- 修改一下,更新功能
- 修复删除不更新
This commit is contained in:
parent
b95c61e2d9
commit
ebf3fcb752
@ -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,
|
||||
|
@ -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()}
|
||||
>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="类型">
|
||||
{form.getFieldDecorator('displayName', {
|
||||
rules: [{ required: true, message: '选择类型!', min: 2 }],
|
||||
{form.getFieldDecorator('type', {
|
||||
initialValue: initValues.type || 1,
|
||||
})(
|
||||
<RadioGroup>
|
||||
@ -76,7 +80,7 @@ const CreateForm = Form.create()(props => {
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="名称">
|
||||
{form.getFieldDecorator('type', {
|
||||
{form.getFieldDecorator('displayName', {
|
||||
rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }],
|
||||
initialValue: initValues.displayName,
|
||||
})(<Input placeholder="显示名称" />)}
|
||||
@ -207,21 +211,21 @@ class ResourceList extends PureComponent {
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'id',
|
||||
title: '编号',
|
||||
dataIndex: 'id',
|
||||
render: text => <strong>{text}</strong>,
|
||||
},
|
||||
{
|
||||
title: '显示名称',
|
||||
title: '显示名字',
|
||||
dataIndex: 'displayName',
|
||||
render: text => <a>{text}</a>,
|
||||
},
|
||||
{
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user