Test.data.ts
6.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { listknowledge } from '@/views/super/airag/test/Test.api';
//import { Tooltip } from 'ant-design-vue';
//列表数据
export const columns: BasicColumn[] = [
/*{
title: 'ID',
align: 'center',
dataIndex: 'id',
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: '文件名称',
align: 'center',
dataIndex: 'text',
},*/
{
title: '文档名称',
align: 'center',
dataIndex: 'docName',
width: 180,
customRender: ({ record }) => {
return renderMetadataField(record, 'docName');
},
},
{
title: '文件内容',
align: 'center',
dataIndex: 'text',
},
{
title: '知识库名称',
align: 'center',
dataIndex: 'knowledgeName',
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,
customRender: ({ record }) => {
return renderMetadataField(record, 'docId');
},
},
{
title: '索引位置',
align: 'center',
dataIndex: 'index',
width: 100,
customRender: ({ record }) => {
return renderMetadataField(record, 'index');
},
},
{
title: 'metadata',
align: 'center',
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));
}
},
},*/,
];
function renderMetadataField(record: any, fieldName: string) {
if (!record.metadata) return '-';
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: '文本内容',
field: 'text',
component: 'Input',
},
// 新增知识库选择字段
{
label: '知识库',
field: 'knowledgeId', // 注意:这里使用knowledgeId作为字段名
component: 'ApiSelect',
componentProps: {
api: listknowledge, // 使用知识库接口
labelField: 'name', // 显示知识库名称
valueField: 'id', // 提交知识库ID
showSearch: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
},
},
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '文件名称',
field: 'docName', // 使用新的字段名
component: 'Input',
required: true,
componentProps: {
placeholder: '请输入文档名称',
},
},
{
label: '文本内容',
field: 'text',
required: true,
component: 'JEditor',
},
// 新增知识库选择字段
{
label: '知识库',
field: 'knowledgeId', // 注意:这里使用knowledgeId作为字段名
component: 'ApiSelect',
required: true,
componentProps: {
api: listknowledge, // 使用知识库接口
labelField: 'name', // 显示知识库名称
valueField: 'id', // 提交知识库ID
showSearch: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
},
},
{
label: '',
field: 'docId',
component: 'Input',
show: false,
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
},
];
// 高级查询数据
export const superQuerySchema = {
name: { title: 'name', order: 0, view: 'text', type: 'string' },
};
/**
* 流程表单调用这个方法获取formSchemaqrtz_fired_triggers
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
return formSchema;
}