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/equipmentCheck.vue |   74 ++++++++++++++++++++++++++-----------
 1 files changed, 52 insertions(+), 22 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/equipmentCheck.vue b/src/views/CNAS/resourceDemand/device/component/equipmentCheck.vue
index b409be9..e414157 100644
--- a/src/views/CNAS/resourceDemand/device/component/equipmentCheck.vue
+++ b/src/views/CNAS/resourceDemand/device/component/equipmentCheck.vue
@@ -17,7 +17,7 @@
           <span style="width: 80px">A浠櫒鍚嶇О锛�</span>
           <el-select v-model="form.adeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
             placeholder="璁惧鍚嶇О" size="small" style="width:200px" @change="(val) => changeMachineName(val, 'A')">
-            <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.id">
+            <el-option v-for="item in equipOptions" :key="item.id" :label="item.label" :value="item.id">
               {{ item.label + '-' + item.value }}
             </el-option>
           </el-select>
@@ -36,7 +36,7 @@
           <span style="width: 80px">B浠櫒鍚嶇О锛�</span>
           <el-select v-model="form.bdeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
             placeholder="璁惧鍚嶇О" size="small" style="width:200px" @change="(val) => changeMachineName(val, 'B')">
-            <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.id">
+            <el-option v-for="item in equipOptions" :key="item.id" :label="item.label" :value="item.id">
               {{ item.label + '-' + item.value }}
             </el-option>
           </el-select>
@@ -55,7 +55,7 @@
           <span style="width: 80px">C浠櫒鍚嶇О锛�</span>
           <el-select v-model="form.cdeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
             placeholder="璁惧鍚嶇О" size="small" style="width:200px" @change="(val) => changeMachineName(val, 'C')">
-            <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.id">
+            <el-option v-for="item in equipOptions" :key="item.id" :label="item.label" :value="item.id">
               {{ item.label + '-' + item.value }}
             </el-option>
           </el-select>
@@ -73,7 +73,7 @@
         <el-button v-if="currentStep === 0" size="small" type="primary" @click="addTableRow">娣诲姞</el-button>
       </div>
       <div style="margin: 10px 0">
-        <el-table ref="yearTable" :data="recordContrastDetailsList" height="300px" style="width: 100% ;"
+        <el-table ref="yearTable" :data="form.recordContrastDetailsList" height="300px" style="width: 100% ;"
  border>
           <el-table-column align="center" header-align="center" label="搴忓彿" type="index" width="60"></el-table-column>
           <el-table-column label="鏍告煡椤圭洰" min-width="170" prop="checkItems">
@@ -127,7 +127,7 @@
         </div>
       </div>
       <template #footer><span  class="dialog-footer">
-        <el-button @click="resetForm">鍙� 娑�</el-button>
+        <el-button @click="handleCancel">鍙� 娑�</el-button>
         <el-button v-if="currentStep === 0 && userId == checkChargerUserId" :loading="submitFormLoading" type="primary" @click="submitCheck">纭�
           瀹�</el-button>
         <el-button v-if="currentStep === 1 && userId == reviewUserId" :loading="submitFormLoading" @click="examine(0)">涓嶉�氳繃</el-button>
@@ -147,10 +147,12 @@
 } from '@/api/cnas/resourceDemand/device.js'
 import { selectUserCondition } from "@/api/business/inspectionTask";
 import {mapGetters} from "@/utils/store-compat";
