From dc7c01777e52cb61c618f45c0da0cdca697ff166 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期五, 16 十月 2026 14:34:18 +0800
Subject: [PATCH] 修复设备核查计划明细导出弹窗:按钮重做+未录入置灰+错误拦截

---
 src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue |   57 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue b/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
index acb3591..a4a37a4 100644
--- a/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
+++ b/src/views/CNAS/resourceDemand/device/component/equipmentVerificationPlan.vue
@@ -202,10 +202,15 @@
       </span></template>
     </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>
-      </span>
+      <div class="down-row">
+        <span>1銆佷华鍣ㄨ澶囨湡闂存牳鏌ヨ褰曡〃锛堟牳鏌ヨ褰曪級</span>
+        <el-button type="primary" :loading="outLoading" :disabled="!downRow.recordStatus" @click="controlDown">瀵� 鍑�</el-button>
+      </div>
+      <div class="down-row">
+        <span>2銆佷华鍣ㄨ澶囨湡闂存牳鏌ユ瘮瀵硅褰曡〃锛堟瘮瀵硅褰曪級</span>
+        <el-button type="primary" :loading="outLoading" :disabled="!downRow.recordContrastStatus" @click="processingDown">瀵� 鍑�</el-button>
+      </div>
+      <div class="down-tip">缃伆琛ㄧず瀵瑰簲璁板綍灏氭湭褰曞叆锛堢姸鎬佷负"鏈紑濮�"锛夛紝璇峰厛鐐�"璁板綍"/"瀵规瘮"褰曞叆鍚庡啀瀵煎嚭</div>
       <template #footer><span  class="dialog-footer">
         <el-button @click="downloadDialog = false">鍙� 娑�</el-button>
       </span></template>
@@ -596,13 +601,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 +634,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 +702,7 @@
 .title {
   position: relative;
   font-size: 16px;
-  color: #333;
+  color: var(--lims-text);
   font-weight: 400;
   padding-left: 10px;
   margin-bottom: 10px;
@@ -693,4 +718,18 @@
   background-color: var(--el-color-primary);
   border-radius: 2px;
 }
+
+.down-row {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  padding: 8px 4px;
+  border-bottom: 1px solid #ebeef5;
+}
+
+.down-tip {
+  margin-top: 10px;
+  color: #909399;
+  font-size: 12px;
+}
 </style>

--
Gitblit v1.9.3