From 29be8639dc16b5d82bddc6099b1fa5cdca75f77a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 20 十月 2026 16:28:22 +0800
Subject: [PATCH] feat(import): 统一导入弹框与模板,修复模板日期格式及上传报错

---
 src/views/CNAS/process/ensureResults/ensureResultsValidity/index.vue |  118 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 89 insertions(+), 29 deletions(-)

diff --git a/src/views/CNAS/process/ensureResults/ensureResultsValidity/index.vue b/src/views/CNAS/process/ensureResults/ensureResultsValidity/index.vue
index 224c51e..f6346ed 100644
--- a/src/views/CNAS/process/ensureResults/ensureResultsValidity/index.vue
+++ b/src/views/CNAS/process/ensureResults/ensureResultsValidity/index.vue
@@ -62,9 +62,11 @@
       </div>
     </div>
     <div class="plan-detail-card">
+      <el-alert v-if="currentPlan && currentPlan.ratifyStatus !== 1" type="info" :closable="false" show-icon
+        style="margin-bottom: 12px"
+        title="妫�娴嬬被璐ㄦ帶椤圭洰闇�鍦ㄥ勾搴﹁鍒掑鏍搞�佹壒鍑嗛�氳繃鍚庯紝鐐瑰嚮瀵瑰簲琛岀殑鈥滀笅鍙戜换鍔♀�濊繘琛屼笅鍙戯紱闈炴娴嬬被椤圭洰鏃犻渶涓嬪彂銆�" />
       <div class="plan-detail-toolbar">
         <div style="display: flex;">
-          <span class="section-title">璐ㄦ帶椤圭洰</span>
           <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
             <span style="width: 88px;font-size: 14px;font-weight: 700;color: var(--lims-text-2);">璐ㄦ帶椤圭洰</span>
             <el-input v-model="yearDetailForm.monitorProject" placeholder="璇疯緭鍏�" size="small"
@@ -212,27 +214,38 @@
     <!--瀵煎叆璁″垝-->
     <el-dialog v-model="uploadDia" title="鏁版嵁瀵煎叆" width="500px" :close-on-click-modal="false"
       :close-on-press-escape="false">
-      <div style="display: flex; align-items: center;">
-        <span style="width: 60px">骞翠唤锛�</span>
-        <el-date-picker v-model="planYear" type="year" value-format="YYYY" clearable size="small" format="YYYY"
-          placeholder="閫夋嫨骞�">
-        </el-date-picker>
-      </div>
-      <div style="display: flex;align-items: center;margin: 10px 0">
-        <div style="width: 60px">瀹℃牳浜猴細</div>
-        <el-select v-model="examineUserId" clearable filterable size="small" style="width: 50%;">
-          <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
-          </el-option>
-        </el-select>
+      <el-form label-width="70px" size="small">
+        <el-form-item label="骞翠唤">
+          <el-date-picker v-model="planYear" type="year" value-format="YYYY" clearable format="YYYY"
+            placeholder="閫夋嫨骞�" style="width: 100%">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="瀹℃牳浜�">
+          <el-select v-model="examineUserId" clearable filterable style="width: 100%">
+            <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 8px 12px; border-radius: 4px; background: var(--el-color-primary-light-9); font-size: 13px;">
+        <span>绗竴娆″鍏ヨ鍏堜笅杞芥ā鏉匡紝鎸夋ā鏉挎牸寮忓~鍐欏悗鍐嶄笂浼犮��</span>
+        <el-button link type="primary" @click="downloadTemplate">涓嬭浇瀵煎叆妯℃澘</el-button>
       </div>
       <div style="margin: 0 auto;">
-        <el-upload ref="upload" :action="action" :auto-upload="false" :file-list="fileList" :headers="uploadHeader"
-          :limit="1" accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
+        <el-upload ref="upload" :action="action" :auto-upload="false" v-model:file-list="fileList" :headers="uploadHeader"
+          :limit="1" accept=".xls,.xlsx"
           :on-change="beforeUpload" :on-error="onError" :on-success="handleSuccessUp" drag
-          :data="{ planYear: planYear, examineUserId: examineUserId }" name="file">
+          :data="{ monitorYear: planYear, examineUserId: examineUserId }" name="file">
           <lims-icon name="el-icon-upload"></lims-icon>
           <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
         </el-upload>
