- 修改一下,更新功能

- 修复删除不更新
This commit is contained in:
sin 2019-05-04 14:46:11 +08:00
parent b95c61e2d9
commit ebf3fcb752
2 changed files with 28 additions and 15 deletions

View File

@ -9,7 +9,7 @@ const buildSelectTree = list => {
} }
return { return {
title: item.displayName, title: item.displayName,
value: item.displayName, value: `${item.displayName}-${item.id}`,
key: item.id, key: item.id,
children, children,
}; };
@ -48,13 +48,11 @@ export default {
}); });
}, },
*delete({ payload }, { call, put }) { *delete({ payload }, { call, put }) {
const response = yield call(deleteResource, payload); yield call(deleteResource, payload);
message.info('删除成功!'); message.info('删除成功!');
yield put({ yield put({
type: 'treeSuccess', type: 'tree',
payload: { payload: {},
list: response.data,
},
}); });
}, },
*tree({ payload }, { call, put }) { *tree({ payload }, { call, put }) {
@ -71,7 +69,18 @@ export default {
reducers: { reducers: {
treeSuccess(state, { payload }) { treeSuccess(state, { payload }) {
const resultData = 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 { return {
...state, ...state,
list: resultData, list: resultData,

View File

@ -40,6 +40,11 @@ const CreateForm = Form.create()(props => {
const okHandle = () => { const okHandle = () => {
form.validateFields((err, fieldsValue) => { form.validateFields((err, fieldsValue) => {
if (err) return; if (err) return;
let pid = fieldsValue.pid;
if (fieldsValue.pid) {
pid = pid.split('-')[1];
fieldsValue.pid = pid;
}
form.resetFields(); form.resetFields();
handleAdd({ handleAdd({
fields: fieldsValue, fields: fieldsValue,
@ -65,8 +70,7 @@ const CreateForm = Form.create()(props => {
onCancel={() => handleModalVisible()} onCancel={() => handleModalVisible()}
> >
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="类型"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="类型">
{form.getFieldDecorator('displayName', { {form.getFieldDecorator('type', {
rules: [{ required: true, message: '选择类型!', min: 2 }],
initialValue: initValues.type || 1, initialValue: initValues.type || 1,
})( })(
<RadioGroup> <RadioGroup>
@ -76,7 +80,7 @@ const CreateForm = Form.create()(props => {
)} )}
</FormItem> </FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="名称"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="名称">
{form.getFieldDecorator('type', { {form.getFieldDecorator('displayName', {
rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }], rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }],
initialValue: initValues.displayName, initialValue: initValues.displayName,
})(<Input placeholder="显示名称" />)} })(<Input placeholder="显示名称" />)}
@ -207,21 +211,21 @@ class ResourceList extends PureComponent {
const columns = [ const columns = [
{ {
title: 'id', title: '编号',
dataIndex: 'id', dataIndex: 'id',
render: text => <strong>{text}</strong>, render: text => <strong>{text}</strong>,
}, },
{ {
title: '显示名', title: '显示名',
dataIndex: 'displayName', dataIndex: 'displayName',
render: text => <a>{text}</a>, render: text => <a>{text}</a>,
}, },
{ {
title: '名称', title: '菜单KEY',
dataIndex: 'name', dataIndex: 'name',
}, },
{ {
title: 'pid', title: '父级编号',
dataIndex: 'pid', dataIndex: 'pid',
sorter: true, sorter: true,
render: val => `${val}`, render: val => `${val}`,
@ -234,7 +238,7 @@ class ResourceList extends PureComponent {
}, },
}, },
{ {
title: '资源地址', title: '菜单/操作',
dataIndex: 'handler', dataIndex: 'handler',
sorter: true, sorter: true,
width: 300, width: 300,