2024-11-14 13:43:41 +08:00
|
|
|
|
/**
|
2024-11-15 17:30:24 +08:00
|
|
|
|
* 项目:中核预埋件检测
|
|
|
|
|
* 模型分组:数据管理
|
|
|
|
|
* 模型名称:设备表
|
2024-11-14 13:43:41 +08:00
|
|
|
|
* @Author: xiongwei
|
2024-11-15 17:30:24 +08:00
|
|
|
|
* @Date: 2024-11-15 11:50:00
|
2024-11-14 13:43:41 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { BasicColumn } from '@/components/Table';
|
|
|
|
|
import { FormSchema } from '@/components/Table';
|
|
|
|
|
|
2024-11-15 17:30:24 +08:00
|
|
|
|
|
2024-11-18 11:44:59 +08:00
|
|
|
|
const colProps = { xs: { span: 24 }, sm: { span: 24 }, lg: { span: 6 } };
|
2024-11-14 13:43:41 +08:00
|
|
|
|
const colPropsInDrawer = { span: 24 };
|
|
|
|
|
|
|
|
|
|
export const schema = {
|
2024-11-15 17:30:24 +08:00
|
|
|
|
model: 'Device',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
viewInPage: false,
|
|
|
|
|
properties: [
|
|
|
|
|
{
|
|
|
|
|
field: 'id',
|
|
|
|
|
label: 'ID系统自动生成',
|
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
form: {
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: false,
|
|
|
|
|
placeholder: 'ID系统自动生成',
|
|
|
|
|
},
|
|
|
|
|
colProps,
|
|
|
|
|
component: 'InputNumber',
|
|
|
|
|
rules: [{ required: true, message: '请输入ID系统自动生成!' }],
|
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-11-15 17:30:24 +08:00
|
|
|
|
field: 'name',
|
|
|
|
|
label: '设备名称',
|
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
form: {
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: false,
|
|
|
|
|
placeholder: '设备名称',
|
|
|
|
|
},
|
|
|
|
|
colProps,
|
|
|
|
|
component: 'Input',
|
|
|
|
|
rules: [{ required: true, message: '请输入设备名称!' }],
|
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'deviceSn',
|
|
|
|
|
label: '设备序列号',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
form: {
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
2024-11-15 17:30:24 +08:00
|
|
|
|
placeholder: '设备序列号',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
},
|
|
|
|
|
colProps,
|
|
|
|
|
component: 'Input',
|
2025-04-23 10:27:38 +08:00
|
|
|
|
rules: [{ required: true, message: '请输入设备序列号!' }],
|
2024-11-14 13:43:41 +08:00
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-11-15 17:30:24 +08:00
|
|
|
|
field: 'deviceIp',
|
|
|
|
|
label: '设备IP地址',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
form: {
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: true,
|
2024-11-15 17:30:24 +08:00
|
|
|
|
placeholder: '设备IP地址',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
},
|
|
|
|
|
colProps,
|
|
|
|
|
component: 'Input',
|
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'createTime',
|
2024-11-18 11:44:59 +08:00
|
|
|
|
label: '创建时间',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
form: {
|
|
|
|
|
colProps,
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: false,
|
|
|
|
|
placeholder: ['开始时间', '结束时间'],
|
|
|
|
|
format: 'YYYY-MM-DD',
|
|
|
|
|
valueFormat: 'YYYY-MM-DD',
|
|
|
|
|
showTime: false,
|
|
|
|
|
},
|
|
|
|
|
component: 'RangePicker',
|
|
|
|
|
rules: [{ required: true, message: '请输入CreateTime!' }],
|
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'updateTime',
|
2024-11-18 11:44:59 +08:00
|
|
|
|
label: '更新时间',
|
2024-11-14 13:43:41 +08:00
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
form: {
|
|
|
|
|
colProps,
|
|
|
|
|
componentProps: {
|
|
|
|
|
allowClear: false,
|
|
|
|
|
placeholder: ['开始时间', '结束时间'],
|
|
|
|
|
format: 'YYYY-MM-DD',
|
|
|
|
|
valueFormat: 'YYYY-MM-DD',
|
|
|
|
|
showTime: false,
|
|
|
|
|
},
|
|
|
|
|
component: 'RangePicker',
|
|
|
|
|
rules: [{ required: true, message: '请输入UpdateTime!' }],
|
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-15 17:30:24 +08:00
|
|
|
|
const queryFields = ['name','deviceSn','deviceIp'];
|
|
|
|
|
const editFields = ['name','deviceSn','deviceIp'];
|
|
|
|
|
const tableFields = ['name','deviceSn','deviceIp','createTime','updateTime'];
|
|
|
|
|
const descriptionFields = ['name','deviceSn','deviceIp','createTime','updateTime'];
|
2024-11-14 13:43:41 +08:00
|
|
|
|
|
|
|
|
|
const queryFieldsIndexMap = new Map(queryFields.map((field, index) => [field, index]));
|
|
|
|
|
export const searchFormSchema: FormSchema[] = schema.properties.filter(item => queryFields.includes(item.field))
|
|
|
|
|
.map(
|
|
|
|
|
({ field, label, form: { ...formProps } }) =>
|
|
|
|
|
({
|
|
|
|
|
field,
|
|
|
|
|
label,
|
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
...formProps,
|
|
|
|
|
required: false,
|
|
|
|
|
rules: [{ required: false }],
|
|
|
|
|
} as FormSchema),
|
|
|
|
|
)
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const indexA = queryFieldsIndexMap.get(a.field) as number;
|
|
|
|
|
const indexB = queryFieldsIndexMap.get(b.field) as number;
|
|
|
|
|
return indexA - indexB;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const editFieldsIndexMap = new Map(editFields.map((field, index) => [field, index]));
|
|
|
|
|
export const formSchema: FormSchema[] = schema.properties.filter(item => editFields.includes(item.field))
|
|
|
|
|
.map(
|
|
|
|
|
({ field, label, defaultValue, form }) =>
|
|
|
|
|
({
|
|
|
|
|
field,
|
|
|
|
|
label,
|
|
|
|
|
defaultValue,
|
|
|
|
|
...form,
|
|
|
|
|
colProps: colPropsInDrawer,
|
|
|
|
|
} as FormSchema),
|
|
|
|
|
)
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const indexA = editFieldsIndexMap.get(a.field) as number;
|
|
|
|
|
const indexB = editFieldsIndexMap.get(b.field) as number;
|
|
|
|
|
return indexA - indexB;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tableFieldsIndexMap = new Map(tableFields.map((field, index) => [field, index]));
|
|
|
|
|
export const columns: BasicColumn[] = schema.properties.filter(item => tableFields.includes(item.field))
|
|
|
|
|
.map(
|
|
|
|
|
({ field, label, table }) =>
|
|
|
|
|
({
|
|
|
|
|
dataIndex: field,
|
|
|
|
|
title: label,
|
|
|
|
|
...table,
|
|
|
|
|
} as BasicColumn)
|
|
|
|
|
)
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const indexA = tableFieldsIndexMap.get(a.dataIndex as string) as number;
|
|
|
|
|
const indexB = tableFieldsIndexMap.get(b.dataIndex as string) as number;
|
|
|
|
|
return indexA - indexB;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const descriptionFieldsIndexMap = new Map(descriptionFields.map((field, index) => [field, index]));
|
|
|
|
|
export const descriptionColumns: BasicColumn[] = schema.properties.filter(item => descriptionFields.includes(item.field))
|
|
|
|
|
.map(
|
|
|
|
|
({ field, label, table }) =>
|
|
|
|
|
({
|
|
|
|
|
dataIndex: field,
|
|
|
|
|
title: label,
|
|
|
|
|
...table,
|
|
|
|
|
} as BasicColumn),
|
|
|
|
|
)
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
const indexA = descriptionFieldsIndexMap.get(a.dataIndex as string) as number;
|
|
|
|
|
const indexB = descriptionFieldsIndexMap.get(b.dataIndex as string) as number;
|
|
|
|
|
return indexA - indexB;
|
|
|
|
|
});
|