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/borrow.vue |   78 ++++++++++++++++++++++++++++-----------
 1 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/borrow.vue b/src/views/CNAS/resourceDemand/device/component/borrow.vue
index acca1c6..326c12e 100644
--- a/src/views/CNAS/resourceDemand/device/component/borrow.vue
+++ b/src/views/CNAS/resourceDemand/device/component/borrow.vue
@@ -26,7 +26,7 @@
         <el-step style="cursor:pointer" v-for="(v, i) in steps" :title="v" :key="i"
           @click="choiceStep(i)"></el-step>
       </el-steps>
-      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
+      <el-form ref="form" :model="form" :rules="rules" label-width="130px" :disabled="!canOperate">
         <div v-show="currentStepClick === 0">
           <el-card style="margin-top: 1em; height: 51vh; overflow-y: scroll;">
             <!-- 鏂板璁惧浜嬭褰曞崱鐗� -->
@@ -57,7 +57,7 @@
               </el-col>
               <el-col :span="12">
                 <el-form-item label="鍊熺敤浜鸿仈绯绘柟寮忥細" prop="borrowerContactInformation" label-width="150px">
-                  <el-input v-model="form.borrowerContactInformation" size="small"></el-input>
+                  <el-input v-model="form.borrowerContactInformation" size="small" :disabled="currentStep > 0"></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
@@ -81,13 +81,13 @@
                 <el-form-item label="鐩稿叧闄勪欢锛�" prop="fileName">
                   <el-input v-model="form.fileName" disabled size="small"
                     :style="`width: ${currentStep == 0 ? '88%' : '100%'};`">
-                    <template #append><el-button  v-if="currentStep === 0" :icon="$icon('el-icon-delete-solid')"
+                    <template #append><el-button  v-if="currentStep === 0 && canOperate" :icon="$icon('el-icon-delete-solid')"
                       @click="deleteFile"></el-button></template>
                   </el-input>
                   <el-upload ref="upload" style="float: right;" :action="action" :show-file-list="false"
-                    :on-success="onSuccess" :disabled="currentStep !== 0" :headers="uploadHeader">
+                    :on-success="onSuccess" :disabled="currentStep !== 0 || !canOperate" :headers="uploadHeader">
                     <template #trigger><el-button style="position: relative;top: -4px" class="uploadFile"  size="small"
-                      type="primary" v-if="currentStep === 0">闄勪欢涓婁紶</el-button></template>
+                      type="primary" v-if="currentStep === 0 && canOperate">闄勪欢涓婁紶</el-button></template>
                   </el-upload>
                 </el-form-item>
               </el-col>
@@ -170,9 +170,9 @@
         </div>
       </el-form>
       <template #footer><span  class="dialog-footer">
