This commit is contained in:
parent
1cff4203b1
commit
5472b1417b
|
|
@ -371,6 +371,11 @@ export default {
|
|||
components: {Treeselect},
|
||||
data() {
|
||||
return {
|
||||
// 1. 存储选中的部门ID(关键)
|
||||
selectedDeptId: undefined,
|
||||
// 2. 存储选中的部门名称(可选,用于回显更友好)
|
||||
selectedDeptName: '',
|
||||
// ... 其他原有变量
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
|
|
@ -556,6 +561,8 @@ export default {
|
|||
// 节点单击事件
|
||||
handleNodeClick(data) {
|
||||
this.queryParams.deptId = data.id
|
||||
this.selectedDeptId = data.id; // 保存ID
|
||||
this.selectedDeptName = data.label; // 保存名称(可选)
|
||||
this.handleQuery()
|
||||
},
|
||||
//用户审批状态修改
|
||||
|
|
@ -614,6 +621,9 @@ export default {
|
|||
this.dateRange = []
|
||||
this.resetForm('queryForm')
|
||||
this.queryParams.deptId = undefined
|
||||
this.selectedDeptId = undefined; // 清空ID
|
||||
this.selectedDeptName = ''; // 清空名称
|
||||
|
||||
this.$refs.tree.setCurrentKey(null)
|
||||
this.handleQuery()
|
||||
},
|
||||
|
|
@ -654,6 +664,14 @@ export default {
|
|||
this.open = true
|
||||
this.title = '添加用户'
|
||||
this.form.password = this.initPassword
|
||||
// 核心:给form.deptId赋值选中的部门ID(treeselect会自动匹配显示)
|
||||
if (this.selectedDeptId) {
|
||||
this.form.deptId = this.selectedDeptId;
|
||||
// 强制触发响应式更新(解决偶发的treeselect不回显问题)
|
||||
this.$nextTick(() => {
|
||||
this.$forceUpdate();
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue