vue使用element三级联动下拉框多选

在这里插入图片描述
在这里插入图片描述

选中高级软件和软件ui工程师之后,一级中的金融和工程也高亮了,这是因为后台返回数据的id(这里后台返回的categoryId值重复)值重复了

template

<el-form-item label="职位类别:" prop="listJobCategoryDTOLIN">
  <el-cascader
      :change-on-select="false"
      :props="defaultParams"
      :options="options"
      v-model="form.listJobCategoryDTOLIN"
      :clearable="true"
      style="width:450px"
      @change="handleChange"
      ref="cascaderUnit"
  >
  </el-cascader>
</el-form-item>

data数据

form: {
        listJobCategoryDTOLIN: [], //临时职位类被
        listJobCategoryDTO: [], //好像没用忘记删除
      },

methods

    //职位类别
    handleChange() {
      const checkedNodes = this.$refs['cascaderUnit'].getCheckedNodes()
      console.log(checkedNodes) // 获取当前点击的节点
      const arrNew = []
      checkedNodes.filter(item => {
        let obj = {
          jobThirdCategoryid: item.uid,
          jobThirdCategoryName: item.label
        }
        arrNew.push(obj)
      })
      this.form.listJobCategoryDTO = arrNew

    },
    // 职位类别
    jobCategoryList() {
      getPositionClassification().then(res => {
        if(res.code === 0) {
          console.log(res.data)
          this.options = res.data
          // this.jobCategoryListsOption = res.data
        }
      })
    },

create

//三级选择器
this.jobCategoryList()

版权声明:本文为weixin_51565477原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。