From 529c2b0204fb8378e3baf2bf4d313e70a93f694a Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 29 四月 2026 17:36:52 +0800
Subject: [PATCH] 更新工序选择逻辑,改用字典数据源 `product_process_type`,并调整相关字段以兼容后端接口

---
 src/views/qualityManagement/metricMaintenance/index.vue |  156 +++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 117 insertions(+), 39 deletions(-)

diff --git a/src/views/qualityManagement/metricMaintenance/index.vue b/src/views/qualityManagement/metricMaintenance/index.vue
index 876d10f..a26f1d7 100644
--- a/src/views/qualityManagement/metricMaintenance/index.vue
+++ b/src/views/qualityManagement/metricMaintenance/index.vue
@@ -1,7 +1,9 @@
 <template>
   <div class="app-container metric-maintenance">
-    <!-- 宸︿晶锛氭娴嬫爣鍑嗗垪琛� -->
-    <div class="left-panel">
+    <el-row :gutter="16" class="metric-maintenance-row">
+      <!-- 宸︿晶锛氭娴嬫爣鍑嗗垪琛� -->
+      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="left-col">
+        <div class="left-panel">
       <div class="toolbar">
         <div class="toolbar-left"></div>
         <div class="toolbar-right">
@@ -19,6 +21,7 @@
         :isSelection="true"
         :tableLoading="tableLoading"
         :rowClassName="rowClassNameCenter"
+        :rowClick="handleTableRowClick"
         @selection-change="handleSelectionChange"
         @pagination="handlePagination"
         :total="page.total"
@@ -81,10 +84,12 @@
           </el-select>
         </template>
       </PIMTable>
-    </div>
+        </div>
+      </el-col>
 
-    <!-- 鍙充晶锛氭爣鍑嗗弬鏁板垪琛� -->
-    <div class="right-panel">
+      <!-- 鍙充晶锛氭爣鍑嗗弬鏁板垪琛� -->
+      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="right-col">
+        <div class="right-panel">
       <div class="right-header">
         <div class="title">鏍囧噯鍙傛暟</div>
         <div class="desc" v-if="currentStandard">
@@ -122,16 +127,18 @@
         <el-table-column prop="defaultValue" label="榛樿鍊�" min-width="120" />
         <el-table-column label="鎿嶄綔" width="140" fixed="right" align="center">
           <template #default="{ row }">
-            <el-button link type="primary" size="small" :disabled="isStandardReadonly" @click="openParamDialog('edit', row)">
+            <el-button link type="primary" :disabled="isStandardReadonly" @click="openParamDialog('edit', row)">
               缂栬緫
             </el-button>
-            <el-button link type="danger" size="small" :disabled="isStandardReadonly" @click="handleParamDelete(row)">
+            <el-button link type="danger" :disabled="isStandardReadonly" @click="handleParamDelete(row)">
               鍒犻櫎
             </el-button>
           </template>
         </el-table-column>
       </el-table>
-    </div>
+        </div>
+      </el-col>
+    </el-row>
 
     <!-- 鏂板 / 缂栬緫妫�娴嬫爣鍑� -->
     <StandardFormDialog
@@ -174,7 +181,6 @@
   qualityTestStandardParamUpdate,
   qualityTestStandardParamDel
 } from '@/api/qualityManagement/metricMaintenance.js'
-import { productProcessListPage } from '@/api/basicData/productProcess.js'
 import StandardFormDialog from './StandardFormDialog.vue'
 import ParamFormDialog from './ParamFormDialog.vue'
 
@@ -212,7 +218,7 @@
     standardNo: [{ required: true, message: '璇疯緭鍏ユ爣鍑嗙紪鍙�', trigger: 'blur' }],
     standardName: [{ required: true, message: '璇疯緭鍏ユ爣鍑嗗悕绉�', trigger: 'blur' }],
     inspectType: [{ required: true, message: '璇烽�夋嫨妫�娴嬬被鍨�', trigger: 'change' }],
