zoukankan      html  css  js  c++  java
  • js 去重和过滤

    //去重 

    if ( (this.selectPeopleList != null) & (this.selectPeopleList.length != 0) ) { let arrId = []; let arrName = []; this.selectPeopleList.map((item) => { arrId.push(item.id); arrName.push(item.name); //去重 let x = new Set(arrName); let y = [...x]; // this.info.inspector = arr.join(","); this.info.inspector = y; }); }
    getTypeTree(item, index) {
          console.log(111, index);
          let getCheckedNodes = this.$refs.treeForm.getCheckedNodes(); //获取被勾选的节点
          let getSelectedNodes = this.$refs.treeForm.getSelectedNodes(); //获取被选中的节点
          let getCheckedAndIndeterminateNodes = this.$refs.treeForm.getCheckedAndIndeterminateNodes(); //获取选中及半选节点
          if (getCheckedNodes != null) {
            // this.selectPeopleList = getCheckedNodes;
            console.log("getCheckedNodes", getCheckedNodes);
            //--
            getCheckedNodes
              .filter((item) => {
                //过滤组织
                return item.iconSkin !== "group";
              })
              .map((item) => {
                // return item;
                this.selectPeopleList.push(item.name);
              });
            //--
            // getCheckedNodes.map((item) => {
            //   this.selectPeopleList.push(item.name);
            // });
            //过滤重复的
            this.selectPeopleList = this.selectPeopleList.filter(
              (element, index, self) => {
                return self.indexOf(element) === index;
              }
            );
            this.selectNumber = this.selectPeopleList.length;
            console.log("this.selectPeopleList", this.selectPeopleList);
          }
        },
    // 去除重复的和group;
            let result = [];
            let obj = {};
            for (let i = 0; i < this.selectPeopleListNew.length; i++) {
              if (this.selectPeopleListNew[i].iconSkin !== "group") {
                if (!obj[this.selectPeopleListNew[i].id]) {
                  result.push(this.selectPeopleListNew[i]);
                  obj[this.selectPeopleListNew[i].id] = true;
                }
              }
            }
  • 相关阅读:
    添加远程库
    Git远程仓库
    Git 删除文件
    Git撤销暂存区stage中的内容
    Git 暂存区的概念
    Git add和commit步骤分析
    2017CCPC秦皇岛 E题String of CCPC&&ZOJ3985【模拟】
    2017CCPC秦皇岛 C题Crusaders Quest&&ZOJ3983【模拟+STL】
    2017CCPC秦皇岛 L题One-Dimensional Maze&&ZOJ3992【模拟】
    HDU2444 The Accomodation of Students【匈牙利算法】
  • 原文地址:https://www.cnblogs.com/Byme/p/14415374.html
Copyright © 2011-2022 走看看