|
|
|
import { BasicColumn } from '/@/components/Table';
|
|
|
|
import { FormSchema } from '/@/components/Table';
|
|
|
|
import { h } from 'vue';
|
|
|
|
//import { Tooltip } from 'ant-design-vue';
|
|
|
|
|
|
|
|
// 列表数据
|
|
|
|
//列表数据
|
|
|
|
export const columns: BasicColumn[] = [
|
|
|
|
{
|
|
|
|
/*{
|
|
|
|
title: 'ID',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'id',
|
|
|
|
width: 200,
|
|
|
|
customRender: ({ text, record }) => {
|
|
|
|
// 调试:检查ID值和原始记录
|
|
|
|
console.log(`ID渲染 - 值: ${text}, 记录:`, record);
|
|
|
|
|
|
|
|
// 如果ID为空,显示详细的调试信息
|
|
|
|
if (!text || text === 'ID-未找到') {
|
|
|
|
return h('div', { style: 'color: #f50; cursor: help;', title: '点击查看详情' }, [
|
|
|
|
h('span', { style: 'font-weight: bold;' }, 'ID缺失'),
|
|
|
|
h('div', { style: 'font-size: 10px; margin-top: 4px;' }, `字段: ${Object.keys(record._raw || {}).join(', ')}`),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return h('span', { style: 'font-family: monospace' }, text);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '文本内容',
|
|
|
|
},*/
|
|
|
|
/*{
|
|
|
|
title: '文件名称',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'text',
|
|
|
|
width: 300
|
|
|
|
},
|
|
|
|
},*/
|
|
|
|
{
|
|
|
|
title: '文件名称',
|
|
|
|
title: '文档名称',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'docName',
|
|
|
|
width: 150
|
|
|
|
width: 180,
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
return renderMetadataField(record, 'docName');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '知识ID',
|
|
|
|
title: '文件内容',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'text',
|
|
|
|
},
|
|
|
|
/* {
|
|
|
|
title: '知识库ID',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'knowledgeId',
|
|
|
|
width: 150
|
|
|
|
width: 150,
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
return renderMetadataField(record, 'knowledgeId');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '文档名称',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'docName',
|
|
|
|
width: 180,
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
return renderMetadataField(record, 'docName');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '文档ID',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'docId',
|
|
|
|
width: 150
|
|
|
|
width: 150,
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
return renderMetadataField(record, 'docId');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '索引',
|
|
|
|
title: '索引位置',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'index',
|
|
|
|
width: 80
|
|
|
|
width: 100,
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
return renderMetadataField(record, 'index');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '相似度',
|
|
|
|
title: 'metadata',
|
|
|
|
align: 'center',
|
|
|
|
dataIndex: 'similarity',
|
|
|
|
width: 100
|
|
|
|
dataIndex: 'metadata',
|
|
|
|
customRender: ({ text }) => {
|
|
|
|
if (!text) return '-';
|
|
|
|
|
|
|
|
try {
|
|
|
|
// 尝试解析JSON
|
|
|
|
const metadata = typeof text === 'string' ? JSON.parse(text) : text;
|
|
|
|
|
|
|
|
// 创建元数据标签
|
|
|
|
const tags = Object.entries(metadata).map(([key, value]) => h(tags, { color: 'blue' }, `${key}: ${value}`));
|
|
|
|
|
|
|
|
return h(
|
|
|
|
Tooltip,
|
|
|
|
{
|
|
|
|
title: h('pre', JSON.stringify(metadata, null, 2)),
|
|
|
|
overlayStyle: { maxWidth: '600px' },
|
|
|
|
},
|
|
|
|
() => h('div', { style: 'display: flex; flex-wrap: wrap; gap: 4px;' }, tags)
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
// 无法解析时显示原始文本
|
|
|
|
const displayText = typeof text === 'string' ? text : JSON.stringify(text);
|
|
|
|
const shortText = displayText.length > 20 ? displayText.substring(0, 20) + '...' : displayText;
|
|
|
|
|
|
|
|
return h(Tooltip, { title: displayText }, () => h('span', shortText));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},*/
|
|
|
|
];
|
|
|
|
|
|
|
|
// 查询数据
|
|
|
|
export const searchFormSchema: FormSchema[] = [];
|
|
|
|
function renderMetadataField(record: any, fieldName: string) {
|
|
|
|
if (!record.metadata) return '-';
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
export const formSchema: FormSchema[] = [
|
|
|
|
try {
|
|
|
|
// 尝试解析metadata
|
|
|
|
const metadata = typeof record.metadata === 'string' ? JSON.parse(record.metadata) : record.metadata;
|
|
|
|
|
|
|
|
// 获取字段值
|
|
|
|
const value = metadata[fieldName];
|
|
|
|
|
|
|
|
if (value === undefined || value === null) {
|
|
|
|
return h('span', { style: 'color: #999' }, '无');
|
|
|
|
}
|
|
|
|
|
|
|
|
// 根据字段类型渲染
|
|
|
|
switch (fieldName) {
|
|
|
|
case 'knowledgeId':
|
|
|
|
case 'docId':
|
|
|
|
return h('span', { style: 'font-family: monospace' }, value);
|
|
|
|
|
|
|
|
case 'index':
|
|
|
|
return h('span', { style: 'font-weight: bold' }, value);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return h('span', value);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
return h('span', { style: 'color: #f50' }, '解析错误');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询数据
|
|
|
|
export const searchFormSchema: FormSchema[] = [
|
|
|
|
{
|
|
|
|
label: 'text',
|
|
|
|
label: '文本内容',
|
|
|
|
field: 'text',
|
|
|
|
component: 'Input',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
//表单数据
|
|
|
|
export const formSchema: FormSchema[] = [
|
|
|
|
{
|
|
|
|
label: '文件名称',
|
|
|
|
field: 'docName', // 使用新的字段名
|
|
|
|
component: 'Input',
|
|
|
|
required: true,
|
|
|
|
componentProps: {
|
|
|
|
placeholder: '请输入文档名称',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '文本内容',
|
|
|
|
field: 'text',
|
|
|
|
required: true,
|
|
|
|
component: 'InputTextArea',
|
|
|
|
},
|
|
|
|
// TODO 主键隐藏字段,目前写死为ID
|
|
|
|
{
|
|
|
|
label: '',
|
|
|
|
field: 'id',
|
|
...
|
...
|
@@ -67,13 +179,14 @@ export const formSchema: FormSchema[] = [ |
|
|
|
|
|
|
|
// 高级查询数据
|
|
|
|
export const superQuerySchema = {
|
|
|
|
name: { title: 'text', order: 0, view: 'text', type: 'string' },
|
|
|
|
name: { title: 'name', order: 0, view: 'text', type: 'string' },
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 流程表单调用这个方法获取formSchema
|
|
|
|
* 流程表单调用这个方法获取formSchemaqrtz_fired_triggers
|
|
|
|
* @param param
|
|
|
|
*/
|
|
|
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
|
|
|
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
|
|
|
|
return formSchema;
|
|
|
|
} |
...
|
...
|
|