From 8321e96b68537fb3d9fa54b2023cd09bef0a1c61 Mon Sep 17 00:00:00 2001 From: shidongli Date: Tue, 26 Nov 2024 16:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=91=E5=AE=A4=E4=BF=A1=E6=81=AF-=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E6=9C=BA=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/department/index.vue | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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;