Browse Source

二次转档功能修复

wzl 2 years ago
parent
commit
a2e00f1814
1 changed files with 32 additions and 15 deletions
  1. 32 15
      pages/converter.vue

+ 32 - 15
pages/converter.vue

@@ -36,7 +36,7 @@ class="mt-20px text-[#4D4D4D] text-16px font-600 inline-flex items-center leadin
               <a class="text-[#ff4f4f] no-underline leading-normal">充值</a>
             </span>
             <div class="need-volume float-right right-48px text-16px text-[#666] leading-48px mr-20px">
-              所需券:<span class="text-[#0dd299] text-16px" :class="{'text-red-500': requiredCoupon > userInfo?.points}">{{ requiredCoupon }}券</span> / 剩余券:<span class="text-[#0dd299] text-16px">{{ userInfo.points ? userInfo.points : 0 }}券</span>
+              所需券:<span class="text-[#0dd299] text-16px" :class="{'text-red-500': requiredCoupon > userInfo?.points}">{{ requiredCoupon }}券</span> / 剩余券:<span class="text-[#0dd299] text-16px">{{ Object.keys(this.userInfo).length === 0 ? 0 : userInfo.points }}券</span>
             </div>
           </div>
           <div class="transfer-panel">
@@ -70,7 +70,7 @@ class="mt-20px text-[#4D4D4D] text-16px font-600 inline-flex items-center leadin
                               <div class="explorer-caption max-w-260px truncate block text-[#777]" title="test.pdf">{{ item.name }}</div>
                             </td>
                             <td class="file-details-cell text-[#999]">{{ getfilesize(item.size) }}</td>
-                            <td class="file-details-cell points">{{ userInfo.subscriberType === 1 ? 0 : item.price }}</td>
+                            <td class="file-details-cell points">{{ userInfo?.subscriberType === 1 ? 0 : item.price }}</td>
                             <td class="file-details-cell select w-106px">
                               <select v-if="item.status !== 6" v-model="item.output" class="transfer-select appearance-none text-center min-w-90px" @change="changeOutput(item, index)">
                                 <option value="png" class="text-center">PNG</option>
@@ -104,7 +104,7 @@ class="mt-20px text-[#4D4D4D] text-16px font-600 inline-flex items-center leadin
                     </div>
                   </div>
                   <div class="input-group file-caption-main w-[100%] -top-450px relative table border-separate">
-                    <div class="input-group-btn relative text-0px whitespace-nowrap !flex">
+                    <div v-if="changeFileFlag" class="input-group-btn relative text-0px whitespace-nowrap !flex">
                       <div tabindex="500" class="btn btn-file" :class="{'btn-file-left' : fileList.length > 0}">
                         <div class="add-file" :class="{'add-file-left':(fileList.length > 0)}">{{ fileList.length > 0 ? '添加文件' : '' }}</div>
                         <input id="fileinput-explorer" ref="file" name="file" accept=".pdf" title="上传文件" type="file" multiple=""
@@ -337,15 +337,22 @@ export default {
       for (let i = 0; i < this.fileList.length; i++) {
         total += this.fileList[i].price
       }
-      if (this.userInfo.subscriberType !== null && this.userInfo.subscriberType === 1) {
+      for (const file of this.fileList) {
+        if (file.status === 6) {
+          total -= file.price
+        }
+      }
+      if (this.userInfo && this.userInfo.subscriberType === 1) {
         total = 0
       }
       return total
     }
   },
   mounted () {
+    console.log(this.userInfo)
     if (localStorage.getItem('file') !== null) {
       this.fileList = JSON.parse(localStorage.getItem('file'))
+      this.changeSucesssFileList = JSON.parse(localStorage.getItem('file'))
     }
   },
   methods: {
@@ -467,7 +474,6 @@ export default {
       const filterFileList = this.fileList.filter(function(item){
         return item.status !== 6
       })
-      console.log(filterFileList)
       let fileArr = []
       for (let i = 0; i < filterFileList.length; i++) {
         const file = {}
@@ -479,7 +485,6 @@ export default {
         fileArr[i] = file;
       }
       fileArr = JSON.stringify(fileArr)
-      console.log(fileArr)
       this.changeFileFlag = false
       this.changeFileStatus('all', 1)
       const config = {
@@ -496,7 +501,7 @@ export default {
           const missionFiles = res.result.missionFilePoJos
           console.log(missionFiles)
           for (let i = 0; i < missionFiles.length; i++) {
-            this.changeFileStatus(missionFiles[i].fileName, 2)
+            this.changeFileStatus(missionFiles[i].fileName, 1)
             this.uploadFile(this.uniqFileArr[i], missionFiles[i].id, res.result.id)
           }
         } else {
@@ -550,6 +555,7 @@ export default {
     // 转档第二步,上传文件
     uploadFile (file, id, missionId) {
       console.log(file)
+      this.uploadNum = 0
       const formData = new FormData()
       formData.append('file', file)
       formData.append('missionFileId', id)
@@ -561,9 +567,8 @@ export default {
       this.$axios.post('/missionFile/upload', formData, config).then((res) => {
         console.log('上传文件')
         if(res.code === 200) {
-          this.changeFileStatus(file.name, 3)
+          this.changeFileStatus(file.name, 2)
           this.uploadNum++
-          console.log(this.uploadNum)
           if (this.uploadNum === this.uniqFileArr.length) {
             this.convertFile(file.name, missionId)
           }
@@ -585,7 +590,7 @@ export default {
       this.$axios.post('/mission/convertFile', formData, config).then((res) => {
         console.log('开始转档')
         if(res.code === 200) {
-          this.changeFileStatus('all', 4)
+          this.changeFileStatus('all', 3)
           this.getFileStatusTimer = window.setInterval(() => {
             setTimeout(this.getFileStatus(formData, config), 0)
           }, 3000)
@@ -606,29 +611,41 @@ export default {
           let changeSucesssNum = 0
           for (let i = 0; i < getFileList.length; i++) {
             if (getFileList[i].status === 2) {
-              this.changeFileStatus(getFileList[i].fileName, 6)
-              changeSucesssNum++
+              this.changeFileStatus(getFileList[i].fileName, 4)
               this.fileList.forEach(item => {
                 if (item.name === getFileList[i].fileName) {
+                  this.changeFileStatus(getFileList[i].fileName, 6)
                   this.$set(item, 'path', getFileList[i].path)
                   this.changeSucesssFileList.push(item)
                 }
               })
+            } else {
+              this.changeFileStatus(getFileList[i].fileName, 5)
             }
+            changeSucesssNum++
           }
           if (changeSucesssNum === getFileList.length) {
             clearInterval(this.getFileStatusTimer)
             this.getFileStatusTimer = null
             this.changeSucesssNumTotal += changeSucesssNum
-            this.uniqFileArr = []
+            let failedFileList = getFileList.filter((val) => val.status === 3)
+            let failedFileNameArr = failedFileList.map(val => val.fileName)
+            let result = []
+            for (let i = 0; i < failedFileNameArr.length; i++) {
+              this.uniqFileArr.forEach(item => {
+                if (item.name === failedFileNameArr[i]) {
+                  result.push(item)
+                }
+              })
+            }
+            this.uniqFileArr = result
           }
-          console.log(this.fileList)
           console.log('changeSucesssFileList:', this.changeSucesssFileList)
           localStorage.setItem('file', JSON.stringify(this.changeSucesssFileList))
         } else {
-          this.uploadNum = 0
           this.changeFileStatus('all', 5)
         }
+        this.uploadNum = 0
         this.changeFileFlag = true
       })
     }