From 5c124cdf26e4d749eae1e7fc9df366e9a5f4d259 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期二, 18 八月 2026 15:04:09 +0800
Subject: [PATCH] 选择采购订单修改列表宽度设置

---
 src/components/upload/file-upload.vue |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/components/upload/file-upload.vue b/src/components/upload/file-upload.vue
index 35c7fe6..3692d2e 100644
--- a/src/components/upload/file-upload.vue
+++ b/src/components/upload/file-upload.vue
@@ -84,23 +84,29 @@
       } else {
         value.push(v);
       }
+      const existingMap = new Map<string | number, UploadFile>();
+      for (const f of fileList.value ?? []) {
+        const id = (f as any)?.response?.[props.valueKey] ?? (f as any)?.[props.valueKey] ?? f?.uid;
+        if (id != null) existingMap.set(id, f);
+      }
       fileList.value = value
         .map((item, i) => {
           if (item && isString(item)) {
-            return {
+            return existingMap.get(item) ?? {
               uid: `${-i}`,
               name: item.slice(Math.max(0, item.lastIndexOf('/') + 1)),
               status: UploadResultStatus.DONE,
               url: item,
             };
           } else if (item && isObject(item)) {
-            return item;
+            const key = item[props.valueKey] ?? item.uid;
+            return (key != null && existingMap.get(key)) || { ...item, url: String((item as any).url ?? '') };
           } else if (item && (typeof item === 'number' || typeof item === 'string')) {
-            return {
+            return existingMap.get(item) ?? {
               uid: `${-i}`,
               name: `鏂囦欢 ${String(item)}`,
               status: UploadResultStatus.DONE,
-              url: item,
+              url: String(item),
               response: { [props.valueKey]: item },
             } as UploadFile;
           }
@@ -135,6 +141,12 @@
 
 /** 澶勭悊鏂囦欢棰勮 */
 function handlePreview(file: UploadFile) {
+  const url = (file as any)?.url || (file as any)?.response?.url || (file as any)?.response;
+  if (!url) {
+    message.warning('鏂囦欢鍦板潃涓嶅瓨鍦紝鏃犳硶棰勮');
+    return;
+  }
+  window.open(url, '_blank');
   emit('preview', file);
 }
 
@@ -207,7 +219,7 @@
     fileList.value?.splice(index!, 1);
   }
 
-  const fileUrl = res?.url || res?.data || res;
+  const fileUrl = res?.url || res?.data || (typeof res === 'string' ? res : '');
   uploadList.value.push({
     name: res?.name || file.name,
     url: fileUrl,
@@ -280,14 +292,14 @@
       :progress="{ showInfo: true }"
       :show-upload-list="{
         showPreviewIcon: true,
-        showRemoveIcon: true,
+        showRemoveIcon: !disabled,
         showDownloadIcon,
       }"
       @remove="handleRemove"
       @preview="handlePreview"
       @reject="handleExceed"
     >
-      <div v-if="drag" class="upload-drag-area">
+      <div v-if="drag && !disabled" class="upload-drag-area">
         <p class="ant-upload-drag-icon">
           <IconifyIcon icon="lucide:cloud-upload" />
         </p>
@@ -296,7 +308,9 @@
           鏀寔{{ accept.join('/') }}鏍煎紡鏂囦欢锛屼笉瓒呰繃{{ maxSize }}MB
         </p>
       </div>
-      <div v-else-if="fileList && fileList.length < maxNumber">
+      <div
+        v-else-if="!disabled && fileList && fileList.length < maxNumber"
+      >
         <Button>
           <IconifyIcon icon="lucide:cloud-upload" />
           {{ $t('ui.upload.upload') }}

--
Gitblit v1.9.3