-    processId: [{ required: true, message: '璇烽�夋嫨宸ュ簭', trigger: 'change' }]
+    processId: [{ required: false, message: '璇烽�夋嫨宸ュ簭', trigger: 'change' }]
   }
 })
 
@@ -228,24 +234,14 @@
   total: 0
 })
 
-// 宸ュ簭涓嬫媺
-const processOptions = ref([])
-
-// 鑾峰彇宸ュ簭鍒楄〃
-const getProcessList = async () => {
-  try {
-    const res = await productProcessListPage({ current: 1, size: 1000 })
-    if (res?.code === 200) {
-      const records = res?.data?.records || []
-      processOptions.value = records.map(item => ({
-        label: item.processName || item.name || item.label,
-        value: item.id || item.processId || item.value
-      }))
-    }
-  } catch (error) {
-    console.error('鑾峰彇宸ュ簭鍒楄〃澶辫触:', error)
-  }
-}
+// 宸ュ簭涓嬫媺锛氭潵婧愪簬瀛楀吀 product_process_type
+const { product_process_type } = proxy.useDict('product_process_type')
+const processOptions = computed(() => {
+  return (product_process_type?.value || []).map(item => ({
+    label: item.label,
+    value: item.value
+  }))
+})
 
 // 褰撳墠閫変腑鐨勬爣鍑� & 鍙充晶璇︽儏
 const currentStandard = ref(null)
@@ -277,18 +273,21 @@
     dataType: 'slot',
     slot: 'standardNoCell',
     minWidth: 160,
