Commit f69b51d7f2ab564449c1a8b674565abbf7bcea4f

Authored by ww
1 parent 9e531f47

fix: 修复角色创建菜单勾选全部无效

@@ -51,14 +51,6 @@ @@ -51,14 +51,6 @@
51 'update:searchValue', 51 'update:searchValue',
52 ], 52 ],
53 setup(props, { attrs, slots, emit, expose }) { 53 setup(props, { attrs, slots, emit, expose }) {
54 - // /**  
55 - // * 作者自带Tree组件  
56 - // * 新增显示隐藏  
57 - // * ft  
58 - // */  
59 - // //ft  
60 - // const isFlod = ref(false);  
61 - //ft  
62 const state = reactive<State>({ 54 const state = reactive<State>({
63 checkStrictly: props.checkStrictly, 55 checkStrictly: props.checkStrictly,
64 expandedKeys: props.expandedKeys || [], 56 expandedKeys: props.expandedKeys || [],
@@ -152,12 +152,14 @@ @@ -152,12 +152,14 @@
152 const { createMessage } = useMessage(); 152 const { createMessage } = useMessage();
153 try { 153 try {
154 const values = await validate(); 154 const values = await validate();
  155 + const treeCheckedKeys: string[] = (unref(treeRef)?.getCheckedKeys() as string[]) || [];
  156 + const menu = [...new Set([...unref(checkedKeysWithHalfChecked), ...treeCheckedKeys])];
155 const req = { 157 const req = {
156 id: roleId.value, 158 id: roleId.value,
157 name: values.name, 159 name: values.name,
158 remark: values.remark, 160 remark: values.remark,
159 status: values.status, 161 status: values.status,
160 - menu: unref(checkedKeysWithHalfChecked), 162 + menu,
161 }; 163 };
162 if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); 164 if (req.menu == undefined) return createMessage.error('请勾选权限菜单');
163 saveOrUpdateRoleInfoWithMenu(req).then(() => { 165 saveOrUpdateRoleInfoWithMenu(req).then(() => {
@@ -131,6 +131,8 @@ @@ -131,6 +131,8 @@
131 async function handleSubmit() { 131 async function handleSubmit() {
132 setDrawerProps({ loading: true, confirmLoading: true }); 132 setDrawerProps({ loading: true, confirmLoading: true });
133 const { createMessage } = useMessage(); 133 const { createMessage } = useMessage();
  134 + const treeCheckedKeys: string[] = (unref(treeRef)?.getCheckedKeys() as string[]) || [];
  135 + const menu = [...new Set([...unref(checkedKeysWithHalfChecked), ...treeCheckedKeys])];
134 try { 136 try {
135 const values = await validate(); 137 const values = await validate();
136 const req = { 138 const req = {
@@ -139,7 +141,7 @@ @@ -139,7 +141,7 @@
139 remark: values.remark, 141 remark: values.remark,
140 status: values.status, 142 status: values.status,
141 roleType: RoleEnum.TENANT_ADMIN, 143 roleType: RoleEnum.TENANT_ADMIN,
142 - menu: unref(checkedKeysWithHalfChecked), 144 + menu,
143 }; 145 };
144 if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); 146 if (req.menu == undefined) return createMessage.error('请勾选权限菜单');
145 const res = await saveOrUpdateRoleInfoWithMenu(req); 147 const res = await saveOrUpdateRoleInfoWithMenu(req);