From d2b9ce5ceb7059dfa06e9281661c8c9516686dd0 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 06 十月 2025 19:54:22 +0800
Subject: [PATCH] bug修改

---
 cloud-server-management/src/main/webapp/WEB-INF/view/system/tShop/TShop_edit.html |   42 ++++++++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tShop/TShop_edit.html b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tShop/TShop_edit.html
index d179f30..cd6ef91 100644
--- a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tShop/TShop_edit.html
+++ b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tShop/TShop_edit.html
@@ -125,7 +125,8 @@
                                     accept="."
                                     :file-list="imageUrl2"
                                     :on-success="handleAvatarSuccess"
-                                    :on-remove="handleRemove">
+                                    :on-remove="handleRemove"
+                                    :before-upload="beforeAvatarUpload">
                                 <i class="el-icon-plus"></i>
                             </el-upload>
                             <el-dialog :visible.sync="dialogVisible">
@@ -211,10 +212,14 @@
         },
         methods: {
             handleAvatarSuccess(res, file) {
-                file.url =file.response
+                // 确保文件对象有完整的结构
+                if (file && file.response) {
+                    file.url = file.response;
+                }
                 TCarInfoDlg.goodsPicArray.push(res);
-                console.log(TCarInfoDlg.goodsPicArray)
+                console.log(TCarInfoDlg.goodsPicArray);
             },
+            // 添加 beforeUpload 钩子到 el-upload 组件
             beforeAvatarUpload(file) {
                 const isLt2M = file.size / 1024 / 1024 < 10;
                 if (!isLt2M) {
@@ -222,23 +227,32 @@
                 }
                 return isLt2M;
             },
+            // 修改 handleRemove 方法
             handleRemove(file, fileList) {
+                // 使用更安全的方式过滤
                 TCarInfoDlg.goodsPicArray = TCarInfoDlg.goodsPicArray.filter(item => {
-                    return item.uid != file.uid;
+                    // 如果是文件对象,比较 uid;如果是字符串,比较值
+                    if (typeof item === 'object' && item !== null) {
+                        return item.uid !== file.uid;
+                    } else {
+                        return item !== file.url;
+                    }
                 });
             },
             changeImg(){
-                var i = id.split(",")
-                for (let j = 0; j <i.length; j++) {
-                    let obj={
-                        fileName:i[j],
-                        uuid:i[j],
-                        url:i[j],
-                        response:i[j],
-                    }
-                    this.imageUrl2.push(obj)
+                if (!id) return; // 如果没有图片数据则返回
+
+                var i = id.split(",").filter(url => url.trim() !== ''); // 过滤空字符串
+                for (let j = 0; j < i.length; j++) {
+                    let obj = {
+                        uid: 'existing-' + j + '-' + Date.now(), // 确保 uid 是唯一的字符串
+                        name: 'image-' + j + '.jpg', // 添加 name 属性
+                        url: i[j],
+                        status: 'success' // 标记为已上传状态
+                    };
+                    this.imageUrl2.push(obj);
                 }
-                console.log( this.imageUrl2,111)
+                console.log(this.imageUrl2, 111);
             },
         },
         created() {

--
Gitblit v1.7.1