From 0108bdd2a028858d988dcc7d7d2cff75db10cfbf Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 23 十月 2026 09:11:54 +0800
Subject: [PATCH] fix(download): 修复文件下载路径拼接问题

---
 src/views/CNAS/resourceDemand/device/component/operationInstruction.vue |  109 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 57 insertions(+), 52 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/operationInstruction.vue b/src/views/CNAS/resourceDemand/device/component/operationInstruction.vue
index 31b74e7..fbf1483 100644
--- a/src/views/CNAS/resourceDemand/device/component/operationInstruction.vue
+++ b/src/views/CNAS/resourceDemand/device/component/operationInstruction.vue
@@ -3,7 +3,7 @@
   <div>
     <div style="margin: 10px 0;text-align: right">
       <el-button size="small" type="primary" @click="getList">鍒锋柊</el-button>
-      <el-button size="small" type="primary" @click="openInstructionDia">鍙楁帶鐢宠</el-button>
+      <el-button size="small" type="primary" @click="dialogVisible = true">鍙楁帶鐢宠</el-button>
     </div>
     <el-table :data="tableData" border height="calc(100vh - 18em)"
 >
@@ -17,11 +17,12 @@
       <el-table-column label="璁惧缂栧彿" min-width="150" prop="deviceNumber"></el-table-column>
       <el-table-column label="璁惧鍨嬪彿" min-width="150" prop="deviceModel"></el-table-column>
       <el-table-column label="鏂囦欢缂栧彿" min-width="150" prop="documentNumber"></el-table-column>
-      <el-table-column label="鏂囦欢鍚嶅瓧" min-width="150" prop="fileName"></el-table-column>
+      <el-table-column label="鏂囦欢鍚嶇О" min-width="150" prop="fileName"></el-table-column>
       <el-table-column label="鏂囨。璇存槑" min-width="150" prop="documentNote"></el-table-column>
       <el-table-column label="涓婁紶浜�" min-width="150" prop="uploaderName"></el-table-column>
-      <el-table-column label="涓婁紶鏃堕棿" min-width="150" prop="updateTime"></el-table-column>
-      <el-table-column label="鐢熸晥鏃堕棿" min-width="150" prop="entryIntoForceTime"></el-table-column>
+      <el-table-column label="涓婁紶鏃堕棿" min-width="150" prop="updateTime" :formatter="formatDateCell"></el-table-column>
+      <el-table-column label="鐢熸晥鏃堕棿" min-width="150" prop="entryIntoForceTime"
+        :formatter="formatDateCell"></el-table-column>
       <el-table-column label="瀹℃壒浜�" min-width="150" prop="approverName"></el-table-column>
       <el-table-column label="瀹℃壒鐘舵��" min-width="150" prop="status">
         <template v-slot="scope">
@@ -31,14 +32,16 @@
       <el-table-column label="鎿嶄綔" min-width="180" fixed="right" prop="name">
         <template v-slot="scope">
           <el-button link type="primary" size="small" @click="downloadFile(scope.row.fileSystemName)">涓嬭浇</el-button>
-          <el-button link type="primary" size="small" style="color: red;"
+          <el-button link type="primary" size="small" style="color: red;" :disabled="scope.row.status === true"
             @click="deleteHomeworkGuidebook(scope.row)">鍒犻櫎</el-button>
-          <el-button link type="primary" size="small" @click="instructionEditFun(scope.row)">缂栬緫</el-button>
-          <el-button link type="primary" size="small" @click="approval(scope.row)">瀹℃壒</el-button>
+          <el-button link type="primary" size="small" :disabled="scope.row.status === true"
+            @click="instructionEditFun(scope.row)">缂栬緫</el-button>
+          <el-button link type="primary" size="small" :disabled="scope.row.status === true"
+            @click="approval(scope.row)">瀹℃壒</el-button>
         </template>
       </el-table-column>
     </el-table>
-    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="1"
+    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="search.current"
       :page-sizes="[10, 20, 30, 50, 100]" :page-size="search.size" layout="->,total, sizes, prev, pager, next, jumper"
       :total="search.total" background>
     </el-pagination>
@@ -82,7 +85,7 @@
         <el-table :data="documentTableData" border style="width: 100%;" tooltip-effect="dark" :row-key="getRowKey"
 
           @selection-change="handleSelectionChange" height="29em">
-          <el-table-column type="selection" width="55%">
+          <el-table-column type="selection" width="55">
           </el-table-column>
           <el-table-column label="搴忓彿" prop="id" type="index" width="60"></el-table-column>
           <el-table-column label="璁惧鍚嶇О" prop="deviceName" show-overflow-tooltip min-width="125"></el-table-column>
