Browse Source

🎨 修复菜单授权bug

master
wangxiang 3 years ago
parent
commit
4d577b2473
  1. 1
      src/components/Form/src/components/RadioButtonGroup.vue
  2. 19
      src/views/system/menu/MenuModal.vue

1
src/components/Form/src/components/RadioButtonGroup.vue

@ -37,6 +37,7 @@
}, },
setup(props) { setup(props) {
const attrs = useAttrs(); const attrs = useAttrs();
console.log('村上春树', attrs);
// Embedded in the form, just use the hook binding to perform form verification // Embedded in the form, just use the hook binding to perform form verification
const [state] = useRuleFormItem(props); const [state] = useRuleFormItem(props);

19
src/views/system/menu/MenuModal.vue

@ -14,7 +14,7 @@
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. * Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔 * author entfrm开发团队-王翔
*/ */
import { ref, unref, reactive, toRaw } from 'vue'; import { reactive, toRaw } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index'; import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './menu.data'; import { formSchema } from './menu.data';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
@ -26,8 +26,6 @@
tag: '', tag: '',
menuTree: [] menuTree: []
}); });
const tag = ref<Nullable<string>>('');
const menuTree = ref<Recordable[]>([]);
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ /** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate, clearValidate }] = useForm({ const [registerForm, { resetFields, setFieldsValue, updateSchema, validate, clearValidate }] = useForm({
@ -41,20 +39,25 @@
await resetFields(); await resetFields();
await clearValidate(); await clearValidate();
// //
tag.value = data._tag; state.tag = data._tag;
const topMenu = { id: '0', name: '顶级菜单', children: [] }; const topMenu = { id: '0', name: '顶级菜单', children: [] };
state.menuTree = listToTree(await listMenu()); state.menuTree = listToTree(await listMenu());
topMenu.children = state.menuTree; topMenu.children = state.menuTree;
await updateSchema({ await updateSchema([{
field: 'parentId', field: 'parentId',
componentProps: { componentProps: {
treeData: [topMenu] treeData: [topMenu]
} }
}); }, {
field: 'type',
componentProps: {
disabled: state.tag == 'edit'
}
}]);
const menuId = data.record?.id; const menuId = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false }; const props: Partial<ModalProps> = { confirmLoading: false };
// tag // tag
switch (unref(tag)) { switch (state.tag) {
case 'add': case 'add':
props.title = '新增菜单'; props.title = '新增菜单';
menuId && await setFieldsValue({ parentId: menuId }); menuId && await setFieldsValue({ parentId: menuId });
@ -76,7 +79,7 @@
// //
setModalProps({ confirmLoading: true }); setModalProps({ confirmLoading: true });
// tag // tag
switch (unref(tag)) { switch (state.tag) {
case 'add': case 'add':
// //
const superMenus = findPath(toRaw(state.menuTree),(node) => node.id == formData?.parentId); const superMenus = findPath(toRaw(state.menuTree),(node) => node.id == formData?.parentId);

Loading…
Cancel
Save