+    align: 'center',
     headerSlot: 'standardNoHeader'
   },
   {
     label: '鏍囧噯鍚嶇О',
     prop: 'standardName',
     minWidth: 180,
+    align: 'center',
     headerSlot: 'standardNameHeader'
   },
   {
     label: '绫诲埆',
     prop: 'inspectType',
     headerSlot: 'inspectTypeHeader',
+    align: 'center',
     dataType: 'tag',
     formatData: (val) => {
       const map = {
@@ -301,12 +300,21 @@
   },
   {
     label: '宸ュ簭',
-    prop: 'processId'
+    prop: 'processId',
+    align: 'center',
+    dataType: 'tag',
+    formatData: (val) => {
+      const target = processOptions.value.find(
+        (item) => String(item.value) === String(val)
+      )
+      return target?.label || val
+    }
   },
   {
     label: '鐘舵��',
     prop: 'state',
     headerSlot: 'stateHeader',
+    align: 'center',
     dataType: 'tag',
     formatData: (val) => {
       const map = {
@@ -325,7 +333,8 @@
   {
     label: '澶囨敞',
     prop: 'remark',
-    minWidth: 160
+    minWidth: 160,
+    align: 'center'
   },
   {
     dataType: 'action',
@@ -378,6 +387,9 @@
     current: page.current,
     size: page.size
   }
+  // processType锛氬瓧鍏� product_process_type 鐨� value
+  // 鍏煎锛氬鏋滃悗绔粛鎺ュ彈 processId锛岃繖閲屼袱鑰呴兘浼氬甫涓�
+  params.processType = params.processId
   qualityTestStandardListPage(params)
     .then((res) => {
       const records = res?.data?.records || []
@@ -412,6 +424,18 @@
 
 const handleSelectionChange = (selection) => {
   selectedRows.value = selection
+
+  if (!selection.length) {
+    currentStandard.value = null
+    detailTableData.value = []
+    return
+  }
+
+  const nextStandard = selection[selection.length - 1]
+  if (currentStandard.value?.id === nextStandard.id) return
+
+  currentStandard.value = nextStandard
+  loadDetail(nextStandard.id)
 }
 
 // 鎵归噺瀹℃牳锛氱姸鎬� 1=鎵瑰噯锛�2=鎾ら攢
@@ -440,7 +464,13 @@
   getStandardList()
 }
 
-// 宸︿晶琛岀偣鍑伙紝鍔犺浇鍙充晶鍙傛暟
+// 琛ㄦ牸琛岀偣鍑伙紝鍔犺浇鍙充晶鍙傛暟
+const handleTableRowClick = (row) => {
+  currentStandard.value = row
+  loadDetail(row.id)
+}
+
+// 宸︿晶琛岀偣鍑伙紝鍔犺浇鍙充晶鍙傛暟锛堜繚鐣欑敤浜庢爣鍑嗙紪鍙峰垪鐨勭偣鍑伙級
 const handleStandardRowClick = (row) => {
   currentStandard.value = row
   loadDetail(row.id)
@@ -560,14 +590,23 @@
       processId: ''
     })
   } else if (type === 'edit' && row) {
-    Object.assign(standardForm.value, row)
+    Object.assign(standardForm.value, {
+      ...row,
+      // 纭繚 inspectType 鍜� state 杞崲涓哄瓧绗︿覆锛屼互鍖归厤 el-select 鐨� value 绫诲瀷
+      inspectType: row.inspectType !== null && row.inspectType !== undefined ? String(row.inspectType) : '',
+      state: row.state !== null && row.state !== undefined ? String(row.state) : '0',
+      // 纭繚 processId 杞崲涓哄瓧绗︿覆鎴栨暟瀛楋紙鏍规嵁瀹為檯闇�瑕侊級
+      processId: row.processId !== null && row.processId !== undefined ? row.processId : ''
+    })
   } else if (type === 'copy' && row) {
     const { id, ...rest } = row
     Object.assign(standardForm.value, {
       ...rest,
       id: undefined,
       standardNo: '',
-      state: '0'
+      state: '0',
+      // 纭繚 inspectType 杞崲涓哄瓧绗︿覆
+      inspectType: rest.inspectType !== null && rest.inspectType !== undefined ? String(rest.inspectType) : ''
     })
   }
   standardDialogVisible.value = true
@@ -580,6 +619,8 @@
 
 const submitStandardForm = () => {
   const payload = { ...standardForm.value }
+  // processType锛氬瓧鍏� product_process_type 鐨� value
+  payload.processType = payload.processId
   const isEdit = standardOperationType.value === 'edit'
   if (isEdit) {
     qualityTestStandardUpdate(payload).then(() => {
@@ -657,23 +698,36 @@
 }
 
 onMounted(() => {
-  getProcessList()
   getStandardList()
 })
 </script>
 
 <style scoped>
-.metric-maintenance {
-  display: flex;
-  gap: 16px;
+.metric-maintenance-row {
+  width: 100%;
+}
+
+.metric-maintenance-row .left-col,
+.metric-maintenance-row .right-col {
+  margin-bottom: 16px;
 }
 
 .left-panel,
 .right-panel {
-  flex: 1;
+  min-width: 0;
   background: #ffffff;
   padding: 16px;
   box-sizing: border-box;
+  overflow: hidden;
+  height: 100%;
+  min-height: 400px;
+}
+
+@media (max-width: 768px) {
+  .left-panel,
+  .right-panel {
+    padding: 12px;
+  }
 }
 
 .toolbar {
@@ -681,6 +735,8 @@
   justify-content: space-between;
   align-items: center;
   margin-bottom: 12px;
+  flex-wrap: wrap;
+  gap: 8px;
 }
 
 .toolbar-left {
@@ -692,6 +748,9 @@
 
 .toolbar-right {
   flex-shrink: 0;
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px;
 }
 
 .search-label {
@@ -751,4 +810,23 @@
 :deep(.center-table .el-table__body-wrapper td .cell) {
   text-align: center !important;
 }
-</style>
\ No newline at end of file
+
+/* PIMTable 琛ㄥご灞呬腑 */
+:deep(.lims-table .pim-table-header-cell) {
+  text-align: center;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+}
+
+:deep(.lims-table .pim-table-header-title) {
+  text-align: center;
+  width: 100%;
+}
+
+:deep(.lims-table .pim-table-header-extra) {
+  width: 100%;
+  margin-top: 4px;
+}
+</style>

--
Gitblit v1.9.3