ソースを参照

E服务附件问题

xiaohaizhao 2 年 前
コミット
d094ef98ea
2 ファイル変更18 行追加33 行削除
  1. 7 15
      Eservice/components/autoUpload/upload.js
  2. 11 18
      Eservice/components/upload/upload.js

+ 7 - 15
Eservice/components/autoUpload/upload.js

@@ -51,15 +51,13 @@ Component({
    */
   methods: {
     handleAdd(file) {
-      console.log(file)
-      let files = file.detail.files.map(e => {
+      let files = this.data.originFiles.concat(file.detail.files.map(e => {
         e.status = 'loading'
         return e
-      })
+      }));
       this.setData({
         uploadCount: files.length,
-        originFiles: files,
-        attachmentids: []
+        originFiles: files
       })
       this.toSetFileData()
     },
@@ -85,7 +83,6 @@ Component({
       })
     },
     handleRemove(data) {
-      console.log(data)
       let file = {
         currentTarget: {
           dataset: {
@@ -159,21 +156,17 @@ Component({
               "serialfilename": res.serialfilename
             }
           }).then(rs => {
-
+            that.data.attachmentids.push(rs.data.attachmentids[0])
             that.setData({
+              uploadCount: that.data.uploadCount - 1,
               originFiles: that.data.originFiles.map(e => {
                 if (e.name === res.filename) {
-                  e.status = ''
+                  e.status = '';
+                  e.attachmentids = rs.data.attachmentids[0]
                 }
                 return e
               })
             })
-
-            that.data.attachmentids.push(rs.data.attachmentids[0])
-
-            that.setData({
-              uploadCount: that.data.uploadCount - 1
-            })
           }).catch(err => {
             console.log(err)
           })
@@ -181,7 +174,6 @@ Component({
       })
     },
     async filebindData() {
-
       this.data.bindData.attachmentids = this.data.attachmentids
       const res = await api._post({
         "classname": "system.attachment.Attachment",

+ 11 - 18
Eservice/components/upload/upload.js

@@ -20,9 +20,7 @@ Component({
    * 组件的初始数据
    */
   data: {
-    originFiles: [
-
-    ],
+    originFiles: [],
     attachmentids: [],
     gridConfig: {
       column: 5,
@@ -41,23 +39,21 @@ Component({
    */
   methods: {
     handleAdd(file) {
-      let files = file.detail.files.map(e => {
+      let files = this.data.originFiles.concat(file.detail.files.map(e => {
         e.status = 'loading'
         return e
-      })
+      }));
       this.setData({
         uploadCount: files.length,
-        originFiles: files,
-        attachmentids: []
+        originFiles: files
       })
       this.toSetFileData()
     },
     handleRemove(data) {
-      let file = data.detail.file
+      let file = data.detail.file;
       this.setData({
-        originFiles: this.data.originFiles.filter(e => {
-          return e.name !== file.name
-        })
+        originFiles: this.data.originFiles.filter(e => e.name !== file.name),
+        attachmentids: this.data.attachmentids.filter(e => e !== file.attachmentids)
       })
     },
     toSetFileData() {
@@ -125,20 +121,17 @@ Component({
             }
           }).then(rs => {
             console.log("上传附件反馈", rs)
+            that.data.attachmentids.push(rs.data.attachmentids[0])
             that.setData({
+              uploadCount: that.data.uploadCount - 1,
               originFiles: that.data.originFiles.map(e => {
                 if (e.name === res.filename) {
-                  e.status = ''
+                  e.status = '';
+                  e.attachmentids = rs.data.attachmentids[0]
                 }
                 return e
               })
             })
-
-            that.data.attachmentids.push(rs.data.attachmentids[0])
-
-            that.setData({
-              uploadCount: that.data.uploadCount - 1
-            })
           }).catch(err => {
             console.log(err)
           })