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;
                }
              }
            }
  • 相关阅读:
    使用EF批量新增数据十分缓慢
    EF中获取当前上下文的表名
    下拉框停用数据的处理
    CEILING保留n位小数向上取整
    MVC ValidationAttribute 验证一个字段必须大于另一个字段
    EF通过导航属性取出从表的集合后,无法删除子表
    我得新博客上线了采用Vue+Layui的结合开发,后台采用asp.net mvc
    CTS,CLS,CLR解释
    Linq与委托
    C#4.0的十种语法糖
  • 原文地址:https://www.cnblogs.com/Byme/p/14415374.html
Copyright © 2011-2022 走看看