import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import { getSamplingScheme } from '@/api/qms/sampleCode/index' import { validateNum } from '@/utils/validator' // 表单校验 export const SampleCodeRules = reactive({ code: [required], batchLowLimiting: [{ validator: validateNum, message: '请输入整数', trigger: 'blur' }], batchUpperLimiting: [ { required: true, message: '该项为必填', trigger: 'blur' }, { validator: validateNum, message: '请输入整数', trigger: 'blur' } ], s1: [required], s2: [required], s3: [required], s4: [required], g1: [required], g2: [required], g3: [required] }) const samplingSchemeList = await getSamplingScheme() export const SampleCode = useCrudSchemas( reactive([ { label: '采样方案编码', field: 'code', sort: 'custom', isSearch: true, form: { component: 'Select', componentProps: { options: samplingSchemeList, optionsAlias: { labelField: 'code', valueField: 'code' } } }, table: { width: 175, fixed: 'left' } }, { label: '批量下限', field: 'batchLowLimiting', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 } }, { label: '批量上限', field: 'batchUpperLimiting', sort: 'custom', isSearch: true, form: { component: 'InputNumber', value: 0 } }, { label: 's1', field: 's1', sort: 'custom' }, { label: 's2', field: 's2', sort: 'custom' }, { label: 's3', field: 's3', sort: 'custom' }, { label: 's4', field: 's4', sort: 'custom' }, { label: 'g1', field: 'g1', sort: 'custom' }, { label: 'g2', field: 'g2', sort: 'custom' }, { label: 'g3', field: 'g3', sort: 'custom' }, { label: '是否可用', field: 'available', sort: 'custom', dictType: DICT_TYPE.TRUE_FALSE, isSearch: true, isForm: false, dictClass: 'string', // 默认都是字符串类型其他暂不考虑 search: { value: 'TRUE' }, form: { component: 'Switch', value: 'TRUE', componentProps: { inactiveValue: 'FALSE', activeValue: 'TRUE' } }, table: { width: 110 } }, { label: '创建时间', field: 'createTime', isForm: false, table: { width: 180 }, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x' } } }, { label: '创建者', field: 'creator', table: { width: 130 }, isForm: false, isTable: true }, { label: '最后更新时间', field: 'updateTime', sort: 'custom', isDetail: true, isForm: false, isTable: false, formatter: dateFormatter, detail: { dateFormat: 'YYYY-MM-DD HH:mm:ss' }, table: { width: 180 }, form: { component: 'DatePicker', componentProps: { style: { width: '100%' }, type: 'datetime', dateFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'x' } } }, { label: '最后更新者', field: 'updater', isDetail: true, isForm: false, isTable: false, table: { width: 150 } }, { label: '操作', field: 'action', isForm: false, isDetail: false, table: { width: 150, fixed: 'right' } } ]) )