<el-form-item label="单位名称">
<el-cascader :props="props"
@change="handleChangeDept"
v-model="deptValue"
clearable>
</el-cascader>
</el-form-item>
data() {
return {
//存放选中单位的ids
deptValue:[],
//联级选择器配置
props: {
lazy: true,
checkStrictly : true,
lazyLoad (node, resolve) {
const { level } = node;
var nodes=[]
var id=level===0?'3205':node.value;
getDeptLsitByDeptId(id).then(res=>{
var deptlist=res.data
if (deptlist.length>0){
deptlist.forEach((item)=>{
var obj={
value:item.deptId,
label:item.deptName,
leaf:node.length>=2
}
nodes.push(obj)
})
resolve(nodes)
}else{
resolve(nodes)
}
})
}
}
}
}
methods:{
//选中单位函数,选中是一个数组,var deptid 获取的是最后的部门id当搜索条件
handleChangeDept(value){
this.queryParams.uporgId=null
if (value.length>0){
var deptid=value[value.length-1]
this.queryParams.uporgId=deptid
}
},
}