+      </div>
+      <div style="margin-top: 10px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 20px;">
+        <div>鏀寔鏍煎紡锛�.xls銆�.xlsx锛涘崟涓枃浠朵笉瓒呰繃10MB銆�</div>
+        <div>璐ㄦ帶椤圭洰銆佹妧鏈爣鍑嗐�佽川鎺ф柟寮忋�佸畬鎴愭椂闄愩�佽礋璐d汉涓哄繀濉」銆�</div>
+        <div>瀹屾垚鏃堕檺鏍煎紡蹇呴』涓� YYYY-MM锛堟ā鏉夸腑璇ュ垪涓烘枃鏈牸寮忥紝鐩存帴杈撳叆 2026-12 鍗冲彲锛夛紱璐熻矗浜哄繀椤诲~鍐欑郴缁熶腑宸插瓨鍦ㄧ殑浜哄憳濮撳悕銆�</div>
+        <div>瀵煎叆鍚庤鍒掍繚瀛樹负鑽夌銆傝鍦ㄨ鍒掕鎯呬腑缂栬緫璐ㄦ帶椤圭洰骞堕�夋嫨浜嬮」绫诲埆锛涙娴嬬被杩橀渶閫夋嫨妫�娴嬫爣鍑嗐�佸師濮嬭褰曟ā鏉裤�佹娴嬪憳銆佽瘎浠蜂汉骞跺~鍐欎换鍔℃埅姝㈡棩锛岀‘璁ゅ悗鍐嶆彁浜ゅ鏍搞��</div>
+        <div>瀵煎叆鍙鍙栨ā鏉跨殑绗竴涓伐浣滆〃銆�</div>
       </div>
       <template #footer><span  class="dialog-footer">
         <el-button @click="uploadDia = false">鍙� 娑�</el-button>
@@ -247,7 +260,7 @@
       </div>
       <div style="margin: 0 auto;">
         <el-upload ref="upload1" :action="action1" :auto-upload="false"
-          :data="{ qualityMonitorDetailsId: qualityMonitorDetailsId }" :file-list="fileList1" :headers="uploadHeader"
+          :data="{ qualityMonitorDetailsId: qualityMonitorDetailsId }" v-model:file-list="fileList1" :headers="uploadHeader"
           :limit="1" :on-change="beforeUpload1" :on-error="onError1" :on-success="onSuccess1" accept='.doc,.docx,application/pdf,' drag
           name="file">
           <lims-icon name="el-icon-upload"></lims-icon>
