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,