Showing
2 changed files
with
20 additions
and
10 deletions
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | const isUpdate = ref<boolean>(true); |
50 | 50 | const treeData = ref<TreeItem[]>([]); |
51 | 51 | const roleMenus = ref<string[]>([]); |
52 | - const allCheckedKeys = ref<string[]>(); | |
52 | + const allCheckedKeys = ref<string[]>([]); | |
53 | 53 | const roleHalfCheckedKeys = ref<string[]>([]); |
54 | 54 | const roleId = ref<string>(''); |
55 | 55 | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
... | ... | @@ -103,10 +103,8 @@ |
103 | 103 | |
104 | 104 | if (unref(isUpdate)) { |
105 | 105 | if (data.record) { |
106 | - // // 通过角色id去获取角色对应的菜单的ids | |
106 | + //通过角色id去获取角色对应的菜单的ids | |
107 | 107 | roleMenus.value = await getMenusIdsByRoleId(data.record.id); |
108 | - console.log(roleMenus.value); | |
109 | - console.log(treeData.value); | |
110 | 108 | treeData.value.map((m) => { |
111 | 109 | roleMenus.value.map((m1) => { |
112 | 110 | if (m.key === m1) { |
... | ... | @@ -116,8 +114,6 @@ |
116 | 114 | }); |
117 | 115 | console.log(roleMenus.value); |
118 | 116 | proxy.$refs.tree.setCheckedKeys(roleMenus.value); |
119 | - // console.log(roleMenus.value, 'roleMenus.value'); | |
120 | - // // TODO: 角色回显问题:待解决 | |
121 | 117 | roleId.value = data.record.id; |
122 | 118 | } |
123 | 119 | setFieldsValue({ |
... | ... | @@ -148,11 +144,23 @@ |
148 | 144 | } |
149 | 145 | } |
150 | 146 | // Tree check事件 |
151 | - const handleCheckClick = (checkedKeys: string[], { halfCheckedKeys }) => { | |
152 | - allCheckedKeys.value = [...checkedKeys, ...halfCheckedKeys]; | |
153 | - // 父节点 | |
154 | - roleHalfCheckedKeys.value = halfCheckedKeys; | |
147 | + const handleCheckClick = (_, e) => { | |
148 | + let nodes = e.checkedNodes; | |
149 | + let halfKeys = e.halfCheckedKeys; | |
150 | + nodes.map((node) => { | |
151 | + if (node.key != halfKeys[0] && halfKeys.length == []) { | |
152 | + allCheckedKeys.value.push(node.key); | |
153 | + } else { | |
154 | + allCheckedKeys.value.push(node.key); | |
155 | + } | |
156 | + }); | |
157 | + allCheckedKeys.value.push(...halfKeys); | |
155 | 158 | }; |
159 | + // const handleCheckClick = (checkedKeys: string[], { halfCheckedKeys }) => { | |
160 | + // allCheckedKeys.value = [...checkedKeys, ...halfCheckedKeys]; | |
161 | + // // 父节点 | |
162 | + // roleHalfCheckedKeys.value = halfCheckedKeys; | |
163 | + // }; | |
156 | 164 | |
157 | 165 | return { |
158 | 166 | allCheckedKeys, | ... | ... |