فهرست منبع

update 优化 上传组件 部分用户存储url串 导致无法回显问题

疯狂的狮子Li 2 سال پیش
والد
کامیت
99dfd42372
2فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 6 1
      ruoyi-ui/src/components/FileUpload/index.vue
  2. 7 2
      ruoyi-ui/src/components/ImageUpload/index.vue

+ 6 - 1
ruoyi-ui/src/components/FileUpload/index.vue

@@ -90,7 +90,12 @@ export default {
           const list = Array.isArray(val) ? val : this.value.split(',');
           // 然后将数组转为对象数组
           this.fileList = list.map(item => {
-            item = { name: item.name, url: item.url, ossId: item.ossId };
+            // 字符串回显处理 如果此处存的是url可直接回显 如果存的是id需要调用接口查出来
+            if (typeof item === "string") {
+              item = { name: item, url: item };
+            } else {
+              item = { name: item.name, url: item.url, ossId: item.ossId };
+            }
             item.uid = item.uid || new Date().getTime() + temp++;
             return item;
           });

+ 7 - 2
ruoyi-ui/src/components/ImageUpload/index.vue

@@ -93,8 +93,13 @@ export default {
           const list = Array.isArray(val) ? val : this.value.split(',');
           // 然后将数组转为对象数组
           this.fileList = list.map(item => {
-            // 此处name使用ossId 防止删除出现重名
-            item = { name: item.ossId, url: item.url, ossId: item.ossId };
+            // 字符串回显处理 如果此处存的是url可直接回显 如果存的是id需要调用接口查出来
+            if (typeof item === "string") {
+              item = { name: item, url: item };
+            } else {
+              // 此处name使用ossId 防止删除出现重名
+              item = { name: item.ossId, url: item.url, ossId: item.ossId };
+            }
             return item;
           });
         } else {