From 137bf2c0666b60cfc0d98b1a9ca7ead860ee4e7c Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 28 十月 2026 17:57:29 +0800
Subject: [PATCH] feat(device,supply,satisfaction): 设备计划改造、耗材采购调整与满意度照片上传

---
 src/components/Attachment/lims-attachment.vue |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/components/Attachment/lims-attachment.vue b/src/components/Attachment/lims-attachment.vue
index ae6a8b0..78fc148 100644
--- a/src/components/Attachment/lims-attachment.vue
+++ b/src/components/Attachment/lims-attachment.vue
@@ -5,7 +5,7 @@
         <div class="el-upload__tip">
           {{ readonly ? '浠呭彲棰勮銆佷笅杞介檮浠�' : ((currentId || deferUpload) ? tip : emptyTip) }}
         </div>
-        <el-upload v-if="!readonly" :action="uploadAction" :headers="uploadHeader" multiple
+        <el-upload v-if="!readonly" :action="uploadAction" :headers="uploadHeader" multiple :accept="accept"
           :show-file-list="false" :disabled="!canUpload" :auto-upload="!deferUpload"
           :on-change="handleFileChange" :on-success="handleUploadSuccess"
           :on-error="handleUploadError">
@@ -18,6 +18,7 @@
         <el-table-column label="鎿嶄綔" width="170">
           <template #default="scope">
             <template v-if="scope.row.pending">
+              <el-button link type="primary" @click="previewPending(scope.row)">棰勮</el-button>
               <el-button link type="danger" @click="removePending(scope.row)">鍒犻櫎</el-button>
             </template>
             <template v-else>
@@ -32,7 +33,7 @@
     <el-dialog v-else :title="dialogTitle" v-model="visible" width="760px" append-to-body @close="$emit('closed')">
       <div class="attachment-header">
         <div class="el-upload__tip">{{ readonly ? '浠呭彲棰勮銆佷笅杞介檮浠�' : tip }}</div>
-        <el-upload v-if="!readonly" :action="uploadAction" :headers="uploadHeader" multiple
+        <el-upload v-if="!readonly" :action="uploadAction" :headers="uploadHeader" multiple :accept="accept"
           :show-file-list="false" :on-success="handleUploadSuccess" :on-error="handleUploadError">
           <el-button size="small" type="primary">涓婁紶闄勪欢</el-button>
         </el-upload>
@@ -52,7 +53,7 @@
         <el-button @click="visible = false">鍏� 闂�</el-button>
       </template>
     </el-dialog>
-    <el-dialog title="棰勮闄勪欢" v-model="previewVisible" fullscreen append-to-body>
+    <el-dialog title="棰勮闄勪欢" v-model="previewVisible" fullscreen append-to-body @close="releasePreviewBlob">
       <file-preview v-if="previewVisible" :file-url="previewUrl" :current-file="previewRow" />
     </el-dialog>
   </div>
@@ -147,6 +148,11 @@
     deferUpload: {
       type: Boolean,
       default: false
+    },
+    // 鍏佽閫夋嫨鐨勬枃浠剁被鍨嬶紝濡� .jpg,.png锛涗负绌轰笉闄愬埗
+    accept: {
+      type: String,
+      default: ''
     }
   },
   watch: {
@@ -173,7 +179,8 @@
       currentRow: {},
       previewVisible: false,
       previewRow: {},
-      previewUrl: ''
+      previewUrl: '',
+      previewBlobUrl: ''
     }
   },
   computed: {
@@ -201,6 +208,9 @@
     uploadAction() {
       return this.javaApi + this.uploadUrl + '?' + this.idParam + '=' + this.currentId
     }
+  },
+  beforeUnmount() {
+    this.releasePreviewBlob()
   },
   methods: {
     // 鎵撳紑闄勪欢绠$悊寮圭獥
@@ -293,7 +303,26 @@
         this.loadList()
       })
     },
+    // 寰呬笂浼犳枃浠剁敤鏈湴涓存椂鍦板潃棰勮锛屾彁浜ゅ悗鍐嶈蛋姝e紡鍦板潃
+    previewPending(row) {
+      const item = this.pendingFiles.find(pending => pending.uid === row.uid)
+      if (!item) {
+        return
+      }
+      this.releasePreviewBlob()
+      this.previewBlobUrl = URL.createObjectURL(item.raw)
+      this.previewRow = { fileName: item.fileName, fileUrl: this.previewBlobUrl }
+      this.previewUrl = this.previewBlobUrl
+      this.previewVisible = true
+    },
+    releasePreviewBlob() {
+      if (this.previewBlobUrl) {
+        URL.revokeObjectURL(this.previewBlobUrl)
+        this.previewBlobUrl = ''
+      }
+    },
     previewFile(row) {
+      this.releasePreviewBlob()
       this.previewRow = row
       this.previewUrl = this.fullUrl(row.fileUrl)
       this.previewVisible = true

--
Gitblit v1.9.3