|
|
@@ -1,7 +1,7 @@ |
|
|
import { DictValueEnumObj } from '@/components/DictTag'; |
|
|
import { DictValueEnumObj } from '@/components/DictTag'; |
|
|
import IconSelector from '@/components/IconSelector'; |
|
|
|
|
|
import KFModal from '@/components/KFModal'; |
|
|
import KFModal from '@/components/KFModal'; |
|
|
import { createIcon } from '@/utils/IconUtil'; |
|
|
|
|
|
|
|
|
import MenuIconSelector from '@/components/MenuIconSelector'; |
|
|
|
|
|
import { openAntdModal } from '@/utils/modal'; |
|
|
import { |
|
|
import { |
|
|
ProForm, |
|
|
ProForm, |
|
|
ProFormDigit, |
|
|
ProFormDigit, |
|
|
@@ -27,31 +27,39 @@ export type MenuFormProps = { |
|
|
menuTree: DataNode[]; |
|
|
menuTree: DataNode[]; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const formLayout = { |
|
|
|
|
|
labelCol: { span: 8 }, |
|
|
|
|
|
wrapperCol: { span: 16 }, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const formItemLayout = { |
|
|
|
|
|
labelCol: { span: 4 }, |
|
|
|
|
|
wrapperCol: { span: 20 }, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
|
const [menuTypeId, setMenuTypeId] = useState<any>('M'); |
|
|
|
|
|
|
|
|
const [menuTypeId, setMenuTypeId] = useState<any>(); |
|
|
const [menuIconName, setMenuIconName] = useState<any>(); |
|
|
const [menuIconName, setMenuIconName] = useState<any>(); |
|
|
const [iconSelectorOpen, setIconSelectorOpen] = useState<boolean>(false); |
|
|
|
|
|
|
|
|
|
|
|
const { menuTree, visibleOptions, statusOptions } = props; |
|
|
const { menuTree, visibleOptions, statusOptions } = props; |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
form.resetFields(); |
|
|
form.resetFields(); |
|
|
setMenuIconName(props.values.icon); |
|
|
setMenuIconName(props.values.icon); |
|
|
|
|
|
setMenuTypeId(props.values.menuType ?? 'M'); |
|
|
form.setFieldsValue({ |
|
|
form.setFieldsValue({ |
|
|
menuId: props.values.menuId, |
|
|
menuId: props.values.menuId, |
|
|
menuName: props.values.menuName, |
|
|
menuName: props.values.menuName, |
|
|
parentId: props.values.parentId, |
|
|
|
|
|
orderNum: props.values.orderNum, |
|
|
|
|
|
|
|
|
parentId: props.values.parentId ?? 0, |
|
|
|
|
|
orderNum: props.values.orderNum ?? 1, |
|
|
path: props.values.path, |
|
|
path: props.values.path, |
|
|
component: props.values.component, |
|
|
component: props.values.component, |
|
|
query: props.values.query, |
|
|
query: props.values.query, |
|
|
isFrame: props.values.isFrame, |
|
|
|
|
|
isCache: props.values.isCache, |
|
|
|
|
|
menuType: props.values.menuType, |
|
|
|
|
|
visible: props.values.visible, |
|
|
|
|
|
status: props.values.status, |
|
|
|
|
|
|
|
|
isFrame: props.values.isFrame ?? '1', |
|
|
|
|
|
isCache: props.values.isCache ?? '1', |
|
|
|
|
|
menuType: props.values.menuType ?? 'M', |
|
|
|
|
|
visible: props.values.visible ?? Object.keys(visibleOptions)[0], |
|
|
|
|
|
status: props.values.status ?? Object.keys(statusOptions)[0], |
|
|
perms: props.values.perms, |
|
|
perms: props.values.perms, |
|
|
icon: props.values.icon, |
|
|
icon: props.values.icon, |
|
|
createBy: props.values.createBy, |
|
|
createBy: props.values.createBy, |
|
|
@@ -73,9 +81,20 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
props.onSubmit(values as MenuFormData); |
|
|
props.onSubmit(values as MenuFormData); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const selectIcon = () => { |
|
|
|
|
|
const { close } = openAntdModal(MenuIconSelector, { |
|
|
|
|
|
selectedIcon: menuIconName, |
|
|
|
|
|
onOk: (icon) => { |
|
|
|
|
|
setMenuIconName(icon); |
|
|
|
|
|
form.setFieldsValue({ icon }); |
|
|
|
|
|
close(); |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<KFModal |
|
|
<KFModal |
|
|
width={640} |
|
|
|
|
|
|
|
|
width={680} |
|
|
title={intl.formatMessage({ |
|
|
title={intl.formatMessage({ |
|
|
id: 'system.menu.title', |
|
|
id: 'system.menu.title', |
|
|
defaultMessage: '编辑菜单权限', |
|
|
defaultMessage: '编辑菜单权限', |
|
|
@@ -92,6 +111,8 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
submitter={false} |
|
|
submitter={false} |
|
|
layout="horizontal" |
|
|
layout="horizontal" |
|
|
onFinish={handleFinish} |
|
|
onFinish={handleFinish} |
|
|
|
|
|
{...formLayout} |
|
|
|
|
|
size="large" |
|
|
> |
|
|
> |
|
|
<ProFormDigit |
|
|
<ProFormDigit |
|
|
name="menuId" |
|
|
name="menuId" |
|
|
@@ -110,6 +131,7 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
]} |
|
|
]} |
|
|
/> |
|
|
/> |
|
|
<ProFormTreeSelect |
|
|
<ProFormTreeSelect |
|
|
|
|
|
{...formItemLayout} |
|
|
name="parentId" |
|
|
name="parentId" |
|
|
label={intl.formatMessage({ |
|
|
label={intl.formatMessage({ |
|
|
id: 'system.menu.parent_id', |
|
|
id: 'system.menu.parent_id', |
|
|
@@ -128,11 +150,9 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
), |
|
|
), |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
|
|
|
defaultValue: 0, |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
/> |
|
|
<ProFormRadio.Group |
|
|
<ProFormRadio.Group |
|
|
|
|
|
{...formItemLayout} |
|
|
name="menuType" |
|
|
name="menuType" |
|
|
valueEnum={{ |
|
|
valueEnum={{ |
|
|
M: '目录', |
|
|
M: '目录', |
|
|
@@ -151,13 +171,13 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
fieldProps={{ |
|
|
defaultValue: 'M', |
|
|
|
|
|
onChange: (e) => { |
|
|
onChange: (e) => { |
|
|
setMenuTypeId(e.target.value); |
|
|
setMenuTypeId(e.target.value); |
|
|
}, |
|
|
}, |
|
|
}} |
|
|
}} |
|
|
/> |
|
|
/> |
|
|
<ProFormSelect |
|
|
<ProFormSelect |
|
|
|
|
|
{...formItemLayout} |
|
|
name="icon" |
|
|
name="icon" |
|
|
label={intl.formatMessage({ |
|
|
label={intl.formatMessage({ |
|
|
id: 'system.menu.icon', |
|
|
id: 'system.menu.icon', |
|
|
@@ -165,10 +185,10 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
})} |
|
|
})} |
|
|
valueEnum={{}} |
|
|
valueEnum={{}} |
|
|
hidden={menuTypeId === 'F'} |
|
|
hidden={menuTypeId === 'F'} |
|
|
addonBefore={createIcon(menuIconName)} |
|
|
|
|
|
|
|
|
// addonBefore={createIcon(menuIconName)} |
|
|
fieldProps={{ |
|
|
fieldProps={{ |
|
|
onClick: () => { |
|
|
onClick: () => { |
|
|
setIconSelectorOpen(true); |
|
|
|
|
|
|
|
|
selectIcon(); |
|
|
}, |
|
|
}, |
|
|
}} |
|
|
}} |
|
|
placeholder="请输入菜单图标" |
|
|
placeholder="请输入菜单图标" |
|
|
@@ -209,9 +229,6 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
message: <FormattedMessage id="请输入显示顺序!" defaultMessage="请输入显示顺序!" />, |
|
|
message: <FormattedMessage id="请输入显示顺序!" defaultMessage="请输入显示顺序!" />, |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
|
|
|
defaultValue: 1, |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
/> |
|
|
<ProFormRadio.Group |
|
|
<ProFormRadio.Group |
|
|
name="isFrame" |
|
|
name="isFrame" |
|
|
@@ -219,7 +236,6 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
0: '是', |
|
|
0: '是', |
|
|
1: '否', |
|
|
1: '否', |
|
|
}} |
|
|
}} |
|
|
initialValue="1" |
|
|
|
|
|
label={intl.formatMessage({ |
|
|
label={intl.formatMessage({ |
|
|
id: 'system.menu.is_frame', |
|
|
id: 'system.menu.is_frame', |
|
|
defaultMessage: '是否为外链', |
|
|
defaultMessage: '是否为外链', |
|
|
@@ -235,9 +251,6 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
), |
|
|
), |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
|
|
|
defaultValue: '1', |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
/> |
|
|
<ProFormText |
|
|
<ProFormText |
|
|
name="path" |
|
|
name="path" |
|
|
@@ -323,9 +336,6 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
message: <FormattedMessage id="请输入是否缓存!" defaultMessage="请输入是否缓存!" />, |
|
|
message: <FormattedMessage id="请输入是否缓存!" defaultMessage="请输入是否缓存!" />, |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
|
|
|
defaultValue: 0, |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
/> |
|
|
<ProFormRadio.Group |
|
|
<ProFormRadio.Group |
|
|
name="visible" |
|
|
name="visible" |
|
|
@@ -343,9 +353,6 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
message: <FormattedMessage id="请输入显示状态!" defaultMessage="请输入显示状态!" />, |
|
|
message: <FormattedMessage id="请输入显示状态!" defaultMessage="请输入显示状态!" />, |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
|
|
|
defaultValue: '0', |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
/> |
|
|
<ProFormRadio.Group |
|
|
<ProFormRadio.Group |
|
|
valueEnum={statusOptions} |
|
|
valueEnum={statusOptions} |
|
|
@@ -363,27 +370,8 @@ const MenuForm: React.FC<MenuFormProps> = (props) => { |
|
|
message: <FormattedMessage id="请输入菜单状态!" defaultMessage="请输入菜单状态!" />, |
|
|
message: <FormattedMessage id="请输入菜单状态!" defaultMessage="请输入菜单状态!" />, |
|
|
}, |
|
|
}, |
|
|
]} |
|
|
]} |
|
|
fieldProps={{ |
|
|
|
|
|
defaultValue: '0', |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
/> |
|
|
</ProForm> |
|
|
</ProForm> |
|
|
<KFModal |
|
|
|
|
|
width={800} |
|
|
|
|
|
open={iconSelectorOpen} |
|
|
|
|
|
onCancel={() => { |
|
|
|
|
|
setIconSelectorOpen(false); |
|
|
|
|
|
}} |
|
|
|
|
|
footer={null} |
|
|
|
|
|
> |
|
|
|
|
|
<IconSelector |
|
|
|
|
|
onSelect={(name: string) => { |
|
|
|
|
|
form.setFieldsValue({ icon: name }); |
|
|
|
|
|
setMenuIconName(name); |
|
|
|
|
|
setIconSelectorOpen(false); |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
</KFModal> |
|
|
|
|
|
</KFModal> |
|
|
</KFModal> |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|
|