vue+elementui---下拉树形多选

  1. html部分
            
              
            

  2. 引入包
    import { treeselectuser } from '@/api/system/dept';
    import Treeselect from "@riophae/vue-treeselect";
    import "@riophae/vue-treeselect/dist/vue-treeselect.css";

  3. js初始化
    export default {
      name: "",
      components: { Treeselect },
      data() {
        return {
            deptUOptions: undefined,
        }
      }
    }

  4. js处理部分
    /** 查询部门人员下拉树结构 */
        getTreeselect() {
          treeselectuser().then(response => {
            this.deptUOptions = response.data;
            for (let deptElememt of this.deptUOptions) {
              this.doDept(deptElememt)
            }
          });
        },
        /** 区分部门和人员的处理 */
        doDept(dept){
          if (dept.treeFlag=='0'&&!dept.children){
            dept.children=[];
          }
          for (let deptElement of dept.children) {
            if (deptElement.treeFlag=='0'){
              this.doDept(deptElement)
            }
          }
        },
    
        nodeSgySelect(node, instanceId){
          this.form.sgyIdArr.push(node.id)
        },
        nodeSgyCancelSelect(node, instanceId){
        },

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