From c6e96cdb8b1cfb51e9a45bf86c38d1353e983127 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期一, 19 十月 2026 15:19:48 +0800
Subject: [PATCH] 设备模块业务完善及前序页面优化

---
 src/views/CNAS/resourceDemand/device/component/checkRecord.vue |   40 +++++++++++++++++++++++++++++++---------
 1 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/checkRecord.vue b/src/views/CNAS/resourceDemand/device/component/checkRecord.vue
index 5c7eca4..3fe2c2f 100644
--- a/src/views/CNAS/resourceDemand/device/component/checkRecord.vue
+++ b/src/views/CNAS/resourceDemand/device/component/checkRecord.vue
@@ -1,7 +1,7 @@
 <template>
   <div>
     <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-model="dialogVisible"
-      title="浠櫒璁惧鏈熼棿鏍告煡姣斿璁板綍琛�" width="80%" @close="resetForm">
+      title="浠櫒璁惧鏈熼棿鏍告煡璁板綍琛�" width="80%" @close="resetForm">
       <el-steps :active="currentStep" align-center finish-status="success">
         <el-step title="濉啓璁惧鏍告煡瀵规瘮璁板綍"></el-step>
         <el-step title="瀹℃牳"></el-step>
@@ -10,9 +10,9 @@
         <el-col :span="8">
           <div class="form-item">
             <span style="width: 110px">浠櫒鍚嶇О锛�</span>
-            <el-select v-model="form.deviceName" :disabled="currentStep !== 0" class="table_input" clearable filterable
-              placeholder="璁惧鍚嶇О" size="small" style="width:200px" @change="(val) => changeMachineName(val)">
-              <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.label">
+            <el-select v-model="selectedDeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
+              placeholder="璁惧鍚嶇О" size="small" style="width:200px" @change="changeMachineName">
+              <el-option v-for="item in equipOptions" :key="item.id" :label="item.label" :value="item.id">
                 {{ item.label + '-' + item.value }}
               </el-option>
             </el-select>
@@ -84,11 +84,11 @@
           </div>
         </el-col>
       </el-row>
-      <el-button size="small" style="margin: 10px 0" type="primary" @click="addRow">娣诲姞</el-button>
+      <el-button v-if="currentStep === 0" size="small" style="margin: 10px 0" type="primary" @click="addRow">娣诲姞</el-button>
       <el-table :data="recordDetailList" height="300" style="width: 100%" border>
         <el-table-column label="娴嬭瘯鐐�" min-width="130" prop="testPoint">
           <template #default="scope">
-            <el-input v-model="scope.row.testPoint" clearable size="small"></el-input>
+            <el-input v-model="scope.row.testPoint" :disabled="currentStep !== 0" clearable size="small"></el-input>
           </template>
         </el-table-column>
         <el-table-column min-width="180">
@@ -283,6 +283,7 @@
         { label: '鐩稿鍋忓樊', value: 2 },
       ],
       equipOptions: [],
+      selectedDeviceId: '',
       submitFormLoading: false,
       userList: [],
       reviewUserId: '',
@@ -299,6 +300,7 @@
   methods: {
     openDialog(row) {
       this.dialogVisible = true
+      this.selectedDeviceId = ''
       this.form.planDetailsId = row.planDetailsId
       this.checkChargerUserId = row.checkChargerUserId
       this.getEquipOptions()
@@ -321,19 +323,38 @@
             this.currentStep = 2
           }
           this.reviewUserId = this.form.reviewUserId
+          this.matchDeviceOption()
           this.$nextTick(() => {
             this.draftRestore('checkRecordForm', 'form', this.form.planDetailsId, 'dialogVisible')
             this.draftRestore('checkRecordRows', 'recordDetailList', this.form.planDetailsId, 'dialogVisible')
+            // 鑽夌閲屽彲鑳芥敼杩囪澶囷紝鎭㈠鍚庨噸鏂板尮閰嶄笅鎷夐�変腑椤�
+            this.matchDeviceOption()
           })
         }
       }).catch(error => {
         console.error(error)
       })
     },
-    // 璧嬪�间华鍣ㄧ紪鍙�
+    // 鎸夎澶� id 鍥炲~鍚嶇О鍜岀紪鍙凤紝閬垮厤鍚屽悕璁惧閫夐敊
     changeMachineName(value) {
-      const index = this.equipOptions.findIndex(item => item.deviceName === value)
-      this.form.deviceNumber = this.equipOptions[index].managementNumber
+      const item = this.equipOptions.find(device => device.id === value)
+      if (item) {
+        this.form.deviceName = item.deviceName
+        this.form.deviceNumber = item.managementNumber
+      } else {
+        this.form.deviceName = ''
+        this.form.deviceNumber = ''
+      }
+    },
+    // 鍘嗗彶璁板綍娌℃湁 deviceId锛屾寜鍚嶇О+缂栧彿鍙嶆煡涓嬫媺閫夐」
+    matchDeviceOption() {
+      if (!this.equipOptions.length || !this.form.deviceName) {
+        return
+      }
+      const match = this.form.deviceNumber
+        ? this.equipOptions.find(item => item.deviceName === this.form.deviceName && item.managementNumber === this.form.deviceNumber)
+        : this.equipOptions.find(item => item.deviceName === this.form.deviceName)
+      this.selectedDeviceId = match ? match.id : ''
     },
     addRow() {
       this.recordDetailList.push({ testPoint: '' })
@@ -390,6 +411,7 @@
             m.id = m.id
             return m
           })
+          this.matchDeviceOption()
         }
       }).catch(error => {
         console.error(error)

--
Gitblit v1.9.3