|
|
/**
|
|
|
* 下拉树组件
|
|
|
*/
|
|
|
export default {
|
|
|
name: 'treeSelect',
|
|
|
template: '',
|
|
|
components: {},
|
|
|
props: {
|
|
|
|
|
|
// 选中的值
|
|
|
value: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
},
|
|
|
// 数据
|
|
|
data: {
|
|
|
type: Array,
|
|
|
default: []
|
|
|
},
|
|
|
//显示的提示语
|
|
|
placeholderText:{
|
|
|
type: String,
|
|
|
default: '请选择'
|
|
|
},
|
|
|
//指定标签,子树节点
|
|
|
defaultProps:{
|
|
|
type:Object,
|
|
|
default:{
|
|
|
children: 'children',
|
|
|
label: 'name',
|
|
|
value: 'value'
|
|
|
}
|
|
|
},
|
|
|
//唯一标识
|
|
|
nodeKey:{
|
|
|
type: String,
|
|
|
default: 'id'
|
|
|
},
|
|
|
//是否有标签
|
|
|
isTag:{
|
|
|
type:Boolean,
|
|
|
default:false
|
|
|
},
|
|
|
//是否可搜索
|
|
|
filterable:{
|
|
|
type:Boolean,
|
|
|
default:false
|
|
|
}
|
|
|
|
|
|
},
|
|
|
data() {
|
|
|
return {}
|
|
|
},
|
|
|
setup(props, {attrs, slots, emit}) {
|
|
|
const {proxy} = Vue.getCurrentInstance();
|
|
|
let data=Vue.ref([]);
|
|
|
let change=(val)=>{
|
|
|
emit("changeSelect",val)
|
|
|
}
|
|
|
//获取菜单类型
|
|
|
let getTypeName=(type)=>{
|
|
|
switch (type) {
|
|
|
case 'org':
|
|
|
return '部门';
|
|
|
case 'user':
|
|
|
return '用户';
|
|
|
default:
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
let init=()=>{
|
|
|
//lsq 部门数据 2022-09-05
|
|
|
proxy.$http.get(`/api-user/org/queryOrgs`, {}, function (res) {
|
|
|
if(res && res.data){
|
|
|
data.value = res.data;
|
|
|
data.value.map(item=>{
|
|
|
item.type='org'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
let id = 0
|
|
|
|
|
|
const load = (node, resolve) => {
|
|
|
if (node.isLeaf) return resolve([])
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
proxy.$http.get(`/api-user/users/getAll`, {}, function (res) {
|
|
|
let arr=[];
|
|
|
if(res && res.data){
|
|
|
arr= res.data;
|
|
|
}
|
|
|
if(arr.length>0){
|
|
|
arr.map(item=>{
|
|
|
item.name=item.nickName;
|
|
|
item.type='user'
|
|
|
})
|
|
|
}
|
|
|
resolve(arr)
|
|
|
})
|
|
|
/*resolve([
|
|
|
{
|
|
|
value: ++id,
|
|
|
label: `lazy load node${id}`,
|
|
|
},
|
|
|
{
|
|
|
value: ++id,
|
|
|
label: `lazy load node${id}`,
|
|
|
isLeaf: true,
|
|
|
},
|
|
|
])*/
|
|
|
}, 400)
|
|
|
}
|
|
|
// 监听编辑状态
|
|
|
Vue.watch(() => props.value, (newValue, oldVlaue) => {
|
|
|
// 编辑
|
|
|
});
|
|
|
// 挂载完
|
|
|
Vue.onMounted(() => {
|
|
|
init()
|
|
|
})
|
|
|
return {
|
|
|
data,
|
|
|
change,
|
|
|
getTypeName,
|
|
|
init,
|
|
|
load
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|