Prechádzať zdrojové kódy

培训任务选取知识库文件可重复bug处理

jingyuanchao 1 rok pred
rodič
commit
228caf917e

+ 15 - 2
src/views/core/edu/task/dialog.newTask.vue

@@ -272,10 +272,23 @@ export default {
     fileSelected(list) {
       if (!list) return;
       let tempArry = [];
+      let fileNameList=[]
+      let addFileNameList=[]
+      this.formData.fileList.forEach(x => {
+        let fileObj= JSON.parse(x);
+        fileNameList.push(fileObj.name);
+      })
       list.forEach(x => {
-        tempArry = tempArry.concat(x.fileList);
+        tempArry.forEach(s => {
+          addFileNameList.push(JSON.parse(s).name);
+        })
+        x.fileList.forEach(y => {
+          let fileObj= JSON.parse(y);
+          if (fileNameList.indexOf(fileObj.name) == -1&&addFileNameList.indexOf(fileObj.name) == -1) {
+            tempArry.push(y);
+          }
+        })
       })
-      console.log("tempArry", tempArry, this.formData.fileList);
       if (this.formData.fileList) {
         this.formFileListDefualtValue = this.formData.fileList.concat(tempArry);
       } else {

+ 15 - 6
src/views/core/edu/task/dialog.perform.vue

@@ -394,18 +394,27 @@ export default {
       }
     },
     fileSelected(list) {
-
       if (!list) return;
       let tempArry = [];
+      let fileNameList=[]
+      let addFileNameList=[]
+      this.formData.fileList.forEach(x => {
+        let fileObj= JSON.parse(x);
+        fileNameList.push(fileObj.name);
+      })
       list.forEach(x => {
-        tempArry = tempArry.concat(x.fileList);
+        tempArry.forEach(s => {
+          addFileNameList.push(JSON.parse(s).name);
+        })
+        x.fileList.forEach(y => {
+          let fileObj= JSON.parse(y);
+          if (fileNameList.indexOf(fileObj.name) == -1&&addFileNameList.indexOf(fileObj.name) == -1) {
+            tempArry.push(y);
+          }
+        })
       })
-      console.log("tempArry", tempArry, this.formData.fileList);
       if (this.formData.fileList) {
-        console.log("12312312121212121212121")
         this.formFileListDefualtValue = this.formData.fileList.concat(tempArry);
-        this.formData.fileList = this.formData.fileList.concat(tempArry);
-        console.log("this.formFileListDefualtValue", this.formFileListDefualtValue)
       } else {
         this.formFileListDefualtValue = tempArry;
       }