diff --git a/src/views/system/department/index.vue b/src/views/system/department/index.vue index 6283cf8..d17938c 100644 --- a/src/views/system/department/index.vue +++ b/src/views/system/department/index.vue @@ -693,12 +693,46 @@ export default { this.single = selection.length !== 1; this.multiple = !selection.length; }, + getLeafIds(nodes) { + console.log(nodes,';node') + + this.form.hospitalAgencyIdtwo=JSON.parse(localStorage.getItem('user')).hospitalAgencyId; + + let leafIds = []; + nodes.forEach(node => { + + if(node.id==this.form.hospitalAgencyIdtwo){ + this.form.hospitalAgencyName=node.label; + + + }else{ + if (node.children) { + // 如果有子节点,递归调用getLeafIds + leafIds = leafIds.concat(this.getLeafIds(node.children)); + } else { + // 如果没有子节点,取当前节点的id + leafIds.push(node.id); + } + + } + + }); + return leafIds; + }, + /** 新增按钮操作 */ handleAdd() { + + this.getinfo() + this.reset(); this.open = true; this.title = "添加科室信息"; - this.getinfo() + if(localStorage.getItem('roleKey') !='admin'){ + this.getLeafIds(this.treeOptions) + + + } }, /** 修改按钮操作 */ handleUpdate(row) { @@ -730,6 +764,7 @@ export default { this.getList(); }); } else { + this.form.hospitalAgencyId=this.form.hospitalAgencyIdtwo addDepartment(this.form).then((response) => { this.$modal.msgSuccess("新增成功"); this.open = false;