scorpioyq 3 жил өмнө
parent
commit
a4ee94175a

+ 3 - 0
src/api/common.js

@@ -4,4 +4,7 @@ export default {
     dicList(params) {
         return fetch('/blade-system/dict-biz/dictionary', params)
     },
+    submit(params) { //保存上传文件素材
+        return fetch('/wutong-library/library/save', params, 'post', 'json')
+    },
 }

+ 4 - 0
src/components/upload-file.vue

@@ -167,6 +167,10 @@ export default {
       this.$emit('close')
     },
     submint() {
+      if (this.tmpFileList && this.tmpFileList.length === 0) {
+        this.$message.error('请先选择要上传的文件')
+        return
+      }
       this.$refs.upload.submit()
     },
     remove(file, fileList) {

+ 2 - 2
src/config/website.js

@@ -4,7 +4,7 @@
 export default {
     title: '梧桐树云平台',
     tenant: '000000',
-    clientId: 'pcapplet', // 客户端id
-    clientSecret: 'pcapplet_secret', // 客户端密钥
+    clientId: 'project_wx', // 客户端id
+    clientSecret: 'project_wx_key', // 客户端密钥
     statusWhiteList: []
 }

+ 21 - 6
src/views/home/component/current.vue

@@ -36,7 +36,9 @@ export default {
   data() {
     return {
       show: false,
-      fileList: []
+      fileList: [],
+      saveCount: 0,
+      libraryList: [],
     }
   },
   methods: {
@@ -50,13 +52,26 @@ export default {
         item.fileFolderId = this.id
         return item
       })
-      this.addFile()
+      this.fileList.forEach(sub => {
+        this.saveLibrary(sub)
+      })
+    },
+    saveLibrary(sub) {
+      let data = {category: 4, content: ''}
+      this.$api.common.submit(Object.assign(sub, data)).then(res => {
+        if (res.code === 200) {
+          this.saveCount++
+          this.libraryList.push(res.data.id)
+          if (this.saveCount === this.fileList.length) {
+            this.saveCount = 0
+            this.addFile()
+          }
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
     },
     addFile() {
-      if (this.fileList.length === 0) {
-        this.$message.error('请先上传相关文件')
-        return
-      }
       this.$api.project.fileAdd(this.fileList).then(res => {
         if (res.code === 200) {
           this.show = false

+ 24 - 8
src/views/home/component/folder_list.vue

@@ -52,13 +52,16 @@ export default {
     total: String,
     type: {
       type: Number,
-      default: 0
+      default: 0,
     }
   },
   data() {
     return {
       show: false,
-      currentRow: null
+      currentRow: null,
+      libraryList: [],
+      saveCount: 0,
+      fileList: [],
     }
   },
   methods: {
@@ -98,7 +101,6 @@ export default {
     },
     success(res) {
       this.fileList = res.fileList.map(res => {
-        console.log('dddd' + res)
         const item = {}
         item.title = res.response.data.originalFileName
         item.suffix = res.response.data.suffix
@@ -111,13 +113,27 @@ export default {
         }
         return item
       })
-      this.addFile()
+      this.fileList.forEach(sub => {
+        this.saveLibrary(sub)
+      })
+    },
+    saveLibrary(sub) {
+      let data = {category: 4, content: ''}
+      this.$api.common.submit(Object.assign(sub, data)).then(res => {
+        if (res.code === 200) {
+          this.saveCount++
+          this.libraryList.push(res.data.id)
+          if (this.saveCount === this.fileList.length) {
+            console.log(this.fileList.length + 'ddjdjfyydju')
+            this.saveCount = 0
+            this.addFile()
+          }
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
     },
     addFile() {
-      if (this.fileList.length === 0) {
-        this.$message.error('请先上传相关文件')
-        return
-      }
       this.$api.project.fileAdd(this.fileList).then(res => {
         if (res.code === 200) {
           this.show = false