Explorar el Código

允许一个文件多次转换

liyangbin hace 2 años
padre
commit
2ca3345feb
Se han modificado 1 ficheros con 12 adiciones y 35 borrados
  1. 12 35
      pages/converter.vue

+ 12 - 35
pages/converter.vue

@@ -350,6 +350,8 @@ export default {
             // 转档中,默认没在
             changeFileFlag: true,
             uploadNum: 0,
+            uploadErrNum: 0,
+            uploadSuccessNum: 0,
             getFileStatusTimer: null,
             changeSucesssNumTotal: 0,
             changeSucesssFileList: [],
@@ -397,7 +399,6 @@ export default {
         }
     },
     mounted() {
-        // console.log(this.userInfo)
         if (localStorage.getItem("file") !== null) {
             this.fileList = JSON.parse(localStorage.getItem("file"));
             this.changeSucesssFileList = JSON.parse(localStorage.getItem("file"));
@@ -496,8 +497,6 @@ export default {
               a = "docx"
             }
             const defaultPrice = await this.getFilePrice("pdf", a);
-            // console.log("上传文件1:展示的文件",this.fileList)
-            // console.log("上传文件1:上传后台的文件:",this.uniqFileArr)
             for (let i = 0; i < array.length; i++) {
                 const id = Date.now() + Math.random().toString(36).slice(-8)
                 const fileObj = {
@@ -535,11 +534,7 @@ export default {
             //     newArr.push(item);
             //   }
             // }
-            // this.uniqFileArr=newArr}
-            // console.log("上传文件2:展示的文件",this.fileList)
-            // console.log("上传文件2:上传后台的文件:",this.uniqFileArr)
-
-            
+            // this.uniqFileArr=newArr}         
             if(event.target){
               event.target.value=''
             }
@@ -588,16 +583,12 @@ export default {
         },
         // 删除文件
         deleteFile(index, item) {
-          // console.log(item)
-          // console.log("上传文件4:上传后台的文件:",this.uniqFileArr,this.fileList[index])
           for(let i=0;i<this.uniqFileArr.length;i++){
             if(item.id === this.uniqFileArr[i].id){
               this.uniqFileArr.splice(i,1)
             }
           }
           this.fileList.splice(index, 1);
-            // console.log("上传文件3:展示的文件",index,this.fileList,this.changeSucesssNumTotal)
-            // console.log("上传文件3:上传后台的文件:",this.uniqFileArr)
             this.changeSucesssFileList = [];
             localStorage.removeItem("file");
             this.fileList.forEach(item => {
@@ -622,18 +613,12 @@ export default {
                 this.fileList.forEach(item => {
                   if (item.status !== 6) {
                     this.$set(item, "status", status);
-                    console.log("全部中要换的:", item,item.status)
-                    }else{
-                      console.log("全部中不换的",item,item.status)
-                    }
+                  }
                 });
             } else {
                 this.fileList.forEach(item => {
-                    if (item.name === fileName && item.output === outputType && item.state !=6) {
-                      console.log("选择中换的",item,item.status)
+                    if (item.name === fileName && item.output === outputType && item.status !=6) {
                       this.$set(item, "status", status);
-                    }else{
-                      console.log("选择中不换的",item,item.status)
                     }
                 });
             }
@@ -703,17 +688,14 @@ export default {
                 data: fileArr
             };
             this.$axios("/mission/create", config).then((res) => {
-              // console.log(res)
                 if (res.code === 200) {
                     const missionFiles = res.result.missionFilePoJos;
-                    console.log("第一步",missionFiles,this.uniqFileArr)
                     for (let i = 0; i < missionFiles.length; i++) {
                         this.changeFileStatus(missionFiles[i].fileName, 1, missionFiles[i].outputType);
                         this.uploadFile(this.uniqFileArr[i], missionFiles[i].id, res.result.id);
                     }
                 }
                 else {
-                  // console.log("111")
                     this.changeFileFlag = true;
                     this.changeFileStatus("all", 5);
                 }
@@ -721,7 +703,6 @@ export default {
         },       
         // 转档第二步,上传文件download="${item.name}"
         uploadFile(file, id, missionId) {
-            // console.log(file)
             this.uploadNum = 0;
             const formData = new FormData();
             formData.append("file", file);
@@ -732,19 +713,21 @@ export default {
                 }
             };
             this.$axios.post("/missionFile/upload", formData, config).then((res) => {
-                // console.log('上传文件')
                 if (res.code === 200) {
-                  console.log("第二步的",file,file.name, 2,file.output)
                     this.changeFileStatus(file.name, 2,file.output);
                     this.uploadNum++;
+                    this.uploadSuccessNum++;
                     if (this.uploadNum === this.uniqFileArr.length) {
                         this.convertFile(file.name, missionId);
                     }
                 }
                 else {
-                    this.changeFileFlag = true;
-                    // console.log(file.name)
-                    this.changeFileStatus("all", 5);
+                    this.uploadErrNum++;
+                    let uploadAllNum = this.uploadErrNum + this.uploadSuccessNum
+                    if(uploadAllNum === this.uniqFileArr.length){
+                      this.changeFileFlag = true;
+                      this.changeFileStatus("all", 5);
+                    }
                 }
             });
         },
@@ -758,9 +741,7 @@ export default {
                 }
             };
             this.$axios.post("/mission/convertFile", formData, config).then((res) => {
-                // console.log('开始转档')
                 if (res.code === 200) {
-                    console.log("第三步的")
                     this.changeFileStatus("all", 3);
                     this.getFileStatusTimer = window.setInterval(() => {
                         setTimeout(this.getFileStatus(formData, config), 0);
@@ -776,11 +757,9 @@ export default {
         // 转档最后一步,轮询文件状态和下载链接
         getFileStatus(formData, config) {
             this.$axios.post("/mission/queryFileStatus", formData, config).then((res) => {
-                // console.log('获取文件状态')
                 if (res.code === 200) {
                     // 转档文件列表
                     const getFileList = res.result[0].missionFilePoJos;
-                    // console.log(getFileList)
                     // 转档成功与失败的数量
                     let changeSucesssNum = 0;
                     let changeErrNum = 0;
@@ -823,12 +802,10 @@ export default {
                             });
                         }
                         this.uniqFileArr = result;
-                        // console.log("上传文件5:上传后台的文件:",this.uniqFileArr)
                         this.getUserInfo()
                         this.uploadNum = 0;
                         this.changeFileFlag = true;
                     }
-                    // console.log('changeSucesssFileList:', this.changeSucesssFileList)
                     localStorage.setItem("file", JSON.stringify(this.changeSucesssFileList));
                 }
                 else {