+import draftSave from '@/mixins/draftSave'
 export default {
   name: "equipment-check",
   // import 寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢�
   components: {},
+  mixins: [draftSave],
   data() {
     // 杩欓噷瀛樻斁鏁版嵁
     return {
@@ -177,7 +179,6 @@
         planDetailsId: '',
       },
       equipOptions: [],
-      recordContrastDetailsList: [],
       userList: [],
       checkChargerUserId: '',
       reviewUserId: ''
@@ -200,10 +201,12 @@
       this.searchInfo()
     },
     searchInfo() {
-      getExamineRecordContrast({ planDetailsId: this.form.planDetailsId }).then(res => {
+      const planDetailsId = this.form.planDetailsId
+      getExamineRecordContrast({ planDetailsId }).then(res => {
         if (res.code === 200) {
-          this.form = { ...res.data }
-          this.recordContrastDetailsList = this.form.recordContrastDetailsList || []
+          // 鏃犲巻鍙茶褰曟椂鎺ュ彛鍙兘杩斿洖绌猴紝planDetailsId 蹇呴』淇濈暀锛屽惁鍒欐棤娉曟彁浜�
+          this.form = { ...(res.data || {}), planDetailsId }
+          this.form.recordContrastDetailsList = this.form.recordContrastDetailsList || []
           if (!this.form.reviewUserId) {
             this.currentStep = 0
           } else {
@@ -213,6 +216,9 @@
             this.currentStep = 2
           }
           this.reviewUserId = this.form.reviewUserId
+          if (this.currentStep === 0) {
+            this.draftRestore('equipmentCheck', 'form', this.form.planDetailsId, 'dialogVisible')
+          }
         }
       }).catch(error => {
         console.error(error)
@@ -220,29 +226,36 @@
     },
     // 璧嬪�间华鍣ㄧ紪鍙�
     changeMachineName(value, type) {
-      const index = this.equipOptions.findIndex(item => item.id === value)
-      if (index > -1) {
-        if (type === 'A') {
-          this.form['adeviceNumber'] = this.equipOptions[index].value
-        }
-        if (type === 'B') {
-          this.form['bdeviceNumber'] = this.equipOptions[index].value
-        }
-        if (type === 'C') {
-          this.form['cdeviceNumber'] = this.equipOptions[index].value
-        }
+      const item = this.equipOptions.find(device => device.id === value)
+      if (type === 'A') {
+        this.form['adeviceNumber'] = item ? item.value : ''
+      }
+      if (type === 'B') {
+        this.form['bdeviceNumber'] = item ? item.value : ''
+      }
+      if (type === 'C') {
+        this.form['cdeviceNumber'] = item ? item.value : ''
       }
     },
     // 娣诲姞琛ㄦ牸鏁版嵁
     addTableRow() {
-      this.recordContrastDetailsList.push({ checkItems: '' })
+      if (!this.form.recordContrastDetailsList) {
+        this.form.recordContrastDetailsList = []
+      }
+      this.form.recordContrastDetailsList.push({ checkItems: '' })
     },
     submitCheck() {
-      this.form.recordContrastDetailsList = this.HaveJson(this.recordContrastDetailsList)
+      const deviceIds = [this.form.adeviceId, this.form.bdeviceId, this.form.cdeviceId].filter(Boolean)
+      if (new Set(deviceIds).size !== deviceIds.length) {
+        this.$message.error('A/B/C 浠櫒涓嶈兘閫夋嫨鍚屼竴鍙拌澶�')
+        return
+      }
+      this.form.recordContrastDetailsList = this.HaveJson(this.form.recordContrastDetailsList || [])
       this.submitFormLoading = true
       addExamineRecordContrast(this.form).then(res => {
         if (res.code == 200) {
           this.$message.success('鏂板鎴愬姛')
+          this.draftClear('equipmentCheck')
           this.resetForm()
         }
         this.submitFormLoading = false
@@ -258,6 +271,7 @@
       reviewExamineRecordContrast(params).then(res => {
         if (res.code == 200) {
           this.$message.success('瀹℃牳鎴愬姛')
+          this.draftClear('equipmentCheck')
           this.resetForm()
         }
         this.submitFormLoading = false
@@ -265,7 +279,23 @@
         this.submitFormLoading = false
       })
     },
+    // 鍙栨秷鎸夐挳锛氱‘璁ゅ悗鏁翠綋娓呯┖鏈鑽夌锛涘彸涓婅鍏抽棴/鎰忓閫�鍑哄垯淇濈暀鑽夌
+    handleCancel() {
+      if (this.currentStep !== 0) {
+        this.resetForm()
+        return
+      }
+      this.$confirm('鍙栨秷鍚庢湰娆″~鍐欑殑鏁版嵁灏嗚娓呯┖锛屼笖鏃犳硶鎭㈠锛屾槸鍚︾户缁紵', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '缁х画濉啓',
+        type: 'warning'
+      }).then(() => {
+        this.draftClear('equipmentCheck')
+        this.resetForm()
+      }).catch(() => {})
+    },
     resetForm() {
+      this.draftStop('equipmentCheck')
       this.dialogVisible = false
       this.$emit('closeDialog')
     },

--
Gitblit v1.9.3