@@ -91,7 +94,8 @@
           <el-table-column label="鏂囨。缂栧彿" prop="documentNumber" show-overflow-tooltip min-width="125"></el-table-column>
           <el-table-column label="鏂囦欢鍚嶇О" prop="fileName" show-overflow-tooltip min-width="125"></el-table-column>
           <el-table-column label="涓婁紶浜�" prop="author" show-overflow-tooltip min-width="125"></el-table-column>
-          <el-table-column label="涓婁紶鏃堕棿" prop="updateTime" show-overflow-tooltip min-width="125"></el-table-column>
+          <el-table-column label="涓婁紶鏃堕棿" prop="updateTime" show-overflow-tooltip min-width="125"
+            :formatter="formatDateCell"></el-table-column>
           <el-table-column min-width="100" label="鎿嶄綔" fixed="right">
             <template v-slot="scope">
               <el-button link type="primary" size="small" @click="downloadFile(scope.row.fileSystemName)">涓嬭浇</el-button>
@@ -188,9 +192,8 @@
   pageByPageQueryOfHomeworkInstructions,
   selectDeviceParameter,
 } from '@/api/cnas/resourceDemand/device.js'
-import draftSave from '@/mixins/draftSave'
+import { formatListDate } from './dateFormat'
 export default {
-  mixins: [draftSave],
   props: {
     clickNodeVal: {
       type: Object,
@@ -261,8 +264,6 @@
     },
     dialogVisible(newVal) {
       if (newVal === false) {
-        this.draftStop('instructionForm')
-        this.draftStop('instructionRows')
         this.instructionForm = {}
         this.documentTableData = []
         this.fileList1 = []
@@ -270,6 +271,9 @@
     }
   },
   methods: {
+    formatDateCell(row, column, cellValue) {
+      return formatListDate(cellValue)
+    },
     approval(row) {
       this.$confirm('鏄惁瀹℃壒閫氳繃锛�', '鎻愮ず', {
         confirmButtonText: '閫氳繃',
@@ -277,8 +281,11 @@
         type: 'warning'
       }).then(() => {
         this.approvalFun(row.id, true)
-      }).catch(() => {
-        this.approvalFun(row.id, false)
+      }).catch((action) => {
+        // 鍙湁鐐瑰嚮鈥滀笉閫氳繃鈥濇墠鎻愪氦椹冲洖锛岀偣鍙充笂瑙掑叧闂�/Esc 瑙嗕负鏀惧純鎿嶄綔
+        if (action === 'cancel') {
+          this.approvalFun(row.id, false)
+        }
       });
     },
     approvalFun(id, status) {
@@ -333,25 +340,15 @@
       homeworkGuidebookEditor({ instructionId: row.instructionId }).then(res => {
         if (res.code == 200) {
           this.instructionForm = res.data.instruction;
-          if (this.instructionForm.fileSystemName) {
-            this.fileList1.push({ name: this.instructionForm.fileName })
-          }
+          this.fileList1 = this.instructionForm.fileSystemName
+            ? [{ name: this.instructionForm.fileName }]
+            : []
           this.documentTableData = res.data.list;
           // 鍒犻櫎鐢�
           this.documentTableData.forEach((v, k) => {
             v.index = k
           })
-          this.draftRestore('instructionForm', 'instructionForm', row.instructionId, 'dialogVisible')
-          this.draftRestore('instructionRows', 'documentTableData', row.instructionId, 'dialogVisible')
         }
-      })
-    },
-    // 鎵撳紑鍙楁帶鐢宠寮圭獥锛堟柊澧烇級
-    openInstructionDia() {
-      this.dialogVisible = true
-      this.$nextTick(() => {
-        this.draftRestore('instructionForm', 'instructionForm', '', 'dialogVisible')
-        this.draftRestore('instructionRows', 'documentTableData', '', 'dialogVisible')
       })
     },
     handleSizeChange(val) {
@@ -369,8 +366,6 @@
           newHomeworkGuidebookAdded(this.instructionForm).then(res => {
             if (res.code == 200) {
               this.$message.success('鎿嶄綔鎴愬姛锛�')
-              this.draftClear('instructionForm')
-              this.draftClear('instructionRows')
               this.dialogVisible = false
               this.getList()
             }
@@ -412,13 +407,13 @@
     addFile() {
       this.$refs.form.validate((valid) => {
         if (valid) {
-          this.draftClear('instructionRowForm')
           if (this.tableDataIndex !== undefined) {
             this.documentTableData[this.tableDataIndex] = this.form
             this.dialogVisible1 = false;
             this.$message.success('淇敼鎴愬姛');
             console.log('this.documentTableData---edit', this.documentTableData[this.tableDataIndex])
           } else {
+            this.form.index = this.getNextRowIndex();
             this.documentTableData.push(this.form);
             this.dialogVisible1 = false;
             this.$message.success('娣诲姞鎴愬姛');
@@ -435,21 +430,24 @@
       this.form.deviceName = this.clickNodeVal.label
       this.onDeviceNameChange()
       this.fileList = []
-      this.draftRestore('instructionRowForm', 'form', '', 'dialogVisible1')
+
     },
     editFun(row, index) {
       this.form = { ...row }
       this.tableDataIndex = index;
-      console.log('this.tableDataIndex', this.tableDataIndex)
-      // 鍥炴樉鍒楄〃
+      // 鍥炴樉鍒楄〃鍓嶅厛娓呯┖锛岄伩鍏嶉噸澶嶆樉绀轰笂涓�娆$殑闄勪欢
+      this.fileList = []
       if (this.form.fileSystemName) {
         this.fileList.push({ name: this.form.fileName })
       }
       this.dialogVisible1 = true
-      this.draftRestore('instructionRowForm', 'form', row.id !== undefined ? row.id : ('row' + index), 'dialogVisible1')
+    },
+    getNextRowIndex() {
+      return this.documentTableData.reduce((max, item) => {
+        return typeof item.index === 'number' && item.index > max ? item.index : max
+      }, -1) + 1
     },
     closeDia() {
-      this.draftStop('instructionRowForm')
       this.dialogVisible1 = false
       this.$refs['form'].resetFields()
       this.fileList = []
@@ -462,22 +460,24 @@
         this.$message.error('璇烽�夋嫨瑕佸垹闄ょ殑閫夐」');
         return;
       }
-      // 鍒犻櫎淇濆瓨濂界殑鏁版嵁
-      let ids = this.selectedRow
+      const selectedIndexes = this.selectedRow.map(item => item.index);
+      // 鍒犻櫎宸蹭繚瀛樼殑鏁版嵁锛涙湰娆℃柊鍔犮�佸皻鏈惤搴撶殑琛屾病鏈� id锛屼笉璋冩帴鍙�
+      const ids = this.selectedRow
         .filter(item => item.id !== undefined)
         .map(item => item.id).join(',');
-      //鏈夐敊璇�
-      const res = await deleteHomeworkGuidebook({ ids });
-      if (res.code === 200) {
-        // 鍒犻櫎瑙嗗浘鐨勬暟鎹�
-        for (const resKey in this.selectedRow) {
-          this.documentTableData = this.documentTableData.filter(item => item.index === this.selectedRow[resKey].index)
+      if (ids) {
+        const res = await deleteHomeworkGuidebook({ ids });
+        if (res.code !== 200) {
+          return;
         }
-        this.$message.success({
-          message: '鍒犻櫎鎴愬姛',
-          type: 'success'
-        });
       }
+      // 涓�娆℃�ц繃婊ゆ帀鎵�鏈夐�変腑琛岋紝淇濈暀鍏朵綑鏁版嵁
+      this.documentTableData = this.documentTableData.filter(item => !selectedIndexes.includes(item.index))
+      this.selectedRow = []
+      this.$message.success({
+        message: '鍒犻櫎鎴愬姛',
+        type: 'success'
+      });
     },
     onSuccess(response, file, fileList) {
       this.form.fileName = file.name;
@@ -495,8 +495,8 @@
       this.form.fileSystemName = ''
     },
     handleRemove1(file, fileList) {
-      this.form.fileName = ''
-      this.form.fileSystemName = ''
+      this.instructionForm.fileName = ''
+      this.instructionForm.fileSystemName = ''
     },
     beforeRemove(file) {
       return this.$confirm(`纭畾绉婚櫎 ${file.name}锛焋)
@@ -505,7 +505,12 @@
       this.$message.warning(`褰撳墠闄愬埗閫夋嫨 1 涓枃浠讹紝鏈閫夋嫨浜� ${files.length} 涓枃浠躲�俙);
     },
     getList() {
-      pageByPageQueryOfHomeworkInstructions({ ...this.search }).then(res => {
+      const params = { ...this.search }
+      // 閫変腑鍏蜂綋璁惧鏃跺彧鏌ヨ璁惧鐨勪綔涓氭寚瀵间功
+      if (this.clickNodeVal && this.clickNodeVal.value) {
+        params.deviceId = this.clickNodeVal.value
+      }
+      pageByPageQueryOfHomeworkInstructions(params).then(res => {
         if (res.code == 200) {
           this.tableData = res.data.records;
           this.search.total = res.data.total

--
Gitblit v1.9.3