伊利项目 小组添加成员搜索

This commit is contained in:
qinoy 2022-09-07 17:56:07 +08:00
parent 5d6f5a984a
commit 33b55a4631

View File

@ -126,8 +126,9 @@
pid: '',
searchUserName:'',
tempNodeArr: [],
expandKeys:[]
expandKeys:[],
treeNode: null,
treeResolve: null
}
},
methods: {
@ -281,6 +282,8 @@
//
data.data.pid = that.pid;
data.data.parentType = '';
that.treeNode = node;
that.treeResolve = resolve;
} else {
//
data.data.pid = node.data.id;
@ -326,11 +329,25 @@
console.log(error);
})
},
filterNode(value, data) {
debugger;
if (!value) return true;
filterNode(values, data) {
if (!values) return true;
//return data.name.indexOf(value) !== -1;
return value.data.pathIdList.indexOf(data.id) !== -1;
let tempIds = [];
values.forEach(value => {
if (value.data.pathIdList.indexOf(data.id) !== -1) {
let node = this.$refs.tree.getNode(data.id);
if (node) {
this.tempNodeArr.push(node);
}
}
value.data.pathIdList.forEach(pathId => {
if (tempIds.indexOf(pathId) === -1) {
tempIds.push(pathId)
}
});
// return value.data.pathIdList.indexOf(data.id) !== -1;
});
return tempIds.indexOf(data.id) !== -1;
},
searchUserNameFun(){
let that = this;
@ -343,28 +360,11 @@
}
}
awsuiAxios.post(data).then(ro => {
debugger;
// console.log('--------',ro)
let userIdArr = [...ro.data];
if (userIdArr.length) {
userIdArr.forEach(userid => {
let node = that.$refs.tree.getNode(userid);
//
if (node) {
that.$refs.tree.filter(node);
setTimeout(() => {
if (node && node.parent) {
if (!node.parent.expanded){
node.parent.expand();
}
}
},100);
that.tempNodeArr.push(node);
}else {
//
that.searchParentUserIdFun(userid,that.searchUserName);
}
});
//
that.searchParentUserIdFun(userIdArr,that.searchUserName);
}else {
that.$message({type:'warning',message:'查询的部门不存在,请检查输入的部门名称'});
}
@ -375,7 +375,7 @@
that.treeNode.childNodes = [];
that.loadNode(that.treeNode,that.treeResolve);
that.expandKeys = [];
if (that.tempNodeArr.length){
if (that.tempNodeArr?.length){
that.tempNodeArr.forEach(node => {
that.$refs.tree.remove(node);
})
@ -387,7 +387,6 @@
searchParentUserIdFun(userid,orgName){
debugger;
let that = this;
const data = {
url: 'jd',
@ -398,14 +397,18 @@
}
awsuiAxios.post(data)
.then(ro => {
console.log('父级部门',ro.data);
// console.log('',ro.data);
that.expandKeys = [...ro.data];
setTimeout(() => {
// that.$refs.orgTree.filter(orgName);
let node = that.$refs.tree.getNode(userid);
that.$refs.tree.filter(node);
that.tempNodeArr.push(node);
},100);
let tempNode = [];
userid.forEach(userId => {
let node = that.$refs.tree.getNode(userId);
tempNode.push(node);
that.tempNodeArr.push(node);
})
that.$refs.tree.filter(tempNode);
},600);
})
.catch(err => {
console.log(err);
@ -421,11 +424,19 @@
} else {//
}
},
watch: {
searchUserName(val) {
this.$refs.tree.filter(val);
}
},
searchUserName(newval, oldval) {
if (!newval) {
this.treeNode.childNodes = [];
this.loadNode(this.treeNode,this.treeResolve);
this.expandKeys = [];
if (this.tempNodeArr?.length){
this.tempNodeArr.forEach(node => {
this.$refs.tree.remove(node);
});
this.tempNodeArr.length = 0;
}
}
}
}
}
</script>