vue级联组件改造-根据勾选内容得顺序返回结果





 cascaderChange(val) {
      let auditPerson = {};
      auditPerson=this.getCascader(val,this.$refs.cascader.getCheckedNodes());
      debugger
      this.auditPersonIdsName = auditPerson.auditPersonIdsName;	//回显的数据
    },
    getCascader(val, AAA,type) {
      let auditPerson = {
        auditPersonIds: [],
        auditPersonIdsName: [],
      };

      if(this.tempData.length >= 0 && this.tempData.length <= val.length) {
        val.forEach((item)=> {
          if(this.tempData.indexOf(item) == -1) {
            this.tempData.push(item)
          }
        })
      }else if(val.length < this.tempData.length) {
        this.tempData.forEach((item,index)=> {
          if(val.indexOf(item) == -1) {
            this.tempData.splice(index,1)
          }
        })
      }else {
        this.tempData= JSON.parse(JSON.stringify(val));
      }
      auditPerson.auditPersonIds = this.tempData;
      this.tempData.forEach((temp)=> {
        AAA.forEach((item) => {
          if (temp == item.value) {
            auditPerson.auditPersonIdsName.push(item.label);
          }
        });
      })
      return auditPerson;
    },

你可能感兴趣的:(vue.js,javascript,前端)