| | |
| | | |
| | | const emit = defineEmits(['success']); |
| | | const formType = ref<FormType>('create'); |
| | | const isDetail = computed(() => formType.value === 'detail'); |
| | | const items = ref<MesQcIndicatorResultApi.IndicatorResultDetail[]>([]); |
| | | const ctxData = ref<CtxData>(); |
| | | |
| | | const getTitle = computed(() => |
| | | formType.value === 'update' |
| | | isDetail.value |
| | | ? '检测结果详情' |
| | | : formType.value === 'update' |
| | | ? $t('ui.actionTitle.edit', ['检验结果']) |
| | | : $t('ui.actionTitle.create', ['检验结果']), |
| | | ); |
| | |
| | | : []; |
| | | } |
| | | |
| | | function getDisplayValue(item: MesQcIndicatorResultApi.IndicatorResultDetail) { |
| | | if (item.value === undefined || item.value === null || item.value === '') { |
| | | return '未填写'; |
| | | } |
| | | if (item.valueType === MesQcResultValueType.DICT) { |
| | | return getValueOptions(item.valueSpecification).find( |
| | | (option) => option.value === String(item.value), |
| | | )?.label ?? item.value; |
| | | } |
| | | return item.value; |
| | | } |
| | | |
| | | const [Modal, modalApi] = useVbenModal({ |
| | | async onConfirm() { |
| | | if (!ctxData.value) { |
| | | if (!ctxData.value || isDetail.value) { |
| | | return; |
| | | } |
| | | const { valid } = await formApi.validate(); |
| | |
| | | items.value = []; |
| | | return; |
| | | } |
| | | formApi.setState({ schema: useQcIndicatorResultFormSchema(formApi) }); |
| | | // 加载数据 |
| | | const data = modalApi.getData<CtxData>(); |
| | | ctxData.value = data; |
| | | formType.value = data.formType; |
| | | formApi.setState({ |
| | | schema: useQcIndicatorResultFormSchema(formApi, isDetail.value), |
| | | }); |
| | | formApi.setDisabled(isDetail.value); |
| | | modalApi.setState({ |
| | | showConfirmButton: !isDetail.value, |
| | | cancelText: isDetail.value ? '关闭' : $t('common.cancel'), |
| | | }); |
| | | modalApi.lock(); |
| | | try { |
| | | const detail = await getIndicatorResultDetail( |
| | |
| | | valueNumber: |
| | | (item.valueType === MesQcResultValueType.FLOAT || |
| | | item.valueType === MesQcResultValueType.INTEGER) && |
| | | item.value !== null |
| | | item.value != null && |
| | | String(item.value).trim() !== '' && |
| | | Number.isFinite(Number(item.value)) |
| | | ? Number(item.value) |
| | | : undefined, |
| | | })); |
| | |
| | | id: detail.id, |
| | | code: detail.code, |
| | | remark: detail.remark, |
| | | sn: detail.sn, |
| | | }); |
| | | } finally { |
| | | modalApi.unlock(); |
| | |
| | | <AForm.Item |
| | | :label="`检测项${index + 1}:${item.indicatorName ?? ''}`" |
| | | > |
| | | <div v-if="isDetail" class="whitespace-pre-wrap break-words py-1"> |
| | | {{ getDisplayValue(item) }} |
| | | <div v-if="item.remark" class="mt-1 text-sm text-muted-foreground"> |
| | | 备注:{{ item.remark }} |
| | | </div> |
| | | </div> |
| | | <InputNumber |
| | | v-if=" |
| | | v-else-if=" |
| | | item.valueType === MesQcResultValueType.FLOAT || |
| | | item.valueType === MesQcResultValueType.INTEGER |
| | | " |