From 39154a82354b08c2449918c0665457fdb2701b9b Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期五, 16 十月 2026 16:02:23 +0800
Subject: [PATCH] 设备模块各标签页弹窗新增草稿自动保存与恢复:编辑或录入数据中途关闭/刷新页面,再次打开同一弹窗时自动恢复未保存的编辑内容(弹窗显示"已恢复上次未保存的编辑内容"提示),保存成功后草稿自动清除;新增 src/mixins/draftSave.js 同时清理设备死代码:management.vue 数采配置旧弹窗及其提交方法、calibration.vue 被注释的导出按钮、device.js 中 numberCollect/deviceMetricRecordExport 两个死接口定义

---
 src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue |   43 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue b/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
index acb3591..0aa34b9 100644
--- a/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
+++ b/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
@@ -203,8 +203,8 @@
     </el-dialog>
     <el-dialog v-model="downloadDialog" title="瀵煎嚭" width="600px">
       <span>
-        <el-button :loading="outLoading" plain type="primary" @click="controlDown">鏍告煡璁板綍</el-button>
-        <el-button :loading="outLoading" plain type="primary" @click="processingDown">鏍告煡姣斿璁板綍</el-button>
+        <el-button :loading="outLoading" type="primary" :disabled="!downRow.recordStatus" @click="controlDown">鏍告煡璁板綍</el-button>
+        <el-button :loading="outLoading" type="primary" :disabled="!downRow.recordContrastStatus" @click="processingDown">鏍告煡姣斿璁板綍</el-button>
       </span>
       <template #footer><span  class="dialog-footer">
         <el-button @click="downloadDialog = false">鍙� 娑�</el-button>
@@ -249,10 +249,12 @@
 } from '@/api/cnas/resourceDemand/device.js'
 import { selectUserCondition } from "@/api/performance/class";
 import { mapGetters } from "@/utils/store-compat";
+import draftSave from '@/mixins/draftSave'
 export default {
   name: "equipment-verification-plan",
   // import 寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢�
   components: { AddVerificationYearPlanDia, CheckRecord, EquipmentCheck },
+  mixins: [draftSave],
   props: {
     clickNodeVal: {
       type: Object,
@@ -495,6 +497,9 @@
       if (this.operationType !== 'add') {
         this.$nextTick(() => {
           this.form = this.HaveJson(row)
+          if (this.operationType !== 'view') {
+            this.draftRestore('equipmentVerificationPlan', 'form', this.form.planDetailsId, 'dialogVisible')
+          }
         })
       } else {
         this.form = {
@@ -510,6 +515,7 @@
           planId: this.currentRow.planId,
           planDetailsId: '',
         }
+        this.draftRestore('equipmentVerificationPlan', 'form', this.form.planId, 'dialogVisible')
       }
     },
     // 鎻愪氦琛ㄥ崟
@@ -521,6 +527,7 @@
             addDeviceExaminePlanDetail(this.form).then(res => {
               if (res.code == 200) {
                 this.$message.success('鏂板鎴愬姛')
+                this.draftClear('equipmentVerificationPlan')
                 this.dialogVisible = false
                 this.getYearTableData()
               }
@@ -533,6 +540,7 @@
             updateDeviceExaminePlanDetail(this.form).then(res => {
               if (res.code == 200) {
                 this.$message.success('鏂板鎴愬姛')
+                this.draftClear('equipmentVerificationPlan')
                 this.dialogVisible = false
                 this.getYearTableData()
               }
@@ -564,6 +572,7 @@
       })
     },
     resetForm() {
+      this.draftStop('equipmentVerificationPlan')
       this.$refs.modelForm.resetFields();
       this.dialogVisible = false
     },
@@ -596,13 +605,32 @@
       this.downRow = row
       this.downloadDialog = true
     },
+    // 瀵煎嚭缁撴灉鎷︽埅: 鍚庣杩斿洖閿欒 JSON 鏃舵彁绀洪敊璇�, 涓嶅瓨鎴愬潖鏂囦欢
+    saveDocx(res, filename) {
+      const reader = new FileReader();
+      reader.readAsText(res, 'utf-8');
+      reader.onload = () => {
+        const text = (reader.result || '').trim();
+        if (text.startsWith('{') || text.startsWith('[')) {
+          let msg = '瀵煎嚭澶辫触';
+          try { msg = JSON.parse(text).msg || msg; } catch (e) {}
+          this.$message.error(msg);
+        } else {
+          this.$download.saveAs(new Blob([res], { type: 'application/msword' }), filename);
+        }
+      };
+      reader.onerror = () => {
+        this.$download.saveAs(new Blob([res], { type: 'application/msword' }), filename);
+      };
+    },
     // 鏍告煡璁板綍瀵煎嚭
     controlDown() {
       this.outLoading = true
       exportReviewExamineRecordDetail({ planDetailsId: this.downRow.planDetailsId }).then(res => {
         this.outLoading = false
-        const blob = new Blob([res], { type: 'application/octet-stream' });
-        this.$download.saveAs(blob, '浠櫒璁惧鏈熼棿鏍告煡璁板綍琛�.doc')
+        this.saveDocx(res, '浠櫒璁惧鏈熼棿鏍告煡璁板綍琛�.doc')
+      }).catch(() => {
+        this.outLoading = false
       })
     },
     // 鏍告煡瀵规瘮瀵煎嚭
@@ -610,8 +638,9 @@
       this.outLoading = true
       exportReviewExamineRecordContrast({ planDetailsId: this.downRow.planDetailsId }).then(res => {
         this.outLoading = false
-        const blob = new Blob([res], { type: 'application/octet-stream' });
-        this.$download.saveAs(blob, '浠櫒璁惧鏈熼棿鏍告煡姣斿璁板綍琛�.doc')
+        this.saveDocx(res, '浠櫒璁惧鏈熼棿鏍告煡姣斿璁板綍琛�.doc')
+      }).catch(() => {
+        this.outLoading = false
       })
     },
     // 瀵煎叆娴佺▼
@@ -677,7 +706,7 @@
 .title {
   position: relative;
   font-size: 16px;
-  color: #333;
+  color: var(--lims-text);
   font-weight: 400;
   padding-left: 10px;
   margin-bottom: 10px;

--
Gitblit v1.9.3