jwyu 1 gadu atpakaļ
vecāks
revīzija
ba680cb49e
1 mainītis faili ar 69 papildinājumiem un 29 dzēšanām
  1. 69 29
      pages/index/index.vue

+ 69 - 29
pages/index/index.vue

@@ -327,37 +327,71 @@ export default {
       }
     },
     async lableKeysHandler(item) {
-      let actId = [];
-      this.$set(item, "isAct", !item.isAct);
-      if (item.isAct) {
-        let index = this.lableArrList.findIndex((val) => val === item);
-        console.log(index);
-        index >= 0 ? (this.lableArrList = this.lableArrList.splice(index, 1)) : "";
-        this.lableArrList.push(item);
-        const firstIndex = this.findFirstIntersectingObjectIndex(this.lableArrList);
-        console.log(this.lableArrList, firstIndex);
-        if (firstIndex >= 0) {
-          this.dataListLable.forEach((item) => {
-            if (item === this.lableArrList[firstIndex]) {
-              item.isAct = !item.isAct;
-            }
-          });
-          this.lableArrList = this.lableArrList.splice(firstIndex, 1);
+      const checkList=item.CheckList
+      let isFlag=false //是否有交集
+      for (let e of checkList) {
+        if(this.lableArrList.includes(e)){
+          isFlag=true
+          break;
         }
       }
 
-      this.lableIsRows.forEach((item) => {
-        item.forEach((_) => {
-          _.isAct && actId.push(_.TagId);
-        });
-      });
-      this.page_no = 1;
-      this.actIdLable = actId.join(",");
-      this.getNewList();
-      if (!item.isAct) return;
-      const res = await Home.tagAddHistory({
-        TagId: item.TagId,
-      });
+      if(!isFlag){
+        this.lableArrList=[...this.lableArrList,...checkList]
+        item.isAct=true
+      }else{//有交集
+        // 找到有交集的那个 设置为false 然后将点击的这个设置为true
+        this.lableIsRows.forEach(e1=>{
+          e1.forEach(e2=>{
+            let flag=false
+            for(let i of e2.CheckList){
+              if(this.lableArrList.includes(i)){
+                flag=true
+                break
+              }
+            }
+            if(flag){
+              e2.isAct=false
+            }
+          })
+        })
+
+        item.isAct=true
+      }
+
+
+      
+      // let actId = [];
+      // this.$set(item, "isAct", !item.isAct);
+      // if (item.isAct) {
+      //   let index = this.lableArrList.findIndex((val) => val === item);
+      //   console.log(index);
+      //   index >= 0 ? (this.lableArrList = this.lableArrList.splice(index, 1)) : "";
+      //   this.lableArrList.push(item);
+      //   const firstIndex = this.findFirstIntersectingObjectIndex(this.lableArrList);
+      //   console.log(this.lableArrList, firstIndex);
+      //   if (firstIndex >= 0) {
+      //     this.dataListLable.forEach((item) => {
+      //       if (item === this.lableArrList[firstIndex]) {
+      //         item.isAct = !item.isAct;
+      //       }
+      //     });
+      //     this.lableArrList = this.lableArrList.splice(firstIndex, 1);
+      //   }
+      // }
+
+      // this.lableIsRows.forEach((item) => {
+      //   item.forEach((_) => {
+      //     _.isAct && actId.push(_.TagId);
+      //   });
+      // });
+      // this.page_no = 1;
+      // this.actIdLable = actId.join(",");
+      // this.getNewList();
+      // if (!item.isAct) return;
+      // const res = await Home.tagAddHistory({
+      //   TagId: item.TagId,
+      // });
     },
     findFirstIntersectingObjectIndex(arr) {
       for (let i = 0; i < arr.length - 1; i++) {
@@ -385,7 +419,13 @@ export default {
     async homeTagListCustom() {
       const res = await Home.homeTagListCustom();
       if (res.Ret === 200) {
-        this.dataListLable = res.Data || [];
+        const arr=res.Data || [];
+        this.dataListLable = arr.map(item=>{
+          return {
+            ...item,
+            isAct:false
+          }
+        })
       }
     },
   },