1. system 提供新的 Resource 相关接口
2. admin-web 接入新的 Resource 相关接口
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { message } from 'antd';
|
||||
import { addResource, updateResource, deleteResource, resourceTree } from '../../services/admin';
|
||||
import { resourceTree, resourceAdd, resourceUpdate, resourceDelete } from '../../services/system';
|
||||
|
||||
const buildSelectTree = list => {
|
||||
return list.map(item => {
|
||||
@@ -8,8 +8,8 @@ const buildSelectTree = list => {
|
||||
children = buildSelectTree(item.children);
|
||||
}
|
||||
return {
|
||||
title: item.displayName,
|
||||
value: `${item.displayName}-${item.id}`,
|
||||
title: item.name,
|
||||
value: `${item.name}-${item.id}`,
|
||||
key: item.id,
|
||||
children,
|
||||
};
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
effects: {
|
||||
*add({ payload }, { call, put }) {
|
||||
const { callback, body } = payload;
|
||||
const response = yield call(addResource, body);
|
||||
const response = yield call(resourceAdd, body);
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export default {
|
||||
},
|
||||
*update({ payload }, { call, put }) {
|
||||
const { callback, body } = payload;
|
||||
const response = yield call(updateResource, body);
|
||||
const response = yield call(resourceUpdate, body);
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export default {
|
||||
});
|
||||
},
|
||||
*delete({ payload }, { call, put }) {
|
||||
yield call(deleteResource, payload);
|
||||
yield call(resourceDelete, payload);
|
||||
message.info('删除成功!');
|
||||
yield put({
|
||||
type: 'tree',
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
const resultData = payload;
|
||||
const treeData = buildSelectTree(resultData);
|
||||
|
||||
// value 要保护 displayName 不然,搜索会失效
|
||||
// value 要保护 name 不然,搜索会失效
|
||||
const rootNode = [
|
||||
{
|
||||
title: '根节点',
|
||||
|
||||
@@ -89,9 +89,9 @@ const CreateForm = Form.create()(props => {
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="名称">
|
||||
{form.getFieldDecorator('displayName', {
|
||||
{form.getFieldDecorator('name', {
|
||||
rules: [{ required: true, message: '请输入名称!', min: 2 }],
|
||||
initialValue: initValues.displayName,
|
||||
initialValue: initValues.name,
|
||||
})(<Input placeholder="名称" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="父级菜单">
|
||||
@@ -99,8 +99,8 @@ const CreateForm = Form.create()(props => {
|
||||
rules: [{ required: true, message: '请选择父级编号!' }],
|
||||
initialValue:
|
||||
initValues.pid === 0
|
||||
? `根节点-${initValues.pid}`
|
||||
: initValues.pid ? `${initValues.displayName}-${initValues.pid}` : undefined,
|
||||
? `根节点`
|
||||
: initValues.pid ? `${initValues.name}` : undefined,
|
||||
})(
|
||||
<TreeSelect
|
||||
showSearch
|
||||
@@ -129,17 +129,17 @@ const CreateForm = Form.create()(props => {
|
||||
}
|
||||
{
|
||||
initValues.type === 1 ? (
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="操作">
|
||||
{form.getFieldDecorator('handler', {
|
||||
initialValue: initValues.handler,
|
||||
})(<Input placeholder="操作" />)}
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="路由">
|
||||
{form.getFieldDecorator('route', {
|
||||
initialValue: initValues.route,
|
||||
})(<Input placeholder="路由" />)}
|
||||
</FormItem>
|
||||
) : ''
|
||||
}
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="权限标识">
|
||||
{form.getFieldDecorator('permissions', {
|
||||
initialValue: initValues.permissions,
|
||||
})(<TextArea placeholder="多个用逗号进行分割,例如:system.admin.add,system.admin.update" />)}
|
||||
{form.getFieldDecorator('permission', {
|
||||
initialValue: initValues.permission,
|
||||
})(<Input placeholder="多个用逗号进行分割,例如:system.admin.add,system.admin.update" />)}
|
||||
</FormItem>
|
||||
</Modal>
|
||||
);
|
||||
@@ -210,7 +210,7 @@ class ResourceList extends PureComponent {
|
||||
const { dispatch } = this.props;
|
||||
Modal.confirm({
|
||||
title: `确认删除?`,
|
||||
content: `${row.displayName}`,
|
||||
content: `${row.name}`,
|
||||
onOk() {
|
||||
dispatch({
|
||||
type: 'resourceList/delete',
|
||||
@@ -237,7 +237,7 @@ class ResourceList extends PureComponent {
|
||||
const columns = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'displayName',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: '图标',
|
||||
@@ -256,27 +256,16 @@ class ResourceList extends PureComponent {
|
||||
dataIndex: 'sort',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'handler',
|
||||
title: '路由',
|
||||
dataIndex: 'route',
|
||||
width: 200,
|
||||
render: val => <span>{val}</span>,
|
||||
},
|
||||
{
|
||||
title: '权限标识',
|
||||
dataIndex: 'permissions',
|
||||
dataIndex: 'permission',
|
||||
width: 300,
|
||||
render(permissions) {
|
||||
let text = '';
|
||||
if (permissions) {
|
||||
for (let i in permissions) {
|
||||
if (i > 0) {
|
||||
text += ' ';
|
||||
}
|
||||
text += permissions[i];
|
||||
}
|
||||
}
|
||||
return (<span>{text}</span>);
|
||||
}
|
||||
render: val => <span>{val}</span>,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
|
||||
@@ -84,29 +84,7 @@ export async function deptTreeAll() {
|
||||
|
||||
// resource
|
||||
|
||||
export async function addResource(params) {
|
||||
return request(`/admin-api/admins/resource/add?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateResource(params) {
|
||||
return request(`/admin-api/admins/resource/update?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteResource(params) {
|
||||
return request(`/admin-api/admins/resource/delete?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export async function resourceTree(params) {
|
||||
return request(`/admin-api/admins/resource/tree?${stringify(params)}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// role
|
||||
|
||||
|
||||
@@ -23,3 +23,29 @@ export async function authorizationResourcePermissions(params) {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// ========== Resource 模块 ==========
|
||||
|
||||
export async function resourceTree(params) {
|
||||
return request(`/system-api/admins/resource/tree`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function resourceAdd(params) {
|
||||
return request(`/system-api/admins/resource/add?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export async function resourceUpdate(params) {
|
||||
return request(`/system-api/admins/resource/update?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export async function resourceDelete(params) {
|
||||
return request(`/system-api/admins/resource/delete?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user