import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' import * as DictTypeApi from '@/api/system/dict/dict.type' const optionsList = await DictTypeApi.getDictTypeAndData('inspection') optionsList.forEach(element => { element.options = element.dictDataRespVOList.map(item => { return { value: element.type + "-%%%-" + item.value, label: element.name + "-" + item.label } }) }) // 表单校验 export const SelectedProjectRules = reactive({ code: [required], dictionaryTypeAndCode: [required], estimateCode: [required], defectLevel: [required], }) export const SelectedProject = useCrudSchemas(reactive([ { label: '编码', field: 'code', sort: 'custom', isTableForm: false, isSearch: true }, { label: '字典及字典项', field: 'dictionaryTypeAndCode', sort: 'custom', formatter: (_: Recordable, __: TableColumn, cellValue: boolean) => { return optionsList.find(item => item.options.some(option => option.value === cellValue))?.options.find(option => option.value === cellValue)?.label }, isSearch: false, isDetail: false, isTable: true, isForm: true, tableForm: { type: 'SelectGroup', initOptions: optionsList, filterable: true, }, form: { component: 'Select', componentProps: { options: optionsList, filterable: true, } }, }, { label: '字典', field: 'dictionaryCode', sort: 'custom', isSearch: false, isTableForm: false, isDetail: false, isTable: false, isForm: false, }, { label: '字典项', field: 'dictionaryValue', sort: 'custom', isSearch: false, isTableForm: false, isDetail: false, isTable: false, isForm: false, }, { label: '字典名称', field: 'dictionaryLabel', sort: 'custom', isSearch: false, isTableForm: false, isDetail: false, isTable: false, isForm: false, }, { label: '评估代码', field: 'estimateCode', sort: 'custom', isSearch: true, dictType: DICT_TYPE.EVALUATION_CODE, dictClass: 'string', tableForm: { type: 'Select', }, form: { component: 'Select', } }, { label: '缺陷级别', field: 'defectLevel', sort: 'custom', isSearch: true, dictType: DICT_TYPE.DEFECT_LEVEL, dictClass: 'string', tableForm: { type: 'Select', }, form: { component: 'Select', } }, { label: '操作', field: 'action', isForm: false, table: { width: 150, fixed: 'right' }, isTableForm: false, } ]))