@@ -397,8 +410,7 @@
         }, {
           label: '鐩戞帶浠诲姟缂栧彿', prop: 'inspectionTaskCode', minWidth: '150px'
         }, {
-          label: '浠诲姟鐘舵��', prop: 'inspectionTaskState', width: '100px',
-          formatData: value => this.inspectionTaskStatus(value)
+          label: '浠诲姟鐘舵��', prop: 'taskStatusText', width: '110px'
         },{
           dataType: 'tag',
           label: '璇勪环鐘舵��',
@@ -575,10 +587,26 @@
     leadInto() {
       this.uploadDia = true
       this.planYear = this.selectedYear
+      this.fileList = []
       this.getUserList()
+    },
+    // 涓嬭浇瀵煎叆妯℃澘
+    downloadTemplate() {
+      const link = document.createElement('a')
+      // 甯︾増鏈弬鏁伴伩鍏嶆祻瑙堝櫒缁х画浣跨敤缂撳瓨閲岀殑鏃фā鏉�
+      link.href = '/import-templates/璐ㄩ噺鐩戞帶璁″垝瀵煎叆妯℃澘.xlsx?v=2'
+      link.download = '璐ㄩ噺鐩戞帶璁″垝瀵煎叆妯℃澘.xlsx'
+      document.body.appendChild(link)
+      link.click()
+      document.body.removeChild(link)
     },
     // 瀵煎叆娴佺▼
     beforeUpload(file) {
+      if (!/\.(xls|xlsx)$/i.test(file.name || '')) {
+        this.$message.error('璇烽�夋嫨 .xls 鎴� .xlsx 鏍煎紡鐨勬枃浠�');
+        this.$refs.upload.clearFiles()
+        return false;
+      }
       if (file.size > 1024 * 1024 * 10) {
         this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
         this.$refs.upload.clearFiles()
@@ -588,23 +616,40 @@
       }
     },
     onError(err, file, fileList) {
-      this.$message.error('涓婁紶澶辫触')
-      this.$refs.upload.clearFiles()
+      this.uploading = false
+      this.fileList = []
+      this.$message.error('涓婁紶澶辫触锛岃閲嶆柊閫夋嫨鏂囦欢')
     },
     handleSuccessUp(response) {
       this.uploading = false;
       if (response.code == 200) {
-        this.$message.success('涓婁紶鎴愬姛');
+        this.$message.success('瀵煎叆鎴愬姛锛岃鍒掑凡淇濆瓨涓鸿崏绋匡紝璇疯ˉ鍏ㄨ川鎺ч」鐩悗鎻愪氦瀹℃牳');
+        const importedPlan = response.data || null
         this.timer = setTimeout(() => {
           this.uploadDia = false
           this.fileList = []
-          this.planYear = this.selectedYear
           this.examineUserId = ''
-          this.getYearPlanList()
+          // 瀵煎叆瀹屾垚鍚庣洿鎺ヨ繘鍏ヨ鍒掕鎯咃紝鏂逛究缁х画缂栬緫璐ㄦ帶椤圭洰銆侀�夋嫨妫�娴嬫爣鍑嗙瓑
+          if (importedPlan && importedPlan.qualityMonitorId) {
+            this.openPlan(importedPlan)
+          } else {
+            this.getYearPlanList()
+          }
         }, 1000)
       } else {
-        this.$message.error(response.msg)
+        this.$message.error(response.msg || '涓婁紶澶辫触')
+        // 鍚庣杩斿洖涓氬姟閿欒鏃� HTTP 鐘舵�佷粛鏄� 200锛宔l-upload 浼氭妸鏂囦欢鏍囪涓� success锛�
+        // 鐩存帴鍐嶆璋冪敤 submit() 涓嶄細閲嶆柊涓婁紶锛岃繖閲屾妸鏂囦欢鎭㈠涓哄緟涓婁紶鐘舵�併��
+        this.resetUploadFiles()
       }
+    },
+    resetUploadFiles() {
+      const files = this.$refs.upload?.uploadFiles || this.fileList || []
+      files.forEach(file => {
+        file.status = 'ready'
+        file.response = undefined
+        file.percentage = 0
+      })
     },
     submitUpload() {
       if (!this.planYear) {
@@ -615,6 +660,12 @@
         this.$message.warning('璇烽�夋嫨瀹℃牳浜�')
         return;
       }
+      const files = this.$refs.upload?.uploadFiles || this.fileList || []
+      if (!files.length) {
+        this.$message.warning('璇烽�夋嫨瑕佸鍏ョ殑鏂囦欢')
+        return;
+      }
+      this.uploading = true
       this.$refs.upload.submit();
     },
     // end
@@ -738,7 +789,10 @@
       this.yearDetailLoading = true
       pageQualityMonitorDetail({ ...entity, ...page }).then(res => {
         this.yearDetailLoading = false
-        this.yearDetailTableData = res.data.records
+        this.yearDetailTableData = res.data.records.map(item => ({
+          ...item,
+          taskStatusText: this.inspectionTaskStatus(item)
+        }))
         this.yearDetailPage.total = res.data.total
         this.$nextTick(() => this.$refs.yearDetailTableData?.$refs?.multipleTable?.doLayout())
       }).catch(err => {
@@ -791,6 +845,7 @@
         }
         this.lookDialogVisible = true
       } else {
+        this.fileList1 = []
         this.uploadDia1 = true
       }
     },
@@ -820,7 +875,7 @@
       this.uploading1 = false
     },
     submitUpload1() {
-      if (this.$refs.upload1.uploadFiles.length === 0) {
+      if (!this.fileList1 || this.fileList1.length === 0) {
         this.$message.error('鏈�夋嫨鏂囦欢')
         return
       }
@@ -991,9 +1046,14 @@
       if (command === 'export') this.handleDown(row)
       if (command === 'delete') this.delPlan(row)
     },
-    inspectionTaskStatus(value) {
+    inspectionTaskStatus(row) {
+      if (row.itemKind !== 'INSPECTION') return '鏃犻渶涓嬪彂'
+      const value = row.inspectionTaskState
+      if (value === null || value === undefined) {
+        return Number(row.planRatifyStatus) === 1 ? '鏈笅鍙�' : '寰呰鍒掓壒鍑�'
+      }
       const map = { 0: '寰呮娴�', 1: '妫�娴嬩腑', 2: '妫�娴嬩腑', 3: '寰呭鏍�', 4: '澶嶆牳閫�鍥�', 5: '寰呰瘎浠�' }
-      return value === null || value === undefined ? '鏈笅鍙�' : (map[value] || '澶勭悊涓�')
+      return map[value] || '澶勭悊涓�'
     },
     handleDetailCommand(command, row) {
       const handlers = {

--
Gitblit v1.9.3