Browse Source

转档,转档中不允许拖拽上传文件,文件状态样式的修改,重复储存问题,文件转档中状态完善

liyangbin 2 years ago
parent
commit
de4bafeeec
1 changed files with 24 additions and 13 deletions
  1. 24 13
      pages/converter.vue

+ 24 - 13
pages/converter.vue

@@ -337,6 +337,7 @@ export default {
             fileList: [],
             uniqFileArr: [],
             checkbox: true,
+            // 转档中,默认没在
             changeFileFlag: true,
             uploadNum: 0,
             getFileStatusTimer: null,
@@ -344,7 +345,9 @@ export default {
             changeSucesssFileList: [],
             visiable: false,
             noMia:false,
-            showInputDisable:false
+            showInputDisable:false,
+            // 转档后的文件名
+            // outFilenames:[]
         };
     },
     middleware: "user",
@@ -446,6 +449,9 @@ export default {
               this.visiable = true;
               return;
             }
+            if( !this.changeFileFlag ){
+              return;
+            }
             //传递拖拽的文件,限制只能传pdf文件
             let dropFile = event.dataTransfer.files
             let newArr= [];
@@ -651,13 +657,13 @@ export default {
                     return "未转换";
                 case 1:
                     this.$set(this.fileList[index], "status", 1);
-                    return "上传中";
+                    return "上传中...";
                 case 2:
                     this.$set(this.fileList[index], "status", 2);
-                    return "上传完成";
+                    return "<span style=\"color: #666666\">上传完成</span>";
                 case 3:
                     this.$set(this.fileList[index], "status", 3);
-                    return "转换中";
+                    return "<span style=\"color: orange\">转换中</span>";
                 case 4:
                     this.$set(this.fileList[index], "status", 4);
                     return "<span style=\"color: orange\">转换成功</span>";
@@ -669,7 +675,7 @@ export default {
                     return `<a href="${item.path}" style="color: #0dd299">下载</a>`;
             }
         },
-        // 转档第二步,上传文件
+        // 转档第二步,上传文件download="${item.name}"
         uploadFile(file, id, missionId) {
             // console.log(file)
             this.uploadNum = 0;
@@ -692,14 +698,13 @@ export default {
                 }
                 else {
                     this.changeFileFlag = true;
-                    console.log(file.name)
-                    this.changeFileStatus(file.name, 5);
+                    // console.log(file.name)
+                    this.changeFileStatus(all, 5);
                 }
             });
         },
         // 转档第三步,开始转档
-        convertFile(file, missionId) {
-          
+        convertFile(file, missionId) {          
             const formData = new FormData();
             formData.append("missionId", missionId);
             const config = {
@@ -735,12 +740,16 @@ export default {
                     for (let i = 0; i < getFileList.length; i++) {
                         if (getFileList[i].status === 2) {
                             this.changeFileStatus(getFileList[i].fileName, 4);
-                            console.log("200")
                             this.fileList.forEach(item => {
                                 if (item.name === getFileList[i].fileName) {
-                                  console.log("下载")
                                     this.changeFileStatus(getFileList[i].fileName, 6);
                                     this.$set(item, "path", getFileList[i].path);
+                                    // 对相同文件名与相同转换后文件进行去重
+                                    this.changeSucesssFileList.forEach((iten,index)=>{
+                                      if(iten.name.indexOf(item.name) !== -1 && iten.output.indexOf(item.output) !== -1){
+                                        this.changeSucesssFileList.splice(index,1)                                      
+                                      }
+                                    })
                                     this.changeSucesssFileList.push(item);
                                 }
                             });
@@ -768,6 +777,8 @@ export default {
                         }
                         this.uniqFileArr = result;
                         this.getUserInfo()
+                        this.uploadNum = 0;
+                        this.changeFileFlag = true;
                     }
                     // console.log('changeSucesssFileList:', this.changeSucesssFileList)
                     localStorage.setItem("file", JSON.stringify(this.changeSucesssFileList));
@@ -776,9 +787,9 @@ export default {
                     this.changeFileStatus("all", 5);
                     // 多失败就关闭查询
                     clearInterval(this.getFileStatusTimer);
+                    this.uploadNum = 0;
+                    this.changeFileFlag = true;
                 }
-                this.uploadNum = 0;
-                this.changeFileFlag = true;
             });
         }
     },