From ebf3fcb7521791fcf3d1886f1c6ce37c49efd5dd Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Sat, 4 May 2019 14:46:11 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD=20-=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=88=A0=E9=99=A4=E4=B8=8D=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/src/models/admin/resourceList.js | 23 +++++++++++++++------- admin-web/src/pages/Admin/ResourceList.js | 20 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/admin-web/src/models/admin/resourceList.js b/admin-web/src/models/admin/resourceList.js index f83c62100..160ed357d 100644 --- a/admin-web/src/models/admin/resourceList.js +++ b/admin-web/src/models/admin/resourceList.js @@ -9,7 +9,7 @@ const buildSelectTree = list => { } return { title: item.displayName, - value: item.displayName, + value: `${item.displayName}-${item.id}`, key: item.id, children, }; @@ -48,13 +48,11 @@ export default { }); }, *delete({ payload }, { call, put }) { - const response = yield call(deleteResource, payload); + yield call(deleteResource, payload); message.info('删除成功!'); yield put({ - type: 'treeSuccess', - payload: { - list: response.data, - }, + type: 'tree', + payload: {}, }); }, *tree({ payload }, { call, put }) { @@ -71,7 +69,18 @@ export default { reducers: { treeSuccess(state, { payload }) { const resultData = payload; - const selectTree = buildSelectTree(resultData); + const treeData = buildSelectTree(resultData); + + const rootNode = [ + { + title: '根节点', + value: `根节点-0`, + key: 0, + children: [], + }, + ]; + + const selectTree = rootNode.concat(treeData); return { ...state, list: resultData, diff --git a/admin-web/src/pages/Admin/ResourceList.js b/admin-web/src/pages/Admin/ResourceList.js index d7e3159d2..20aeb09d3 100644 --- a/admin-web/src/pages/Admin/ResourceList.js +++ b/admin-web/src/pages/Admin/ResourceList.js @@ -40,6 +40,11 @@ const CreateForm = Form.create()(props => { const okHandle = () => { form.validateFields((err, fieldsValue) => { if (err) return; + let pid = fieldsValue.pid; + if (fieldsValue.pid) { + pid = pid.split('-')[1]; + fieldsValue.pid = pid; + } form.resetFields(); handleAdd({ fields: fieldsValue, @@ -65,8 +70,7 @@ const CreateForm = Form.create()(props => { onCancel={() => handleModalVisible()} > - {form.getFieldDecorator('displayName', { - rules: [{ required: true, message: '选择类型!', min: 2 }], + {form.getFieldDecorator('type', { initialValue: initValues.type || 1, })( @@ -76,7 +80,7 @@ const CreateForm = Form.create()(props => { )} - {form.getFieldDecorator('type', { + {form.getFieldDecorator('displayName', { rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }], initialValue: initValues.displayName, })()} @@ -207,21 +211,21 @@ class ResourceList extends PureComponent { const columns = [ { - title: 'id', + title: '编号', dataIndex: 'id', render: text => {text}, }, { - title: '显示名称', + title: '显示名字', dataIndex: 'displayName', render: text => {text}, }, { - title: '名称', + title: '菜单KEY', dataIndex: 'name', }, { - title: 'pid', + title: '父级编号', dataIndex: 'pid', sorter: true, render: val => `${val}`, @@ -234,7 +238,7 @@ class ResourceList extends PureComponent { }, }, { - title: '资源地址', + title: '菜单/操作', dataIndex: 'handler', sorter: true, width: 300,