You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
3.1 KiB

1 year ago
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
1 year ago
import {getSamplingScheme} from "@/api/qms/samplingProcess";
import { validateInteger ,validateTwoNum} from '@/utils/validator'
1 year ago
// 表单校验
export const SamplingProcessRules = reactive({
sampleType: [required],
evaluationMode: [required],
description: [required],
sampleQty:ref([{ required: true, message: '该项为必填项', trigger: 'blur' },{validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}]),
1 year ago
sampleProgCode:ref([{ required: true, message: '该项为必填项', trigger: 'blur' }]),
1 year ago
inspectionQty: [required, {validator:validateInteger, message: '请输入正确的整数', trigger: 'blur'}]
1 year ago
})
1 year ago
const samplingSchemeList = await getSamplingScheme()
1 year ago
export const SamplingProcess = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '编码',
field: 'code',
sort: 'custom',
isSearch: true,
1 year ago
isForm: false,
table: {
1 year ago
width: 175,
fixed: 'left'
}
1 year ago
},
{
label: '描述',
field: 'description',
1 year ago
sort: 'custom',
isSearch: true,
1 year ago
table: {
width: 175
}
1 year ago
},
{
label: '取样类型',
field: 'sampleType',
sort: 'custom',
1 year ago
dictType: DICT_TYPE.SAMPLING_TYPE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
1 year ago
isSearch: true,
1 year ago
form: {
component: 'Select'
},
1 year ago
table: {
width: 140
}
1 year ago
},
{
label: '评估模式',
field: 'evaluationMode',
sort: 'custom',
dictType: DICT_TYPE.EVALUATION_MODE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
1 year ago
form: {
component: 'Select'
},
1 year ago
table: {
width: 140
}
1 year ago
},
1 year ago
{
label: '样品份数',
field: 'sampleQty',
1 year ago
sort: 'custom',
1 year ago
table: {
width: 140
}
1 year ago
},
1 year ago
{
label: '采样方案编码',
field: 'sampleProgCode',
sort: 'custom',
1 year ago
form: {
1 year ago
component: 'Select',
componentProps: {
options: samplingSchemeList,
optionsAlias: {
labelField: 'description',
valueField: 'code'
},
}
1 year ago
},
1 year ago
table: {
width: 175
}
1 year ago
},
1 year ago
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isForm: false,
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',
}
},
1 year ago
table: {
width: 175
}
1 year ago
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
form: {
component: 'Switch',
value: 'TRUE',
componentProps: {
inactiveValue: 'FALSE',
activeValue: 'TRUE'
}
},
table: {
width: 110
}
},
1 year ago
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))