循环里面找相同的集合

2021-11-12  本文已影响0人  糖醋里脊120625
 userPermissions(index, rowData) {
      var that = this;
      this.$get(canTeenAnalysisI.treesidelist).then(function (response) {
        if (response.code == 200) {

          that.sunlighttreeData = response.data.filter((item, index, arr) => {
            return item.menuType == "1"
          });
          that.ShangYuantreeData = response.data.filter((item, index, arr) => {
            return item.menuType == "0"
          });
        } else {
          that.$message(response.message);
        }
      });


      that.ShangYuanmorenxuanz=[];
      that.sunlightmorenxuanz=[];
      that.dialogFormVisible = true;
      that.rowDataId = rowData.eiId;
      this.$get(canTeenAnalysisI.alluserfuladmin+ "?enterpriseId=" + that.rowDataId).then((res) => {
          if (res.data) {
            that.$refs.sunlighttree.setCheckedKeys([], false);
            that.$refs.ShangYuantree.setCheckedKeys([], false);
            that.Getecho(res.data.split(","))
          }
        }
      );
    },
    Getecho(resdata){
      this.ShangYuanrepeatdata=[];
      this.sunlightrepeatdata=[];
      var that=this
      that.sunlighttreeData.forEach((item, index) => {
        that.sunlightEachloop(item.menuId,resdata)
        if(item.children){
          item.children.forEach((each, index) => {
            that.sunlightEachloop(each.menuId,resdata)
          });

        }
      });
      that.ShangYuantreeData.forEach((item, index) => {
        that.ShangYuanEachloop(item.menuId,resdata)
        if(item.children){
          item.children.forEach((each, index) => {
            that.ShangYuanEachloop(each.menuId,resdata)
          });

        }
      });
    },
    ShangYuanEachloop(id,list){
      var that=this;
      list.forEach((item, index) => {
        if(id==item){
          this.ShangYuanrepeatdata= this.ShangYuanrepeatdata.concat(item)
        }
      });
      this.ShangYuanmorenxuanz= this.ShangYuanrepeatdata;
    },
上一篇下一篇

猜你喜欢

热点阅读