From 755d94cbdcdecb9aea1c1718ab4f221dfec4cc22 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 15 May 2019 23:50:47 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=90=8E=E7=AB=AF=EF=BC=9A=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=A2=9E=E5=8A=A0=20icon?= =?UTF-8?q?=E3=80=81permissions=E3=80=81=E5=8E=BB=E9=99=A4=20name=20?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/src/locales/zh-CN/menu.js | 2 +- admin-web/src/pages/Admin/ResourceList.js | 121 +++++++++++------- .../vo/resource/ResourceTreeNodeVO.java | 20 +-- .../admin/api/bo/resource/ResourceBO.java | 4 + .../mall/admin/convert/ResourceConvert.java | 17 ++- .../mall/admin/dao/ResourceMapper.java | 13 +- .../mall/admin/dataobject/ResourceDO.java | 2 + .../mall/admin/service/OAuth2ServiceImpl.java | 3 +- .../admin/service/ResourceServiceImpl.java | 6 +- .../main/resources/mapper/ResourceMapper.xml | 44 +------ 10 files changed, 106 insertions(+), 126 deletions(-) diff --git a/admin-web/src/locales/zh-CN/menu.js b/admin-web/src/locales/zh-CN/menu.js index 849ae3b8c..0c549bcdd 100644 --- a/admin-web/src/locales/zh-CN/menu.js +++ b/admin-web/src/locales/zh-CN/menu.js @@ -41,7 +41,7 @@ export default { // admin 'menu.admin': '系统设置', 'menu.admin.admin-list': '管理员列表', - 'menu.admin.resource-list': '资源列表', + 'menu.admin.resource-list': '权限列表', 'menu.admin.role-list': '角色列表', 'menu.admin.dictionary-list': '数据字典', // 商品相关 diff --git a/admin-web/src/pages/Admin/ResourceList.js b/admin-web/src/pages/Admin/ResourceList.js index e2f9b7046..31fc8ca1d 100644 --- a/admin-web/src/pages/Admin/ResourceList.js +++ b/admin-web/src/pages/Admin/ResourceList.js @@ -15,6 +15,7 @@ import { TreeSelect, Radio, Divider, + Icon, InputNumber, } from 'antd'; import PageHeaderWrapper from '@/components/PageHeaderWrapper'; @@ -23,7 +24,8 @@ import styles from './ResourceList.less'; const RadioGroup = Radio.Group; const FormItem = Form.Item; const { Option } = Select; -const types = ['未知', '菜单', '链接']; +const TextArea = Input.TextArea; +const types = ['未知', '菜单', '按钮']; // 添加 form 表单 const CreateForm = Form.create()(props => { @@ -58,8 +60,15 @@ const CreateForm = Form.create()(props => { width: 200, }; - const title = modalType === 'add' ? '添加一个 Resource' : '更新一个 Resource'; - const okText = modalType === 'add' ? '添加' : '更新'; + function onTypeChange(event) { + initValues.type = parseInt(event.target.value); + } + + // 给 type 赋予初始值 + initValues.type = initValues.type || 1; + + const title = modalType === 'add' ? '添加一个权限' : '编辑一个权限'; + const okText = modalType === 'add' ? '添加' : '编辑'; return ( { > {form.getFieldDecorator('type', { - initialValue: initValues.type || 1, + initialValue: initValues.type, })( - + 菜单 按钮 @@ -81,28 +90,17 @@ const CreateForm = Form.create()(props => { {form.getFieldDecorator('displayName', { - rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }], + rules: [{ required: true, message: '请输入名称!', min: 2 }], initialValue: initValues.displayName, - })()} - - - {form.getFieldDecorator('name', { - rules: [{ required: true, message: '请输入资源名字!' }], - initialValue: initValues.name, - })()} - - - {form.getFieldDecorator('handler', { - initialValue: initValues.handler, - })()} + })()} {form.getFieldDecorator('pid', { - rules: [{ required: true, message: '请输入父级编号!' }], + rules: [{ required: true, message: '请选择父级编号!' }], initialValue: initValues.pid === 0 ? `根节点-${initValues.pid}` - : `${initValues.displayName}-${initValues.pid}`, + : initValues.pid ? `${initValues.displayName}-${initValues.pid}` : undefined, })( { /> )} - + {form.getFieldDecorator('sort', { - rules: [{ required: true, message: '请输入菜单排序!' }], + rules: [{ required: true, message: '请输入排序!' }], initialValue: initValues.sort, - })()} + })()} + + { + initValues.type === 1 ? ( + + {form.getFieldDecorator('icon', { + rules: [{ required: true, message: '请输入图标!' }], + initialValue: initValues.icon, + })()} + + ) : '' + } + { + initValues.type === 1 ? ( + + {form.getFieldDecorator('handler', { + initialValue: initValues.handler, + })()} + + ) : '' + } + + {form.getFieldDecorator('permissions', { + initialValue: initValues.permissions, + })(