Commit 82945d47 authored by Maofei94's avatar Maofei94

fix: 角色管理

parent 2aae7b09
.divbox{ .divbox{
display: flex; display: flex!important;
align-items: center; align-items: center;
} }
.cardbox{ .cardbox{
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
} }
.btnBox{ .btnBox{
margin-top: 40px; margin-top: 40px;
display: flex; display: flex!important;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
......
...@@ -224,7 +224,7 @@ const InitDataBase = props => { ...@@ -224,7 +224,7 @@ const InitDataBase = props => {
setCardLoading(false); setCardLoading(false);
if (res.GetMe === true) { if (res.GetMe === true) {
notification.success({ notification.success({
message: '通知', message: '提示',
duration: 3, duration: 3,
description: '连接成功', description: '连接成功',
}); });
...@@ -257,7 +257,7 @@ const InitDataBase = props => { ...@@ -257,7 +257,7 @@ const InitDataBase = props => {
setOption(res.root); setOption(res.root);
} else { } else {
notification.error({ notification.error({
message: '通知', message: '提示',
duration: 15, duration: 15,
description: res.message, description: res.message,
}); });
......
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Input, notification } from 'antd'; import { Form, Input, notification, Select } from 'antd';
import SiteModal from '@/components/Modal/SiteModa'; import SiteModal from '@/components/Modal/SiteModa';
import { addStation } from '@/services/userCenter/siteManage/api'; import { addRole, getRoleGroup } from '@/services/userCenter/roleManage/api';
const { Item } = Form; const { Item } = Form;
const { Option } = Select;
const AddModal = props => { const AddModal = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [formLayout, setFormLayout] = useState('horizontal'); const [formLayout, setFormLayout] = useState('horizontal');
const [groupList, setGroupList] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const { confirmModal } = props; const { confirmModal, itemObj } = props;
useEffect(() => {
itemObj.groupflag &&
form.setFieldsValue({
group: itemObj.groupflag,
});
return () => {
form.resetFields();
};
}, [itemObj]);
const onSubmit = () => { const onSubmit = () => {
form form
.validateFields() .validateFields()
.then(res => { .then(res => {
console.log(res, 'res');
setLoading(true); setLoading(true);
addStation({ addRole({
stationName: res.stationName, roleName: res.roleName,
description: res.description, description: res.description,
group: res.group,
subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '',
_version: 9999, _version: 9999,
_dc: new Date().getTime(), _dc: new Date().getTime(),
}) })
...@@ -25,7 +38,7 @@ const AddModal = props => { ...@@ -25,7 +38,7 @@ const AddModal = props => {
if (res.success) { if (res.success) {
form.resetFields(); form.resetFields();
notification.success({ notification.success({
message: '通知', message: '提示',
duration: 3, duration: 3,
description: '新增成功', description: '新增成功',
}); });
...@@ -33,7 +46,7 @@ const AddModal = props => { ...@@ -33,7 +46,7 @@ const AddModal = props => {
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 15,
description: res.message, description: res.message,
}); });
} }
...@@ -51,6 +64,38 @@ const AddModal = props => { ...@@ -51,6 +64,38 @@ const AddModal = props => {
console.error(err); console.error(err);
}); });
}; };
const onChange = value => {
console.log(value);
const { length } = value;
form.setFieldsValue({
group: value[length - 1],
});
};
// 获取分组列表
const selectFocus = e => {
setGroupList([]);
getRoleGroup({
_version: 9999,
_dc: Date.now(),
subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '',
subSystemName: itemObj.subSystemValue || itemObj.visibleValue || '',
})
.then(res => {
if (res) {
setGroupList(res);
} else {
notification.error({
message: '提示',
duration: 15,
description: res.message,
});
setGroupList([]);
}
})
.catch(err => {
console.error(err);
});
};
const onFinish = value => {}; const onFinish = value => {};
return ( return (
...@@ -58,11 +103,11 @@ const AddModal = props => { ...@@ -58,11 +103,11 @@ const AddModal = props => {
{...props} {...props}
title="新增角色" title="新增角色"
bodyStyle={{ width: '100%', minHeight: '100px' }} bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: 200, borderRadius: '20px' }} style={{ top: 100 }}
width="600px" width="600px"
destroyOnClose destroyOnClose
cancelText="取消" cancelText="取消"
okText="确认选择" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
...@@ -74,7 +119,7 @@ const AddModal = props => { ...@@ -74,7 +119,7 @@ const AddModal = props => {
> >
<Item <Item
label="角色名称" label="角色名称"
name="stationName" name="roleName"
rules={[ rules={[
{ {
required: true, required: true,
...@@ -84,7 +129,27 @@ const AddModal = props => { ...@@ -84,7 +129,27 @@ const AddModal = props => {
> >
<Input placeholder="请输入角色名称" /> <Input placeholder="请输入角色名称" />
</Item> </Item>
<Item label="角色类别">all</Item> <Item label="角色类别" name="subSystemValue">
{itemObj.subSystemValue || itemObj.visibleValue}
</Item>
<Item label="角色分组" name="group">
<Select
mode="tags"
placeholder="请选择分组"
onFocus={() => {
selectFocus();
}}
onChange={e => {
onChange(e);
}}
>
{groupList.map((item, index) => (
<Option value={item.value} key={index}>
{item.text}
</Option>
))}
</Select>
</Item>
<Item label="角色描述" name="description"> <Item label="角色描述" name="description">
<Input placeholder="请输入角色描述" /> <Input placeholder="请输入角色描述" />
</Item> </Item>
......
import React, { useState } from 'react'; import React, { useState } from 'react';
import { notification } from 'antd'; import { notification } from 'antd';
import SiteModal from '@/components/Modal/SiteModa'; import SiteModal from '@/components/Modal/SiteModa';
import { deleteStation } from '@/services/userCenter/siteManage/api'; import { deleteRole } from '@/services/userCenter/roleManage/api';
const DelModal = props => { const DelModal = props => {
const { confirmModal, stationId } = props; const { confirmModal, itemObj } = props;
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const onSubmit = props => { const onSubmit = props => {
setLoading(true); setLoading(true);
deleteStation({ deleteRole({
stationID: stationId, roleID: itemObj.roleID || '',
_version: 9999, _version: 9999,
_dc: new Date().getTime(), _dc: new Date().getTime(),
}) })
...@@ -47,11 +47,15 @@ const DelModal = props => { ...@@ -47,11 +47,15 @@ const DelModal = props => {
width="400px" width="400px"
destroyOnClose destroyOnClose
cancelText="取消" cancelText="取消"
okText="确认删除" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
是否删除该角色? 是否删除角色
<span style={{ color: 'red' }}>
{itemObj.roleName && itemObj.roleName}
</span>
?
</SiteModal> </SiteModal>
); );
}; };
......
import React, { useState, useEffect } from 'react';
import { notification, Form, Input } from 'antd';
import SiteModal from '@/components/Modal/SiteModa';
import { setRoleGroupName } from '@/services/userCenter/roleManage/api';
const { Item } = Form;
const EditGroup = props => {
const { confirmModal, itemObj } = props;
const [loading, setLoading] = useState(false);
const [form] = Form.useForm();
useEffect(() => {
console.log(itemObj.groupflag, 'flag');
form.setFieldsValue({
newName: itemObj.groupflag,
});
}, [itemObj]);
const onSubmit = props => {
setLoading(true);
setRoleGroupName({
subSystemValue: itemObj.visibleValue || itemObj.subSystemValue,
oldName: itemObj.groupflag,
newName: form.getFieldsValue().newName,
_version: 9999,
_dc: new Date().getTime(),
})
.then(res => {
setLoading(false);
if (res.success) {
form.resetFields();
notification.success({
message: '提示',
duration: 3,
description: '修改成功',
});
confirmModal();
} else {
notification.error({
message: '提示',
duration: 15,
description: res.message,
});
}
})
.catch(err => {
setLoading(false);
});
};
return (
<SiteModal
{...props}
title="编辑分组名称"
bodyStyle={{ width: '100%', minHeight: '50px' }}
style={{ top: 200 }}
width="600px"
destroyOnClose
cancelText="取消"
okText="确认"
onOk={() => onSubmit()}
confirmLoading={loading}
>
<Form form={form} wrapperCol={{ span: 20 }}>
<Item label="分组名称" name="newName">
<Input placeholder="请输入分组名称" />
</Item>
</Form>
</SiteModal>
);
};
export default EditGroup;
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Input, notification } from 'antd'; import { Form, Input, notification, Select } from 'antd';
import SiteModal from '@/components/Modal/SiteModa'; import SiteModal from '@/components/Modal/SiteModa';
import { editStation } from '@/services/userCenter/siteManage/api'; import { editRole, getRoleGroup } from '@/services/userCenter/roleManage/api';
const { Item } = Form; const { Item } = Form;
const EditModal = props => { const { Option } = Select;
const AddModal = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [formLayout, setFormLayout] = useState('horizontal'); const [formLayout, setFormLayout] = useState('horizontal');
const [groupList, setGroupList] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const flag = useRef(); const { confirmModal, itemObj } = props;
const { confirmModal, stationObj } = props; console.log(itemObj, 'itemObj');
useEffect(() => {
form.setFieldsValue({
roleName: itemObj.roleName,
description: itemObj.description,
group: itemObj.group,
subSystemValue: itemObj.subSystemValue,
});
}, [itemObj]);
const onSubmit = () => { const onSubmit = () => {
form form
.validateFields() .validateFields()
.then(res => { .then(res => {
console.log(res, 'res');
setLoading(true); setLoading(true);
flag.current = res; editRole({
editStation({ roleID: itemObj.roleID,
stationName: res.stationName, roleName: res.roleName,
description: res.description, description: res.description,
stationID: stationObj.stationID, group: res.group,
subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '',
_version: 9999, _version: 9999,
_dc: new Date().getTime(), _dc: new Date().getTime(),
}) })
...@@ -27,7 +40,7 @@ const EditModal = props => { ...@@ -27,7 +40,7 @@ const EditModal = props => {
if (res.success) { if (res.success) {
form.resetFields(); form.resetFields();
notification.success({ notification.success({
message: '通知', message: '提示',
duration: 3, duration: 3,
description: '编辑成功', description: '编辑成功',
}); });
...@@ -53,29 +66,62 @@ const EditModal = props => { ...@@ -53,29 +66,62 @@ const EditModal = props => {
console.error(err); console.error(err);
}); });
}; };
useEffect(() => { const onChange = value => {
console.log(value);
const { length } = value;
form.setFieldsValue({ form.setFieldsValue({
stationName: stationObj.text, group: value[length - 1],
description: stationObj.description,
}); });
}, [stationObj]); };
// 获取分组列表
const selectFocus = e => {
setGroupList([]);
getRoleGroup({
_version: 9999,
_dc: Date.now(),
subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '',
subSystemName: itemObj.subSystemValue || itemObj.visibleValue || '',
})
.then(res => {
if (res) {
setGroupList(res);
} else {
notification.error({
message: '提示',
duration: 15,
description: res.message,
});
setGroupList([]);
}
})
.catch(err => {
console.error(err);
});
};
const onFinish = value => {};
return ( return (
<SiteModal <SiteModal
{...props} {...props}
title="编辑角色" title="编辑角色"
bodyStyle={{ width: '100%', minHeight: '100px' }} bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: 200, borderRadius: '20px' }} style={{ top: 100 }}
width="600px" width="600px"
destroyOnClose destroyOnClose
cancelText="取消" cancelText="取消"
okText="确认编辑" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
<Form form={form} layout={formLayout} labelCol={{ span: 4 }}> <Form
form={form}
layout={formLayout}
onFinish={onFinish}
labelCol={{ span: 4 }}
>
<Item <Item
label="角色名称" label="角色名称"
name="stationName" name="roleName"
rules={[ rules={[
{ {
required: true, required: true,
...@@ -85,7 +131,27 @@ const EditModal = props => { ...@@ -85,7 +131,27 @@ const EditModal = props => {
> >
<Input placeholder="请输入角色名称" /> <Input placeholder="请输入角色名称" />
</Item> </Item>
<Item label="角色类别">all</Item> <Item label="角色类别" name="subSystemValue">
{itemObj.subSystemValue || itemObj.visibleValue}
</Item>
<Item label="角色分组" name="group">
<Select
mode="tags"
placeholder="请选择分组"
onFocus={() => {
selectFocus();
}}
onChange={e => {
onChange(e);
}}
>
{groupList.map((item, index) => (
<Option value={item.value} key={index}>
{item.text}
</Option>
))}
</Select>
</Item>
<Item label="角色描述" name="description"> <Item label="角色描述" name="description">
<Input placeholder="请输入角色描述" /> <Input placeholder="请输入角色描述" />
</Item> </Item>
...@@ -94,4 +160,4 @@ const EditModal = props => { ...@@ -94,4 +160,4 @@ const EditModal = props => {
); );
}; };
export default EditModal; export default AddModal;
.cardBox{ .cardBox{
min-height: calc(100vh - 200px); min-height: calc(100vh - 200px);
max-height: calc(100vh - 200px); // max-height: calc(100vh - 200px);
overflow-y: scroll; // overflow-y: scroll;
} }
.ant-tree-node-content-wrapper-open{ .ant-tree-node-content-wrapper-open{
display: flex; display: flex;
...@@ -29,4 +29,11 @@ ...@@ -29,4 +29,11 @@
min-height: calc(100vh - 292px); min-height: calc(100vh - 292px);
max-height: calc(100vh - 292px); max-height: calc(100vh - 292px);
overflow-y: scroll; overflow-y: scroll;
}
:global{
.ant-tree-switcher{
display: flex;
align-items: center;
color:#1890FF;
}
} }
\ No newline at end of file
...@@ -62,7 +62,7 @@ const AddModal = props => { ...@@ -62,7 +62,7 @@ const AddModal = props => {
width="600px" width="600px"
destroyOnClose destroyOnClose
cancelText="取消" cancelText="取消"
okText="确认选择" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
......
...@@ -47,7 +47,7 @@ const DelModal = props => { ...@@ -47,7 +47,7 @@ const DelModal = props => {
width="400px" width="400px"
destroyOnClose destroyOnClose
cancelText="取消" cancelText="取消"
okText="确认删除" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
......
...@@ -68,7 +68,7 @@ const EditModal = props => { ...@@ -68,7 +68,7 @@ const EditModal = props => {
width="600px" width="600px"
destroyOnClose destroyOnClose
cancelText="取消" cancelText="取消"
okText="确认编辑" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
......
...@@ -30,7 +30,12 @@ ...@@ -30,7 +30,12 @@
.listItem{ .listItem{
padding-left: 5px; padding-left: 5px;
cursor: pointer; cursor: pointer;
font-size: 16px;
}
.listItem:hover{
background-color: #f8f8f8 ;
} }
.selected{ .selected{
background-color: #bae7ff; font-weight: bold;
background-color: #bae7ff!important;
} }
\ No newline at end of file
import { get, post } from '@/services/index'; import { get, post, PUBLISH_SERVICE } from '@/services/index';
// 获取站点信息
export const getWebModuleTree = params =>
get('/Cityinterface/rest/services/OMS.svc/W4_GetWeb4ModuleTree', params);
// 新增站点 // 新增站点
export const addStation = params => export const addStation = params =>
...@@ -33,3 +29,27 @@ export const setMenuToRole = (params, options) => ...@@ -33,3 +29,27 @@ export const setMenuToRole = (params, options) =>
params, params,
options, options,
); );
/**
* @角色管理
*/
// 获取角色树
export const getRoleGroupList = params =>
get(`${PUBLISH_SERVICE}/UserCenter/RoleGroupList`, params);
// 新增角色
export const addRole = params =>
get(`/Cityinterface/rest/services/OMS.svc/P_AddRole`, params);
// 获取分组列表
export const getRoleGroup = params =>
get(`/Cityinterface/rest/services/OMS.svc/P_GetRoleGroup`, params);
// 编辑角色
export const editRole = params =>
get('/Cityinterface/rest/services/OMS.svc/P_EditRole', params);
// 删除角色
export const deleteRole = params =>
get('/Cityinterface/rest/services/OMS.svc/P_DeleteRole', params);
// 编辑分组名称
export const setRoleGroupName = params =>
get('/Cityinterface/rest/services/OMS.svc/P_SetRoleGroupName', params);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment