157 lines
5.4 KiB
Vue
157 lines
5.4 KiB
Vue
import { BasicColumn, FormSchema } from '/@/components/Table';
|
|
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
|
import { list as dictList } from '/@/views/system/dict/dict.api';
|
|
import { loadTreeData } from '/@/api/common/api';
|
|
|
|
export const SOURCE_TYPE_OPTIONS = [
|
|
{ label: '数据字典', value: 'dict' },
|
|
{ label: '分类字典', value: 'category' },
|
|
];
|
|
|
|
export const sourceTypeTextMap: Record<string, string> = {
|
|
dict: '数据字典',
|
|
category: '分类字典',
|
|
};
|
|
|
|
export const columns: BasicColumn[] = [
|
|
{ title: '种类键值', align: 'center', dataIndex: 'kindKey', width: 120 },
|
|
{ title: '种类名称', align: 'center', dataIndex: 'kindName', width: 140 },
|
|
{
|
|
title: '数据源',
|
|
align: 'center',
|
|
dataIndex: 'sourceType',
|
|
width: 100,
|
|
customRender: ({ text }) => sourceTypeTextMap[String(text || '')] || text || '',
|
|
},
|
|
{ title: '根名称', align: 'center', dataIndex: 'sourceRootName', width: 140 },
|
|
{ title: '对应分类', align: 'center', dataIndex: 'categoryRefName', width: 140 },
|
|
{ title: '优先级', align: 'center', dataIndex: 'priority', width: 80 },
|
|
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 80, defaultHidden: true },
|
|
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 165 },
|
|
];
|
|
|
|
export const searchFormSchema: FormSchema[] = [
|
|
{ label: '种类键值', field: 'kindKey', component: 'Input', colProps: { span: 6 } },
|
|
{ label: '种类名称', field: 'kindName', component: 'Input', colProps: { span: 6 } },
|
|
{
|
|
label: '数据源',
|
|
field: 'sourceType',
|
|
component: 'Select',
|
|
componentProps: { options: SOURCE_TYPE_OPTIONS, allowClear: true },
|
|
colProps: { span: 6 },
|
|
},
|
|
{ label: '根编码', field: 'sourceRootCode', component: 'Input', colProps: { span: 6 } },
|
|
];
|
|
|
|
export const batchFormSchema: FormSchema[] = [
|
|
{
|
|
label: '数据源',
|
|
field: 'sourceType',
|
|
component: 'Select',
|
|
required: true,
|
|
defaultValue: 'category',
|
|
componentProps: { options: SOURCE_TYPE_OPTIONS },
|
|
},
|
|
{
|
|
label: '数据字典',
|
|
field: 'dictRootCode',
|
|
component: 'ApiSelect',
|
|
required: true,
|
|
ifShow: ({ values }) => values.sourceType === 'dict',
|
|
componentProps: {
|
|
api: () => dictList({ pageNo: 1, pageSize: 500 }),
|
|
resultField: 'records',
|
|
labelField: 'dictName',
|
|
valueField: 'dictCode',
|
|
showSearch: true,
|
|
placeholder: '请选择数据字典根',
|
|
},
|
|
},
|
|
{
|
|
label: '分类字典',
|
|
field: 'categoryRootCode',
|
|
component: 'ApiSelect',
|
|
required: true,
|
|
ifShow: ({ values }) => values.sourceType === 'category',
|
|
componentProps: {
|
|
api: loadTreeData,
|
|
params: { async: false, pcode: '0' },
|
|
resultField: '',
|
|
labelField: 'title',
|
|
valueField: 'code',
|
|
showSearch: true,
|
|
placeholder: '请选择分类字典根',
|
|
},
|
|
},
|
|
];
|
|
|
|
export const editFormSchema: FormSchema[] = [
|
|
{ label: '', field: 'id', component: 'Input', show: false },
|
|
{ label: '', field: 'sourceType', component: 'Input', show: false },
|
|
{ label: '', field: 'sourceRootCode', component: 'Input', show: false },
|
|
{ label: '', field: 'sourceRootName', component: 'Input', show: false },
|
|
{ label: '', field: 'categoryRefId', component: 'Input', show: false },
|
|
{ label: '', field: 'categoryRefCode', component: 'Input', show: false },
|
|
{
|
|
label: '种类键值',
|
|
field: 'kindKey',
|
|
component: 'Input',
|
|
componentProps: { disabled: true },
|
|
},
|
|
{
|
|
label: '种类名称',
|
|
field: 'kindName',
|
|
component: 'Input',
|
|
required: true,
|
|
},
|
|
{
|
|
label: '对应分类',
|
|
field: 'categoryRefName',
|
|
component: 'Input',
|
|
componentProps: { disabled: true },
|
|
},
|
|
{
|
|
label: '优先级',
|
|
field: 'priority',
|
|
component: 'InputNumber',
|
|
required: true,
|
|
componentProps: { min: 0, precision: 0, style: { width: '100%' } },
|
|
},
|
|
{
|
|
label: '租户ID',
|
|
field: 'tenantId',
|
|
component: 'InputNumber',
|
|
componentProps: { disabled: true, style: { width: '100%' } },
|
|
},
|
|
];
|
|
|
|
export const batchJVxeColumns: JVxeColumn[] = [
|
|
{ title: '', key: 'categoryRefId', type: JVxeTypes.hidden },
|
|
{ title: '', key: 'categoryRefCode', type: JVxeTypes.hidden },
|
|
{ title: '', key: 'sourceType', type: JVxeTypes.hidden },
|
|
{ title: '', key: 'sourceRootCode', type: JVxeTypes.hidden },
|
|
{ title: '', key: 'sourceRootName', type: JVxeTypes.hidden },
|
|
{ title: '', key: 'tenantId', type: JVxeTypes.hidden },
|
|
{ title: '种类键值', key: 'kindKey', type: JVxeTypes.normal, width: 200, minWidth: 160, disabled: true },
|
|
{ title: '种类名称', key: 'kindName', type: JVxeTypes.input, width: 180, minWidth: 140 },
|
|
{ title: '对应分类', key: 'categoryRefName', type: JVxeTypes.normal, width: 180, minWidth: 140, disabled: true },
|
|
{
|
|
title: '优先级',
|
|
key: 'priority',
|
|
type: JVxeTypes.inputNumber,
|
|
width: 110,
|
|
minWidth: 90,
|
|
align: 'center',
|
|
validateRules: [{ required: true, message: '请输入优先级' }],
|
|
},
|
|
];
|
|
|
|
export const superQuerySchema = {
|
|
kindKey: { title: '种类键值', order: 0, view: 'text' },
|
|
kindName: { title: '种类名称', order: 1, view: 'text' },
|
|
sourceType: { title: '数据源', order: 2, view: 'list', enum: SOURCE_TYPE_OPTIONS },
|
|
sourceRootCode: { title: '根编码', order: 3, view: 'text' },
|
|
categoryRefName: { title: '对应分类', order: 4, view: 'text' },
|
|
priority: { title: '优先级', order: 5, view: 'number' },
|
|
};
|