Holla-Tako před 5 měsíci
rodič
revize
e7161aa695

+ 60 - 0
src/page/mixin/legacyUpload.js

@@ -0,0 +1,60 @@
1
+import {uploadUrl_2} from "@/api/settlementManagement";
2
+import {downloadBase} from "@/api/inventoryQualityTraceability";
3
+import {basicUploadUrl, getFileList} from "@/api/base";
4
+export default {
5
+  data() {
6
+    return {
7
+      uploadUrl_2,
8
+      downloadBase,
9
+      fileList: [],
10
+      fileIds: [],
11
+      deleteFileIds: [],
12
+    }
13
+  },
14
+  methods: {
15
+    getFileListById(dataId) {
16
+      getFileList({bid: dataId, orgId: this.orgId}).then(resp => {
17
+
18
+        this.fileList = resp.map(d => {
19
+          return {
20
+            id: d.id,
21
+            name: d.originalFileName,
22
+            url: `${basicUploadUrl}${d.filePath}`
23
+          }
24
+        })
25
+        console.log('文件列表', resp, this.fileList)
26
+      })
27
+    },
28
+    onUploadSuccess(resp, file, fileList) {
29
+      console.log('上传文件 resp', resp, file, fileList)
30
+      this.fileList = fileList.map(f => {
31
+        let url
32
+        let id
33
+        if(f.response) {
34
+          url = f.response.filePath
35
+          id = f.response.id
36
+        }else {
37
+          url = f.url
38
+          id = f.id
39
+        }
40
+        return {
41
+          name: f.name,
42
+          url: url,
43
+          id: id,
44
+        }
45
+      })
46
+    },
47
+    onUploadRemove(fileList) {
48
+      const removeFiles = []
49
+      for(const f of this.fileList) {
50
+        const file = fileList.find(temp => temp.id === f.id)
51
+        if(! file) {
52
+          removeFiles.push(f)
53
+        }
54
+      }
55
+      this.fileList = fileList
56
+      this.deleteFileIds.push(... removeFiles.map(f => f.id))
57
+      console.log('删除文件 ', fileList, removeFiles)
58
+    }
59
+  }
60
+}

+ 3 - 45
src/page/storehouseManagement/components/hazardControlEdit.vue

@@ -163,8 +163,10 @@ import {simple_required} from "@/utils/ruleDatas";
163 163
 import upload from '@/components/upload/v2.vue'
164 164
 import {basicUploadUrl, getFileList, minioUrl} from "@/api/base";
165 165
 import {downloadBase} from "@/api/inventoryQualityTraceability";
166
+import legacyUpload from "@/page/mixin/legacyUpload";
166 167
 
167 168
 export default {
169
+  mixins: [legacyUpload, ],
168 170
   props: {
169 171
     visible: {
170 172
       type: Boolean,
@@ -220,9 +222,6 @@ export default {
220 222
       uploadUrl_2,
221 223
       show: this.visible,
222 224
       form: { },
223
-      fileList: [],
224
-      fileIds: [],
225
-      deleteFileIds: [],
226 225
       rules: {
227 226
         sbr: simple_required, fxxx: simple_required, hjbw: simple_required,
228 227
         fxlx: simple_required, fxfj: simple_required, fxglcs: simple_required,
@@ -240,17 +239,7 @@ export default {
240 239
       if(this.isAdd) {
241 240
       }else {
242 241
         console.log('查看 id', this.dataId)
243
-        getFileList({bid: this.dataId, orgId: this.orgId}).then(resp => {
244
-
245
-          this.fileList = resp.map(d => {
246
-            return {
247
-              id: d.id,
248
-              name: d.originalFileName,
249
-              url: `${basicUploadUrl}${d.filePath}`
250
-            }
251
-          })
252
-          console.log('文件列表', resp, this.fileList)
253
-        })
242
+        this.getFileListById(this.dataId)
254 243
         StorageSafeManageControllerEdit(this.dataId).then(resp  => {
255 244
           this.form = resp.storageSafeManageWithBLOBs
256 245
           // const fl = resp.fileList || []
@@ -331,37 +320,6 @@ export default {
331 320
         }
332 321
       })
333 322
     },
334
-    onUploadSuccess(resp, file, fileList) {
335
-      console.log('上传文件 resp', resp, file, fileList)
336
-      this.fileList = fileList.map(f => {
337
-        let url
338
-        let id
339
-        if(f.response) {
340
-          url = f.response.filePath
341
-          id = f.response.id
342
-        }else {
343
-          url = f.url
344
-          id = f.id
345
-        }
346
-        return {
347
-          name: f.name,
348
-          url: url,
349
-          id: id,
350
-        }
351
-      })
352
-    },
353
-    onUploadRemove(fileList) {
354
-      const removeFiles = []
355
-      for(const f of this.fileList) {
356
-        const file = fileList.find(temp => temp.id === f.id)
357
-        if(! file) {
358
-          removeFiles.push(f)
359
-        }
360
-      }
361
-      this.fileList = fileList
362
-      this.deleteFileIds.push(... removeFiles.map(f => f.id))
363
-      console.log('删除文件 ', fileList, removeFiles)
364
-    }
365 323
   }
366 324
 
367 325
 }