import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import * as ConfigApi from '@/api/infra/config' const autoCodeSwitch = await ConfigApi.getConfigKey('sparePartCodeAutoSwitch') const autoSwitch = ref(false) if (autoCodeSwitch == 'TRUE') { autoSwitch.value = true } // 表单校验 export const SparePartRules = reactive({ code: [required], name: [required], isOverall: [required], images: [required], uom: [required], }) export const SparePart = useCrudSchemas(reactive([ { label: 'id', field: 'id', sort: 'custom', isSearch: false, isTable: false, isForm: false, isDetail:false }, { label: '备件编号', field: 'code', sort: 'custom', isForm: !autoSwitch.value, isSearch: true, fixed: 'left' }, { label: '名称', field: 'name', sort: 'custom', isSearch: true, }, { label: '品牌', field: 'brand', sort: 'custom', isSearch: true, }, { label: '规格型号', field: 'specifications', sort: 'custom', isSearch: true, }, { label: '是否全局', field: 'isOverall', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 isSearch: true, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } } }, { label: '科目', field: 'subject', sort: 'custom', dictType: DICT_TYPE.SUBJECT, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 isSearch: true, form: { component: 'Select' } }, { label: '科目代码', field: 'subjectCode', sort: 'custom', isSearch: true, }, { label: '类别', field: 'type', sort: 'custom', isSearch: true, }, { label: '图片', field: 'images', sort: 'custom', isSearch: false, }, { label: '区域', field: 'region', sort: 'custom', dictType: DICT_TYPE.REGION, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 isSearch: true, form: { component: 'Select' } }, { label: '备件分类', field: 'classification', sort: 'custom', dictType: DICT_TYPE.PART_CLASS, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 isSearch: true, form: { component: 'Select' } }, { label: '计量单位字典', field: 'uom', sort: 'custom', dictType: DICT_TYPE.UOM, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 isSearch: true, }, { label: '单价', field: 'singlePrice', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 }, }, { label: '生产厂家字符', field: 'manufacturer', sort: 'custom', isSearch: true, }, { label: '库存下限', field: 'minInventory', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 }, }, { label: '库存上限', field: 'maxInventory', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 }, }, { label: '更换周期', field: 'replacementCycle', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 }, }, { label: '存放位置描述', field: 'storageLocation', sort: 'custom', isSearch: false, }, { label: '创建时间', field: 'createTime', sort: 'custom', formatter: dateFormatter, isSearch: false, isTable: false, isForm: false, isDetail:false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, }, { label: '部门id', field: 'departmentCode', sort: 'custom', isSearch: false, isTable: false, isForm: false, isDetail:false, }, { label: '备注', field: 'remark', sort: 'custom', isSearch: false, }, { label: '地点ID', field: 'siteId', sort: 'custom', isSearch: false, isTable: false, isForm: false, isDetail:false, }, { label: '是否可用默认TRUE', field: 'available', sort: 'custom', isSearch: false, isTable: false, isForm: false, isDetail:false, }, { label: '删除时间', field: 'deletionTime', sort: 'custom', formatter: dateFormatter, isSearch: false, isTable: false, isForm: false, isDetail:false, search: { component: 'DatePicker', componentProps: { valueFormat: 'YYYY-MM-DD HH:mm:ss', type: 'daterange', defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] } }, form: { component: 'DatePicker', componentProps: { type: 'datetime', valueFormat: 'x' } }, }, { label: '删除人id', field: 'deleterId', sort: 'custom', isSearch: false, isTable: false, isForm: false, isDetail:false, }, { label: '并发乐观锁', field: 'concurrencyStamp', sort: 'custom', isSearch: false, isTable: false, isForm: false, isDetail:false, form: { component: 'InputNumber', value: 0 }, }, { label: '操作', field: 'action', isForm: false, table: { width: 150, fixed: 'right' } } ]))