-        <el-button @click="submitForm('3reject')" v-if="currentStep !== 0 && currentStep !== 2">椹冲洖</el-button>
-        <el-button @click="submitForm('2save')" v-if="currentStep === 0">淇濆瓨</el-button>
-        <el-button type="primary" v-if="currentStep !== 2" @click="submitForm('1submit')">{{ currentStep === 0 ? '鎻愪氦' :
+        <el-button :loading="submitLoading" @click="submitForm('3reject')" v-if="currentStep !== 0 && currentStep !== 2 && canOperate">椹冲洖</el-button>
+        <el-button :loading="submitLoading" @click="submitForm('2save')" v-if="currentStep === 0 && canOperate">淇濆瓨</el-button>
+        <el-button :loading="submitLoading" type="primary" v-if="currentStep !== 2 && canOperate" @click="submitForm('1submit')">{{ currentStep === 0 ? '鎻愪氦' :
           '閫氳繃'
           }}</el-button>
       </span></template>
@@ -183,7 +183,7 @@
         </el-table-column>
         <el-table-column prop="operator" label="鎿嶄綔浜�" width="180">
         </el-table-column>
-        <el-table-column prop="operationTime" label="鎿嶄綔鏃ユ湡" width="180">
+        <el-table-column prop="operationTime" label="鎿嶄綔鏃ユ湡" width="180" :formatter="formatDateCell">
         </el-table-column>
         <el-table-column prop="operationType" label="鎻愪氦绫诲瀷">
         </el-table-column>
@@ -207,6 +207,8 @@
 } from '@/api/cnas/resourceDemand/device.js'
 import { selectUserCondition } from "@/api/business/inspectionTask";
 import { mapGetters } from "@/utils/store-compat";
+import { formatListDate } from './dateFormat'
+import { saveBlobOrShowError } from '@/utils/saveBlob'
 export default {
   props: {
     clickNodeVal: {
@@ -223,9 +225,10 @@
     return {
       dialogVisible: false,
       dialogVisible0: false,
+      canOperate: true,
       currentStep: 0, // 姝ラ鏉℃樉绀虹鍑犳
       currentStepClick: 0, // 鐐瑰嚮姝ラ鏉″彉鍖�
-      steps: ['鍊熷嚭', '鍊熺敤'],
+      steps: ['鍊熷嚭', '褰掕繕'],
       responsibleOptions: [], // 涓嬬幆鑺傝礋璐d汉list
       form: {
         processNumber: null,
@@ -251,6 +254,7 @@
       },
       deviceLogs: [],
       outLoading: false,
+      submitLoading: false,
       recipientStateList: [{
         value: 0,
         type: 'success',
@@ -279,18 +283,20 @@
         },
         { label: "鍊熺敤浜�", prop: "recipientUser" },
         { label: "鍊熺敤浜鸿仈绯绘柟寮�", prop: "borrowerContactInformation", width: '140px' },
-        { label: "鍊熺敤鏃ユ湡", prop: "recipientTime" },
+        { label: "鍊熺敤鏃ユ湡", prop: "recipientTime", formatData: (params) => formatListDate(params) },
         {
           label: "鍊熺敤鏃剁姸鎬�", prop: "recipientState", dataType: "tag",
           formatData: (params) => {
-            return this.recipientStateList.find((m) => m.value == params).label;
+            const item = this.recipientStateList.find((m) => m.value == params)
+            return item ? item.label : '-'
           },
           formatType: (params) => {
-            return this.recipientStateList.find((m) => m.value == params).type;
+            const item = this.recipientStateList.find((m) => m.value == params)
+            return item ? item.type : 'info'
           },
         },
         { label: "鍊熷嚭浜�", prop: "submitUser" },
-        { label: "鍊熷嚭鏃ユ湡", prop: "createTime" },
+        { label: "鍊熷嚭鏃ユ湡", prop: "createTime", formatData: (params) => formatListDate(params) },
         {
           label: "褰撳墠鐘舵��", prop: "nowState"
         },
@@ -328,7 +334,7 @@
       page: {
         total: 0,
         size: 10,
-        current: 0,
+        current: 1,
       },
       tableLoading: false,
     }
@@ -337,7 +343,7 @@
     // 鐩戝惉鐐瑰嚮el-tree鐨勬暟鎹紝杩涜鏁版嵁鍒锋柊
     clickNodeVal(newVal) {
       if (newVal.value) {
-        thisqueryParams.deviceId = this.clickNodeVal.value
+        this.queryParams.deviceId = this.clickNodeVal.value
         this.refreshTable()
       }
     },
@@ -362,6 +368,9 @@
     this.refreshTable()
   },
   methods: {
+    formatDateCell(row, column, cellValue) {
+      return formatListDate(cellValue)
+    },
     getList() {
       this.tableLoading = true;
       let param = { ...this.queryParams, ...this.page };
@@ -384,7 +393,7 @@
       this.getList();
     },
     refresh() {
-      this.queryParams = {};
+      this.queryParams = { deviceId: this.clickNodeVal.value };
       this.page.current = 1;
       this.getList();
     },
@@ -445,12 +454,16 @@
           this.form.nowState = currentStepAction === 2 ? '鍏抽棴' : this.steps[currentStepAction]
           this.form.deviceId = this.clickNodeVal.value
           delete this.form.deviceLogs
+          this.submitLoading = true
           saveDeviceBorrow(this.form).then(res => {
             if (res.code == 200) {
               this.$message.success('鎻愪氦鎴愬姛')
               this.dialogVisible = false
               this.refreshTable()
             }
+            this.submitLoading = false
+          }).catch(err => {
+            this.submitLoading = false
           })
         } else {
           let step = this.steps[this.currentStep]
@@ -467,6 +480,8 @@
         deleteCNASFile({ fileName: this.form.fileName }).then(res => {
           if (res.code == 200) {
             this.$message.success('鍒犻櫎鎴愬姛锛�')
+            this.form.fileName = null
+            this.form.url = null
           }
         })
       }).catch(() => {
@@ -510,12 +525,31 @@
             this.currentStepClick = i
           }
           console.log(this.currentStepClick)
+          this.applyPermission()
           this.dialogVisible = true
         }
       })
     },
+    // 闈炲綋鍓嶇幆鑺傝矗浠讳汉鍙厑璁告煡鐪�
+    applyPermission() {
+      if (this.form.nowState === '鍏抽棴') {
+        this.canOperate = false
+        return
+      }
+      let responsible = null
+      if (this.form.nowState === '褰掕繕') {
+        responsible = this.form.nowUser
+      } else if (this.form.nowState === '鍊熷嚭') {
+        responsible = this.form.submitOperationUser
+      }
+      this.canOperate = !responsible || responsible === this.nickName
+      if (!this.canOperate) {
+        this.$message.warning('褰撳墠鐜妭璐d换浜轰负锛�' + responsible + '锛屾偍鍙兘鏌ョ湅')
+      }
+    },
     // 鏂板
     add() {
+      this.canOperate = true
       this.dialogVisible = true
       this.form = {
         processNumber: null,
@@ -523,10 +557,11 @@
         unifyNumber: null,
         recipientUser: null,
         recipientTime: null,
+        recipientState: 0,
         nextUser: null,
         rebackUser: null,
         rebackTime: null,
-        receiveState: null,
+        receiveState: 0,
         deviceUser: null,
         fileName: null,
       }
@@ -538,11 +573,10 @@
       this.outLoading = true
       deviceBorrowExport({ deviceId: this.clickNodeVal.value }).then(res => {
         this.outLoading = false
-        const blob = new Blob([res], {
-          type: 'application/force-download'
-        })
         const filename = decodeURI(this.clickNodeVal.label + '璁惧鍊熷嚭缁熻' + '.xlsx')
-        this.$download.saveAs(blob, filename)
+        saveBlobOrShowError(res, filename, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
+      }).catch(() => {
+        this.outLoading = false
       })
     },
     handleLookList(row) {

--
Gitblit v1.9.3