AiragLog.data.ts 4.9 KB
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { listKnowledgeName, listmodelid } from '@/views/super/airag/airaglog/AiragLog.api';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '序号',
    align: 'center',
    dataIndex: 'index', // 使用数据中的index字段
    key: 'index',
    width: 60,
    // 移除原有的customRender
  },
  {
    title: '问题',
    align: 'center',
    dataIndex: 'question',
  },
  {
    title: '回答',
    align: 'center',
    dataIndex: 'answer',
    width: 500,
  },
  {
    title: '模型名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '提问者',
    align: 'center',
    dataIndex: 'createBy',
  },
  {
    title: '提问时间',
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: '回答方式',
    align: 'center',
    dataIndex: 'answerType',
    customRender: ({ text }) => {
      const statusMap = {
        1: '问题库回答',
        2: '模型回答',
        3: '未命中',
      };
      return statusMap[text];
    },
  },
  {
    title: '是否存入问题库',
    align: 'center',
    dataIndex: 'isStorage',
    customRender: ({ text }) => {
      return text === 1 ? '已存入' : '未存入';
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '问题',
    field: 'question',
    component: 'Input', // 替换为文本域组件
  },
  // 新增知识库选择字段
  {
    label: '模型名称',
    field: 'name', // 注意:这里使用knowledgeId作为字段名
    component: 'ApiSelect',
    componentProps: {
      api: listmodelid,
      labelField: 'name', // 显示知识库名称
      valueField: 'id', // 提交知识库ID
      showSearch: true,
      filterOption: (input: string, option: any) => {
        return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
      },
    },
  },
  {
    label: '提问时间',
    field: 'createTimeStr',
    component: 'RangePicker', // 改用支持时间的组件
    componentProps: {
      showTime: true, // 启用时间选择
      format: 'YYYY-MM-DD HH:mm:ss', // 日期时间格式
      valueFormat: 'YYYY-MM-DD HH:mm:ss', // 绑定值格式
      placeholder: ['开始时间', '结束时间'],
    },
  },
  {
    label: '回答方式',
    field: 'answerType',
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '未命中',
          value: 3,
        },
        {
          label: '模型回答',
          value: 2,
        },
        {
          label: '问题库回答',
          value: 1,
        },
      ],
    },
  },
  {
    label: '是否存入',
    field: 'isStorage',
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '已存入',
          value: 1,
        },
        {
          label: '未存入',
          value: 0,
        },
      ],
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '模型名称',
    field: 'name', // 注意:这里使用knowledgeId作为字段名
    component: 'Input',
    required: true,
    componentProps: {
      api: listmodelid, // 使用知识库接口
      labelField: 'name', // 显示知识库名称
      valueField: 'id', // 提交知识库ID
      showSearch: true,
      readonly: true,
      filterOption: (input: string, option: any) => {
        return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
      },
    },
  },
  {
    label: '问题',
    field: 'question',
    component: 'Input',
  },
  {
    label: '回答',
    field: 'answer',
    component: 'InputTextArea',
    componentProps: {
      autoSize: {
        minRows: 1, // 最小行数
        maxRows: 10, // 最大行数
      },
      style: { width: '100%' }, // 宽度自适应
    },
  },
  {
    label: '知识库',
    field: 'knowledgeId', // 注意:这里使用knowledgeId作为字段名
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: listKnowledgeName,
      labelField: 'name', // 显示知识库名称
      valueField: 'id', // 提交知识库ID
      showSearch: true,
      filterOption: (input: string, option: any) => {
        return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
      },
    },
  },
  // TODO 主键隐藏字段,目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  question: { title: '问题', order: 0, view: 'text', type: 'string' },
  answer: { title: '回答', order: 1, view: 'text', type: 'string' },
  modelId: { title: '模型ID', order: 2, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
  return formSchema;
}