| | |
| | | import { |
| | | DICT_TYPE, |
| | | MesAutoCodeRuleCode, |
| | | MesQcIndicatorItemType, |
| | | MesQcResultValueType, |
| | | } from '@vben/constants'; |
| | | import { getDictOptions } from '@vben/hooks'; |
| | | |
| | | import { Button } from 'ant-design-vue'; |
| | | |
| | | import { getIndicatorList } from '#/api/mes/qc/indicator'; |
| | | import { generateAutoCode } from '#/api/mes/md/autocode/record'; |
| | | |
| | | import { QcIndicatorResultSpecificationInput } from './components'; |
| | |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'itemType', |
| | | label: '条目类型', |
| | | component: 'RadioGroup', |
| | | defaultValue: MesQcIndicatorItemType.RECORD, |
| | | componentProps: { |
| | | options: [ |
| | | { label: '录入项', value: MesQcIndicatorItemType.RECORD }, |
| | | { label: '分组项', value: MesQcIndicatorItemType.GROUP }, |
| | | ], |
| | | optionType: 'button', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'parentId', |
| | | label: '所属分组', |
| | | component: 'ApiSelect', |
| | | componentProps: { |
| | | allowClear: true, |
| | | api: async () => { |
| | | const list = await getIndicatorList(); |
| | | // 仅可选择分组项作为父级,且分组项本身不可再挂父级(仅两级) |
| | | return list |
| | | .filter((i) => i.itemType === MesQcIndicatorItemType.GROUP) |
| | | .map((i) => ({ label: i.name, value: i.id })); |
| | | }, |
| | | placeholder: '不选则为顶级项', |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['itemType'], |
| | | // 分组项必须为顶级,隐藏并清空上级 |
| | | show: (values) => values.itemType !== MesQcIndicatorItemType.GROUP, |
| | | if: (values) => values.itemType !== MesQcIndicatorItemType.GROUP, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'type', |
| | | label: '检测项类型', |
| | | component: 'Select', |
| | |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'formulaText', |
| | | label: '公式文本', |
| | | component: 'Input', |
| | | componentProps: { |
| | | maxlength: 500, |
| | | placeholder: '如 w3 = c × V × 0.06005 / m × 100%(仅展示,不参与计算)', |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['itemType'], |
| | | if: (values) => values.itemType === MesQcIndicatorItemType.GROUP, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'tool', |
| | | label: '检测工具', |
| | | component: 'Input', |
| | | componentProps: { |
| | | maxlength: 100, |
| | | placeholder: '请输入检测工具', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'unitText', |
| | | label: '单位文本', |
| | | component: 'Input', |
| | | componentProps: { |
| | | maxlength: 50, |
| | | placeholder: '如 %、g、无,仅展示不参与计算', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'sortOrder', |
| | | label: '排序号', |
| | | component: 'InputNumber', |
| | | defaultValue: 0, |
| | | componentProps: { |
| | | min: 0, |
| | | precision: 0, |
| | | placeholder: '同级排序,数字小的在前', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | placeholder: '请选择结果值类型', |
| | | }, |
| | | rules: 'required', |
| | | dependencies: { |
| | | triggerFields: ['itemType'], |
| | | // 分组项不录入结果值,隐藏并跳过校验 |
| | | if: (values) => values.itemType !== MesQcIndicatorItemType.GROUP, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'resultSpecification', |
| | |
| | | minWidth: 160, |
| | | }, |
| | | { |
| | | field: 'itemType', |
| | | title: '条目类型', |
| | | width: 90, |
| | | formatter: ({ cellValue }) => |
| | | cellValue === MesQcIndicatorItemType.GROUP ? '分组项' : '录入项', |
| | | }, |
| | | { |
| | | field: 'parentName', |
| | | title: '所属分组', |
| | | width: 120, |
| | | formatter: ({ cellValue }) => cellValue || '-', |
| | | }, |
| | | { |
| | | field: 'type', |
| | | title: '检测项类型', |
| | | width: 120, |
| | |
| | | width: 140, |
| | | }, |
| | | { |
| | | field: 'unitText', |
| | | title: '单位', |
| | | width: 80, |
| | | formatter: ({ cellValue }) => cellValue || '-', |
| | | }, |
| | | { |
| | | field: 'resultType', |
| | | title: '结果值类型', |
| | | width: 120, |