1.通讯录列表
<h6>通讯录列表</h6>
<div class="input-wrap">
<el-cascader class="cascader" :show-all-levels="false" :options="depTree" :props="defaultProps" v-model="selectDepartmentList" filterable clearable change-on-select @change="handleChange"></el-cascader>
</div>
2.data里声明
data() {
return {
defaultProps:{//级联选择器部门人员自定义变量指示
value:'ID',
label:'NAME',
children:'CHILDREN',
},
depTree:[],
selectDepartmentList: [],//默认值
bmmc:null, //部门名称索引
}
}
3.点击 筛选部门
//筛选部门
handleChange(val){
console.log(1212,val)
this.bmmc = val[val.length-1],
this.getAddressList();//获取列表的方法
},
4.搜索框 无人员显示 只获取部门
//部门树状结构(搜索框)
getBmTree(){
let param = {
departid: '',
name:'',
}
this._GetDepartmentTreeAndUser(param).then(da => {
let data = JSON.parse(da);
if (data.status==0) {
this.keepDep(data.result);
data.result.forEach(ele=>{
if(ele.ID!='918' && ele.ID!='919' && ele.ID!='920'){//此处因为返回之中无ISDEPARTMENT字段
this.depTree.push(ele)
}
})
}
});
},
//递归处理空的部门children(搜索框)
keepDep(item){
if(item&&item.length!=0){
item.forEach(ele =>{
if(ele.CHILDREN.length!=0){
this.keepDep(ele.CHILDREN)
}else{
delete ele.CHILDREN
}
})
}
},
5 声明
mounted() {
this.getBmTree()
}