Browse Source

图片上传修改

web100 2 năm trước cách đây
mục cha
commit
ffce017ec2
1 tập tin đã thay đổi với 54 bổ sung16 xóa
  1. 54 16
      src/views/basicdata/dept/index.vue

+ 54 - 16
src/views/basicdata/dept/index.vue

@@ -684,6 +684,7 @@ export default {
     /** 新增按钮操作 */
     handleAdd(row) {
       this.reset();
+      this.fileList = []
       if (row != undefined) {
         this.form.parentId = row.fId;
       }
@@ -706,15 +707,23 @@ export default {
         this.form.fLocation = this.form.fLocation + ''
         this.form.fCharg = this.form.fCharg + ''
         // this.relevantAttachments = this.form.annexList ? this.form.annexList : [];
-        this.form.fProperties = this.form.fProperties.split(",")
-        this.form.fType = this.form.fType.split(",")
-        this.form.fGoodsType = this.form.fGoodsType.split(",")
+        if (this.form.fProperties != null) {
+          this.form.fProperties = this.form.fProperties.split(",");
+
+        }
+        if (this.form.fType != null) {
+          this.form.fType = this.form.fType.split(",");
+        }
+        if (this.form.fGoodsType != null) {
+          this.form.fGoodsType = this.form.fGoodsType.split(",");
+        }
         this.form.fCoverArea = this.form.fCoverArea
         this.fileList = []
+        console.log('response.data.annexList', response.data.annexList);
         for (let item in response.data.annexList) {
-
           this.fileList.push(response.data.annexList[item].fUrl)
         }
+        console.log('this.fileList', this.fileList);
         // 在每个元素前添加URL属性
         this.fileList = this.fileList.map((file) => {
           return { url: file };
@@ -734,19 +743,28 @@ export default {
         if (valid) {
           if (this.form.fId != undefined) {
             console.log(this.relevantAttachments)
-            this.form.annexList = this.relevantAttachments
-            this.form.fProperties = this.form.fProperties.join(',');
-            this.form.fType = this.form.fType.join(',');
-            this.form.fGoodsType = this.form.fGoodsType.join(',');
-            this.form.fPhotoUrl = []
+            // this.form.annexList = this.relevantAttachments
+            console.log(this.form.fProperties);
+            if (this.form.fProperties != null) {
+              this.form.fProperties = this.form.fProperties.join(",");
+
+            }
+            if (this.form.fType != null) {
+              this.form.fType = this.form.fType.join(",");
+            }
+            if (this.form.fGoodsType != null) {
+              this.form.fGoodsType = this.form.fGoodsType.join(",");
+
+            }
+            this.form.annexList = []
             for (let item in this.pictureEist) {
               if (this.pictureEist[item].response) {
-                this.form.fPhotoUrl.push({
-                  url: this.pictureEist[item].response.url
+                this.form.annexList.push({
+                  fUrl: this.pictureEist[item].response.url
                 })
               } else {
-                this.form.fPhotoUrl.push({
-                  url: this.pictureEist[item].url
+                this.form.annexList.push({
+                  fUrl: this.pictureEist[item].url
                 })
               }
             }
@@ -758,9 +776,29 @@ export default {
             });
           } else {
             this.form.annexList = this.relevantAttachments
-            this.form.fProperties = this.form.fProperties.join(',');
-            this.form.fType = this.form.fType.join(',');
-            this.form.fGoodsType = this.form.fGoodsType.join(',');
+            if (this.form.fProperties != null) {
+              this.form.fProperties = this.form.fProperties.join(",");
+
+            }
+            if (this.form.fType != null) {
+              this.form.fType = this.form.fType.join(",");
+
+            }
+            if (this.form.fGoodsType != null) {
+              this.form.fGoodsType = this.form.fGoodsType.join(",");
+            }
+            this.form.annexList = []
+            for (let item in this.pictureEist) {
+              if (this.pictureEist[item].response) {
+                this.form.annexList.push({
+                  fUrl: this.pictureEist[item].response.url
+                })
+              } else {
+                this.form.annexList.push({
+                  fUrl: this.pictureEist[item].url
+                })
+              }
+            }
             console.log(this.form.fProperties, this.form.fType, this.form.fGoodsType);
             addDept(this.form).then(response => {
               this.msgSuccess("新增成功");