From c1a9bd81744474027abc73abcc778fd2798ec7ec Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 18 九月 2026 14:39:43 +0800
Subject: [PATCH] feat(mes): 增加质检指标详情查看功能并调整接口配置
---
src/views/mes/qc/indicatorresult/components/form.vue | 76 +++++++++++++++++++++++++++++--------
1 files changed, 59 insertions(+), 17 deletions(-)
diff --git a/src/views/mes/qc/indicatorresult/components/form.vue b/src/views/mes/qc/indicatorresult/components/form.vue
index c6481b2..fc345f8 100644
--- a/src/views/mes/qc/indicatorresult/components/form.vue
+++ b/src/views/mes/qc/indicatorresult/components/form.vue
@@ -6,7 +6,7 @@
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
-import { MesQcResultValueType } from '@vben/constants';
+import { MesQcIndicatorItemType, MesQcResultValueType } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import {
@@ -43,11 +43,49 @@
const items = ref<MesQcIndicatorResultApi.IndicatorResultDetail[]>([]);
const ctxData = ref<CtxData>();
-const getTitle = computed(() =>
- formType.value === 'update'
+const isDetail = computed(() => formType.value === 'detail');
+
+const getTitle = computed(() => {
+ if (formType.value === 'detail') {
+ return $t('ui.actionTitle.view', ['妫�楠岀粨鏋�']);
+ }
+ return formType.value === 'update'
? $t('ui.actionTitle.edit', ['妫�楠岀粨鏋�'])
- : $t('ui.actionTitle.create', ['妫�楠岀粨鏋�']),
-);
+ : $t('ui.actionTitle.create', ['妫�楠岀粨鏋�']);
+});
+
+/** 鍒嗙粍鏍戝钩閾轰负褰曞叆椤瑰垪琛細鍒嗙粍鑺傜偣涓嶅睍绀猴紝浠呭睍寮�鍏跺瓙椤� */
+function flattenRecordItems(
+ nodes: MesQcIndicatorResultApi.IndicatorResultDetail[] | undefined,
+ out: MesQcIndicatorResultApi.IndicatorResultDetail[],
+) {
+ (nodes ?? []).forEach((node) => {
+ if (node.itemType === MesQcIndicatorItemType.GROUP) {
+ flattenRecordItems(node.children, out);
+ return;
+ }
+ out.push({
+ ...node,
+ valueNumber:
+ (node.valueType === MesQcResultValueType.FLOAT ||
+ node.valueType === MesQcResultValueType.INTEGER) &&
+ node.value != null
+ ? Number(node.value)
+ : undefined,
+ });
+ });
+}
+
+/** 璇︽儏灞曠ず鍊硷細骞宠娴嬮噺澶氭壒娆¢】鍙峰悎骞讹紝鍏煎鏃ф暟鎹崟鍊� */
+function measureText(item: MesQcIndicatorResultApi.IndicatorResultDetail) {
+ const vals = (item.measures ?? [])
+ .map((m) => m.value)
+ .filter((v) => v !== undefined && v !== null && v !== '');
+ if (vals.length > 0) {
+ return vals.join('銆�');
+ }
+ return item.value ?? '';
+}
const [Form, formApi] = useVbenForm({
commonConfig: {
@@ -135,6 +173,9 @@
const data = modalApi.getData<CtxData>();
ctxData.value = data;
formType.value = data.formType;
+ const detailMode = data.formType === 'detail';
+ formApi.setDisabled(detailMode);
+ modalApi.setState({ showConfirmButton: !detailMode });
modalApi.lock();
try {
const detail = await getIndicatorResultDetail(
@@ -142,16 +183,10 @@
data.qcType,
data.id,
);
- // 鍥炲~鏁板�煎瓧娈碉紙鐢ㄤ簬 InputNumber 缁戝畾锛�
- items.value = (detail.items ?? []).map((item) => ({
- ...item,
- valueNumber:
- (item.valueType === MesQcResultValueType.FLOAT ||
- item.valueType === MesQcResultValueType.INTEGER) &&
- item.value !== null
- ? Number(item.value)
- : undefined,
- }));
+ // 鍒嗙粍鏍戝钩閾� + 鍥炲~鏁板�煎瓧娈碉紙鐢ㄤ簬 InputNumber 缁戝畾锛�
+ const flat: MesQcIndicatorResultApi.IndicatorResultDetail[] = [];
+ flattenRecordItems(detail.items, flat);
+ items.value = flat;
// 璁剧疆鍒� values
await formApi.setValues({
id: detail.id,
@@ -179,10 +214,17 @@
class="mb-2"
>
<AForm.Item
- :label="`妫�娴嬮」${index + 1}锛�${item.indicatorName ?? ''}`"
+ :label="`妫�娴嬮」${index + 1}锛�${item.indicatorName ?? ''}${
+ isDetail && item.unitText ? `锛�${item.unitText}锛塦 : ''
+ }`"
>
+ <Input
+ v-if="isDetail"
+ :value="measureText(item) || '/'"
+ disabled
+ />
<InputNumber
- v-if="
+ v-else-if="
item.valueType === MesQcResultValueType.FLOAT ||
item.valueType === MesQcResultValueType.INTEGER
"
--
Gitblit v1.9.3