考勤设置人员选择修改

This commit is contained in:
cwchen 2025-02-18 09:58:08 +08:00
parent 9f92711e34
commit 278381d134
1 changed files with 55 additions and 8 deletions

View File

@ -168,6 +168,7 @@
:options="personOptions"
:normalizer="normalizer"
placeholder="选择部门和人员"
value-consists-of="LEAF_PRIORITY"
@input="handleSelect"
/>
</el-form-item>
@ -601,8 +602,51 @@ export default {
});
return data;
},
handleSelect(value, instanceId) {
console.log("Selected:", value);
handleSelect(selectedNodes, instanceId) {
const lastSelectedNodeId = selectedNodes[selectedNodes.length - 1] // ID
const selectedNode = this.findNodeById(this.personOptions, lastSelectedNodeId) //
if (selectedNode && selectedNode.children) {
let childIds = this.getAllIds(selectedNode.children);
// ID
this.form.checkList = [...new Set([...this.form.checkList, ...childIds])];
} else {
// selectedNodes
this.form.checkList = [...new Set([...this.form.checkList, ...selectedNodes])];
}
this.form.checkList = this.form.checkList.filter(item => {
return item.indexOf('user') > -1;
});
// console.error(this.form.checkList);
},
findNodeById(nodes, id) {
for (const node of nodes) {
if (node.id === id) {
return node
}
if (node.children) {
const found = this.findNodeById(node.children, id)
if (found) {
return found
}
}
}
return null
},
// ID
getAllIds(list) {
return this.collectIds(list);
},
// ID
collectIds(nodes) {
let ids = [];
nodes.forEach((node) => {
ids.push(node.id); // ID
if (node.children && node.children.length > 0) {
//
ids = ids.concat(this.collectIds(node.children));
}
});
return ids;
},
/** 转换部门数据结构 */
@ -756,6 +800,7 @@ export default {
this.personOptions = this.changeData(this.form.treeList);
this.form.checkList = [];
this.setCheck(this.form.treeList);
this.form.checkList = [...new Set([...this.form.checkList])];
// console.log(this.form)
this.open = true;
this.title = "编辑";
@ -785,18 +830,20 @@ export default {
this.form.attDay = arr.join(",");
let arr2 = [];
this.form.checkList.forEach((item) => {
if (item.indexOf("|") > -1) {
if (item.indexOf("|") > -1 && item.split('|')[0] === 'user') {
let obj = {
orgId: item.split("|")[1],
userId: item.split("|")[0],
// orgId: item.split("|")[1],
// userId: item.split("|")[0],
orgId: '',
userId: item.split('|')[1]
};
arr2.push(obj);
} else {
let obj = {
/* let obj = {
orgId: item,
userId: "",
};
arr2.push(obj);
}; */
// arr2.push(obj);
}
});
this.form.checkOrgList = arr2;