Merge remote-tracking branch 'origin/master'
This commit is contained in:
@ -33,6 +33,11 @@ export default {
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '/api/biz-service-ebtp-project': '' },
|
||||
},
|
||||
'/api/sys-manager-ebtp-project': {
|
||||
target: 'http://localhost:18012',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '/api/sys-manager-ebtp-project': '' },
|
||||
},
|
||||
// '/api/wfap/v1/audit/bill/find/by/procid': {
|
||||
// target: 'http://10.242.31.158:8891/',//审批单 uat环境自动审批,暂时用不到
|
||||
// changeOrigin: true,
|
||||
|
189
src/pages/System/Department/index.tsx
Normal file
189
src/pages/System/Department/index.tsx
Normal file
@ -0,0 +1,189 @@
|
||||
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
|
||||
import { Button, Form, Input, message, Modal, PageHeader, Select, Spin, Tree, TreeSelect } from 'antd';
|
||||
import { useRef, useState } from 'react';
|
||||
import { fetchAllDepartment, addOrg, deleteOrg, updateOrg, getDataById } from './service';
|
||||
import React from 'react';
|
||||
const Index: React.FC<{}> = () => {
|
||||
const [spin, spinSet] = useState<boolean>(false);
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [form] = Form.useForm();
|
||||
const [title, setTitle] = useState<string>('');
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const [org, orgSet] = useState<any>([]);
|
||||
const layout = {
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 13 },
|
||||
};
|
||||
const columns: ProColumns[] = [
|
||||
{
|
||||
title: '组织编码',
|
||||
dataIndex: 'orgNum',
|
||||
width: '10%',
|
||||
},
|
||||
{
|
||||
title: '组织名称',
|
||||
dataIndex: 'orgName',
|
||||
width: '30%',
|
||||
},
|
||||
{
|
||||
title: '组织全称',
|
||||
dataIndex: 'orgFullName',
|
||||
width: '45%',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '操作', width: '10%',
|
||||
valueType: 'option',
|
||||
render: (_, record) => [
|
||||
<Button type='text' onClick={() => { handleUpdate(record) }}>修改</Button>,
|
||||
<Button type='text' onClick={() => { handleDelete(record.orgId) }}>删除</Button>
|
||||
]
|
||||
},
|
||||
// {
|
||||
// title: '部门负责人',
|
||||
// dataIndex: 'leaderName',
|
||||
// width: '15%',
|
||||
// },
|
||||
];
|
||||
const handleAdd = async () => {
|
||||
setOpen(true);
|
||||
setTitle('添加组织');
|
||||
};
|
||||
|
||||
const handleUpdate = async (record: any) => {
|
||||
form.resetFields();
|
||||
const org = await getDataById(record.orgId);
|
||||
form.setFieldsValue(org.data);
|
||||
setOpen(true);
|
||||
setTitle('修改组织');
|
||||
};
|
||||
// 删除操作
|
||||
const handleDelete = (id: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除该组织?',
|
||||
onOk: async () => {
|
||||
await deleteOrg(id).then((r: any) => {
|
||||
if (r.code == 200) {
|
||||
message.success('删除成功');
|
||||
}
|
||||
})
|
||||
.finally(() => actionRef.current?.reload());
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
if (values.orgId) {
|
||||
await updateOrg(values).then((r: any) => {
|
||||
if (r.code == 200) {
|
||||
message.success('修改成功');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await addOrg(values).then((r: any) => {
|
||||
if (r.code == 200) {
|
||||
message.success('新增成功');
|
||||
}
|
||||
});
|
||||
}
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const closeModal = async () => {
|
||||
actionRef.current?.reload();
|
||||
form.resetFields();
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const addModal = (
|
||||
<Modal
|
||||
title={title}
|
||||
visible={open}
|
||||
width="70%"
|
||||
centered
|
||||
destroyOnClose={true}
|
||||
bodyStyle={{ maxHeight: window.innerHeight * 0.96 - 108, overflowY: 'auto', paddingTop: 0 }}
|
||||
// footer={<Button onClick={() => setOpen(false)}>关闭</Button>}
|
||||
onOk={handleSubmit}
|
||||
onCancel={() => closeModal()}
|
||||
>
|
||||
<Form form={form} {...layout}>
|
||||
<Form.Item label="组织id" name="orgId" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="上级部门" name="upOrgId" >
|
||||
<TreeSelect
|
||||
style={{ width: '100%' }}
|
||||
// treeDefaultExpandedKeys={['OR1000000000']}
|
||||
placeholder="请选择部门,可搜索"
|
||||
treeData={org}
|
||||
showSearch={true}
|
||||
treeNodeFilterProp={'title'}
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="组织名称" name="orgName" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="组织编码" name="orgNum" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
//表格请求
|
||||
async function request(params: any) {
|
||||
console.log('org params:', params);
|
||||
const { data } = await fetchAllDepartment(params);
|
||||
console.log('org data:', data);
|
||||
// orgSet(data.children);
|
||||
orgSet(data);
|
||||
let result = {
|
||||
// data: data.children,
|
||||
data: data,
|
||||
success: true,
|
||||
total: data.length,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Spin spinning={spin}>
|
||||
<PageHeader title="组织管理" />
|
||||
<div style={{ maxHeight: innerHeight - 130, height: innerHeight - 130 }} className='xsy-entrust bgCWhite'>
|
||||
<ProTable
|
||||
actionRef={actionRef}//action触发后更新表格
|
||||
columns={columns}
|
||||
search={{ labelWidth: 'auto', span: 6 }}
|
||||
options={false}
|
||||
rowKey="orgId"
|
||||
size="small"
|
||||
pagination={{
|
||||
defaultPageSize: 10,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
size: 'default',
|
||||
showTotal: (total) => <>{`共${total}条`}</>,
|
||||
}}
|
||||
pagination={false}
|
||||
toolBarRender={() => [
|
||||
<Button onClick={() => { handleAdd() }} type="primary">
|
||||
新增
|
||||
</Button>,
|
||||
]
|
||||
}
|
||||
request={request}
|
||||
/>
|
||||
{addModal}
|
||||
</div>
|
||||
</Spin >
|
||||
);
|
||||
}
|
||||
|
||||
export default Index;
|
50
src/pages/System/Department/service.ts
Normal file
50
src/pages/System/Department/service.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
export async function fetchAllDepartment(params: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysorg/queryAll`, {
|
||||
method: 'get',
|
||||
params: params,
|
||||
});
|
||||
}
|
||||
export async function addOrg(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysorg/insert', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
export async function deleteOrg(id: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysorg/del/${id}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
export async function updateOrg(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysorg/update', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
export async function getDataById(id: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysorg/${id}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export async function departmentList(options?: { [key: string]: any }): Promise<{ data: any }> {
|
||||
return request('/api/system/departmentList', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
//根据部门id 查部门下所属部门及人员,立项用
|
||||
export async function getOrgUserIF(orgId: any) {
|
||||
return request(`/api/sysorg/user?orgId=${orgId}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
//查部门下所属部门及人员 全量
|
||||
export async function getAllOrgUserIF() {
|
||||
return request(` /api/sysorg/user/all`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
272
src/pages/System/Role/index.tsx
Normal file
272
src/pages/System/Role/index.tsx
Normal file
@ -0,0 +1,272 @@
|
||||
import React, { useState, useRef } from 'react';
|
||||
import { message, Modal, Input, Form, PageHeader, Button, Spin, Select, Tree } from 'antd';
|
||||
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
|
||||
import { getPage, getDataById, deleteRole, addRole, updateRole } from './service';
|
||||
// import './styles.less';
|
||||
import { getDicData } from '@/utils/session';
|
||||
import TextArea from 'antd/lib/input/TextArea';
|
||||
|
||||
const entrust: React.FC<{}> = () => {
|
||||
//获取字典
|
||||
const getDict: any = getDicData();
|
||||
const [form] = Form.useForm();
|
||||
const [title, setTitle] = useState<string>('');
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
|
||||
const [checkedKeys, setCheckedKeys] = useState<React.Key[]>([]);
|
||||
const [currentRoleId, setCurrentRoleId] = useState<number | null>(null);
|
||||
const dictData = JSON.parse(getDict);
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [spin, spinSet] = useState<boolean>(false);
|
||||
//查询分页数据
|
||||
const [pageData, pageDataSet] = useState<any>({
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
const layout = {
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 13 },
|
||||
};
|
||||
interface DictType {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
const sys_normal_scope: DictType[] = [
|
||||
{ value: 'EBTP', label: '招标采购中心' },
|
||||
];
|
||||
|
||||
//委托列表
|
||||
const columns: ProColumns<any>[] = [
|
||||
{ title: '序号', valueType: 'index', width: 50, },
|
||||
{ title: '角色名称', dataIndex: 'roleName', },//, ellipsis: true
|
||||
{ title: '权限字符', dataIndex: 'roleCode', width: '10%' },
|
||||
{
|
||||
title: '角色范围', dataIndex: 'roleScope',
|
||||
valueEnum: { 'EBTP': { text: '招标采购中心', status: 'EBTP' }, },
|
||||
render: (_, record) => {
|
||||
if (record.roleScope === 'EBTP') {
|
||||
return (<>招标采购中心</>)
|
||||
} else {
|
||||
return (<></>)
|
||||
}
|
||||
}
|
||||
},
|
||||
{ title: '创建时间', dataIndex: 'createDate', width: '10%', valueType: 'dateTime', search: false },
|
||||
{
|
||||
title: '操作', width: '9%',
|
||||
valueType: 'option',
|
||||
render: (_, record) => [
|
||||
<Button type='text' onClick={() => { handleUpdate(record) }}>修改</Button>,
|
||||
<Button type='text' onClick={() => { handleDelete(record.roleId) }}>删除</Button>
|
||||
]
|
||||
},
|
||||
];
|
||||
// 删除操作
|
||||
const handleDelete = (id: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除该角色?',
|
||||
onOk: async () => {
|
||||
await deleteRole(id).then((r: any) => {
|
||||
if (r?.code == 200) {
|
||||
message.success('删除成功');
|
||||
} else {
|
||||
message.error('删除失败');
|
||||
}
|
||||
})
|
||||
.finally(() => actionRef.current?.reload());
|
||||
},
|
||||
});
|
||||
};
|
||||
const handleAdd = async () => {
|
||||
form.resetFields();
|
||||
// const menus = await menuTreeselect();
|
||||
// setMenuOptions(menus.data || []);
|
||||
// setMenuOptions(menu || []);
|
||||
|
||||
// 使用时转换
|
||||
setMenuOptions(formatMenuOptions(menu) || []);
|
||||
setOpen(true);
|
||||
setTitle('添加角色');
|
||||
};
|
||||
|
||||
const [menuOptions, setMenuOptions] = useState<any[]>([]);
|
||||
let menu = [{
|
||||
"id": '1', "parentId": '0', "label": "系统管理", "weight": 1,
|
||||
"children": [{
|
||||
"id": '101', "parentId": '1', "label": "角色管理", "weight": 2,
|
||||
"children": [{ "id": '1008', "parentId": '101', "label": "角色查询", "weight": 1 },
|
||||
{ "id": '1009', "parentId": '101', "label": "角色新增", "weight": 2 },
|
||||
{ "id": '1010', "parentId": '101', "label": "角色修改", "weight": 3 },
|
||||
{ "id": '1011', "parentId": '101', "label": "角色删除", "weight": 4 },
|
||||
{ "id": '1012', "parentId": '101', "label": "角色导出", "weight": 5 }]
|
||||
},
|
||||
{
|
||||
"id": '105', "parentId": '1', "label": "字典管理", "weight": 6,
|
||||
"children": [{ "id": '1026', "parentId": '105', "label": "字典查询", "weight": 1 },
|
||||
{ "id": '1027', "parentId": '105', "label": "字典新增", "weight": 2 },
|
||||
{ "id": '1028', "parentId": '105', "label": "字典修改", "weight": 3 },
|
||||
{ "id": '1029', "parentId": '105', "label": "字典删除", "weight": 4 },
|
||||
{ "id": '1030', "parentId": '105', "label": "字典导出", "weight": 5 }]
|
||||
}]
|
||||
},
|
||||
{ "id": '4', "parentId": '0', "label": "PLUS官网", "weight": 4 },
|
||||
{
|
||||
"id": "1494925781048545281", "parentId": '0', "label": "个人待办", "weight": 18,
|
||||
"children": [{ "id": "1494926258733633538", "parentId": "1494925781048545281", "label": "待办任务", "weight": 1 },
|
||||
{ "id": "1494926586677874690", "parentId": "1494925781048545281", "label": "已办任务", "weight": 2 }]
|
||||
}];
|
||||
const formatMenuOptions = (data: any[]) => {
|
||||
return data.map(item => ({
|
||||
title: item.label,
|
||||
key: item.id,
|
||||
children: item.children ? formatMenuOptions(item.children) : undefined,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleUpdate = async (record: any) => {
|
||||
form.resetFields();
|
||||
const role = await getDataById(record.roleId);
|
||||
// const menus = await roleMenuTreeselect(record.roleId);
|
||||
// setMenuOptions(menus.data.menus || []);
|
||||
setMenuOptions(formatMenuOptions(menu) || []);
|
||||
setCheckedKeys(role.data.menuIds || []);
|
||||
form.setFieldsValue({
|
||||
...role.data,
|
||||
menuIds: role.data.menuIds || [],
|
||||
});
|
||||
// form.setFieldsValue(role.data);
|
||||
setCurrentRoleId(record.roleId);
|
||||
setOpen(true);
|
||||
setTitle('修改角色');
|
||||
};
|
||||
|
||||
const closeModal = async () => {
|
||||
actionRef.current?.reload();
|
||||
form.resetFields();
|
||||
setCheckedKeys([]);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
if (values.roleId) {
|
||||
await updateRole(values).then((r: any) => {
|
||||
if (r?.code == 200) {
|
||||
message.success('修改成功');
|
||||
} else {
|
||||
message.error('修改失败');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await addRole(values).then((r: any) => {
|
||||
console.log("r?.code", r?.code)
|
||||
if (r?.code == 200) {
|
||||
message.success('新增成功');
|
||||
} else {
|
||||
message.error('新增失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const checkSupModal = (
|
||||
<Modal
|
||||
title={title}
|
||||
visible={open}
|
||||
width="70%"
|
||||
centered
|
||||
destroyOnClose={true}
|
||||
bodyStyle={{ maxHeight: window.innerHeight * 0.96 - 108, overflowY: 'auto', paddingTop: 0 }}
|
||||
// footer={<Button onClick={() => setOpen(false)}>关闭</Button>}
|
||||
onOk={handleSubmit}
|
||||
onCancel={() => closeModal()}
|
||||
>
|
||||
<Form form={form} {...layout}>
|
||||
<Form.Item label="角色id" name="roleId" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="角色名称" name="roleName" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="角色编码" name="roleCode" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="角色范围" name="roleScope" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
{sys_normal_scope.map((item) => (
|
||||
<Option key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label="角色描述" name="roleDesc" rules={[{ required: true }]}>
|
||||
<TextArea />
|
||||
</Form.Item>
|
||||
<Form.Item label="菜单权限" name="menuIds" >
|
||||
<Tree
|
||||
defaultExpandAll
|
||||
checkable
|
||||
checkedKeys={checkedKeys}
|
||||
onCheck={(checkedKeys) => {
|
||||
setCheckedKeys(checkedKeys as React.Key[]);
|
||||
form.setFieldsValue({ menuIds: checkedKeys });
|
||||
}}
|
||||
treeData={menuOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
return (
|
||||
<Spin spinning={spin}>
|
||||
<PageHeader title="角色管理" />
|
||||
<div style={{ maxHeight: innerHeight - 130, height: innerHeight - 130 }} className='xsy-entrust bgCWhite'>
|
||||
<ProTable<any>
|
||||
actionRef={actionRef}//action触发后更新表格
|
||||
columns={columns}//表格
|
||||
options={false}
|
||||
bordered={false}
|
||||
className='tableSearch'
|
||||
size='small'
|
||||
search={{ labelWidth: 'auto', span: 6 }}
|
||||
request={(params) =>
|
||||
getPage({
|
||||
...params,
|
||||
basePageRequest: { pageNo: pageData.pageNo, pageSize: pageData.pageSize },
|
||||
}).then((res) => {
|
||||
const result = {
|
||||
data: res.data.records,
|
||||
total: res.data.total,
|
||||
success: res.success,
|
||||
pageSize: res.data.size,
|
||||
current: res.data.current
|
||||
}
|
||||
return result;
|
||||
})
|
||||
}
|
||||
toolBarRender={() => [
|
||||
<Button onClick={() => { handleAdd() }} type="primary">
|
||||
新增
|
||||
</Button>,
|
||||
]
|
||||
}
|
||||
pagination={{
|
||||
defaultPageSize: 10,
|
||||
showSizeChanger: false,
|
||||
onChange: (page, pageSize) => pageDataSet({ pageNo: page, pageSize: pageSize }),
|
||||
onShowSizeChange: (current, size) => pageDataSet({ pageNo: current, pageSize: size }),
|
||||
}}
|
||||
onReset={() => { pageDataSet({ pageNo: 1, pageSize: 10 }) }}
|
||||
/>
|
||||
{checkSupModal}
|
||||
</div>
|
||||
{/* 查看 */}
|
||||
</Spin >
|
||||
)
|
||||
};
|
||||
export default entrust;
|
31
src/pages/System/Role/service.ts
Normal file
31
src/pages/System/Role/service.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 分页查询角色
|
||||
export async function getPage(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysrole/getPage', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
export async function getDataById(id: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysrole/${id}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
export async function deleteRole(id: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysrole/del/${id}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
export async function addRole(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysrole/insert', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
export async function updateRole(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysrole/update', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
290
src/pages/System/User/index.tsx
Normal file
290
src/pages/System/User/index.tsx
Normal file
@ -0,0 +1,290 @@
|
||||
import React, { useState, useRef, useMemo, useEffect } from 'react';
|
||||
import { message, Modal, Input, Form, PageHeader, Button, Spin, Tree, Checkbox, Row, Col } from 'antd';
|
||||
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
|
||||
import { getPage, getDataById, allocationIF, assignsRoles, updateRole } from './service';
|
||||
import { fetchAllDepartment } from '../Department/service';
|
||||
import { getDicData } from '@/utils/session';
|
||||
const { Search } = Input;
|
||||
const entrust: React.FC<{}> = () => {
|
||||
const [roleModalForm] = Form.useForm();
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [spin, spinSet] = useState<boolean>(false);
|
||||
const [roles, setRoles] = useState<any>([]);
|
||||
//查询分页数据
|
||||
const [pageData, pageDataSet] = useState<any>({
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
const layout = {
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 13 },
|
||||
};
|
||||
useEffect(() => {
|
||||
getDepartmentList();
|
||||
}, []);
|
||||
|
||||
//委托列表
|
||||
const columns: ProColumns<any>[] = [
|
||||
{ title: '序号', valueType: 'index', width: 50, },
|
||||
{ title: '用户名', dataIndex: 'name', },
|
||||
{ title: '用户账号', dataIndex: 'employeeNumber' },
|
||||
{ title: '用户Id', dataIndex: 'userId' },
|
||||
{ title: '部门', dataIndex: 'orgName', hideInSearch: true },
|
||||
{ title: '邮箱', dataIndex: 'email' },
|
||||
{
|
||||
title: '操作', width: '9%',
|
||||
valueType: 'option',
|
||||
render: (_, record) => [
|
||||
<Button type='text' onClick={() => { chooseRole(record) }}>分配角色</Button>
|
||||
// <Button type='text' onClick={() => { handleUpdate(record) }}>修改</Button>,
|
||||
// <Button type='text' onClick={() => { handleDelete(record.roleId) }}>删除</Button>
|
||||
]
|
||||
},
|
||||
];
|
||||
//分配角色查询数据
|
||||
const chooseRole = (record: any) => {
|
||||
roleModalForm.resetFields();
|
||||
spinSet(true);
|
||||
allocationIF(record.userId)
|
||||
.then((res: any) => {
|
||||
if (res?.code === 200) {
|
||||
console.log("roleIds",res?.data?.roleIds);
|
||||
setRoles(
|
||||
res?.data?.allRole?.map((item: any) => ({ label: item.roleName, value: item.roleId })),
|
||||
);
|
||||
roleModalForm.setFieldsValue({ ...record, roleIds: res?.data?.roleIds });
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
spinSet(false);
|
||||
});
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
const closeModal = async () => {
|
||||
actionRef.current?.reload();
|
||||
roleModalForm.resetFields();
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const onAssignsRoles = async () => {
|
||||
const values = await roleModalForm.validateFields();
|
||||
try {
|
||||
const { success } = await assignsRoles(values );
|
||||
if (success) {
|
||||
message.success('操作成功!');
|
||||
}
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const setRoleModal = (
|
||||
<Modal
|
||||
title={"分配角色"}
|
||||
visible={open}
|
||||
width="70%"
|
||||
centered
|
||||
destroyOnClose={true}
|
||||
bodyStyle={{ maxHeight: window.innerHeight * 0.96 - 108, overflowY: 'auto', paddingTop: 0 }}
|
||||
// footer={<Button onClick={() => setOpen(false)}>关闭</Button>}
|
||||
onOk={onAssignsRoles}
|
||||
onCancel={() => closeModal()}
|
||||
>
|
||||
<Form form={roleModalForm} {...layout}>
|
||||
<Form.Item label="id" name="userId" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="名称" name="name" >
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
<Form.Item label="部门" name="orgName" >
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
<Form.Item label="角色信息" name="roleIds">
|
||||
<Checkbox.Group>
|
||||
<Row>
|
||||
{roles?.map((v: any, i: number) => (
|
||||
<Col span={8} key={`col-${i}`}>
|
||||
<Checkbox value={v.value}>{v.label}</Checkbox>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</Checkbox.Group>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
const [treeDataList, treeDataListSet] = useState<any>([]);
|
||||
const [orgId, setOrgId] = useState<any>('');
|
||||
const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
||||
const [searchValue, setSearchValue] = useState('');
|
||||
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
||||
const [allData, allDataSet] = useState<any>([]);
|
||||
const onChange: (e: any) => void = (e) => {
|
||||
const { value } = e.target;
|
||||
let keys: any = [];
|
||||
if (value !== '') {
|
||||
const newExpandedKeys = treeDataList
|
||||
.map((item: { title: string | any[]; key: any }) => {
|
||||
if (item.title.indexOf(value) > -1) {
|
||||
return getParentKey(item.key, allData);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter((item: any, i: any, self: string | any[]) => {
|
||||
return item && self.indexOf(item) === i;
|
||||
});
|
||||
keys = newExpandedKeys;
|
||||
}
|
||||
setExpandedKeys(keys as React.Key[]);
|
||||
setSearchValue(value);
|
||||
setAutoExpandParent(value !== '');
|
||||
};
|
||||
const getDepartmentList = async () => {
|
||||
try {
|
||||
const { data } = await fetchAllDepartment({});
|
||||
allDataSet(data);
|
||||
const dataList: { key: React.Key; title: string }[] = [];
|
||||
const generateList = (data: any[]) => {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const node = data[i];
|
||||
const { key } = node;
|
||||
dataList.push({ key, title: node.title });
|
||||
if (node.children) {
|
||||
generateList(node.children);
|
||||
}
|
||||
}
|
||||
};
|
||||
generateList(data);
|
||||
treeDataListSet(dataList);
|
||||
} catch (e) { }
|
||||
};
|
||||
|
||||
const getParentKey = (key: React.Key, tree: any): React.Key => {
|
||||
let parentKey: React.Key;
|
||||
for (let i = 0; i < tree.length; i++) {
|
||||
const node = tree[i];
|
||||
if (node.children) {
|
||||
if (node.children.some((item) => item.key === key)) {
|
||||
parentKey = node.key;
|
||||
} else if (getParentKey(key, node.children)) {
|
||||
parentKey = getParentKey(key, node.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parentKey!;
|
||||
};
|
||||
const onExpand = (newExpandedKeys: any[]) => {
|
||||
setExpandedKeys(newExpandedKeys);
|
||||
setAutoExpandParent(false);
|
||||
};
|
||||
const onDepartmentClick = (selectedKeys: any, e: any) => {
|
||||
setOrgId(selectedKeys[0]);
|
||||
setTimeout(() => {
|
||||
actionRef.current?.reload();
|
||||
}, 200);
|
||||
};
|
||||
const treeData = useMemo(() => {
|
||||
const loop = (data: any): any[] => {
|
||||
console.log('data', data);
|
||||
let res: any[] = [];
|
||||
data.map((item: any, i: any) => {
|
||||
const strTitle = item.title as string;
|
||||
const index = strTitle.indexOf(searchValue);
|
||||
const beforeStr = strTitle.substring(0, index);
|
||||
const afterStr = strTitle.slice(index + searchValue.length);
|
||||
const title =
|
||||
index > -1 ? (
|
||||
<span>
|
||||
{beforeStr}
|
||||
<span style={{ color: 'red' }}>{searchValue}</span>
|
||||
{afterStr}
|
||||
</span>
|
||||
) : (
|
||||
<span>{strTitle}</span>
|
||||
);
|
||||
if (expandedKeys.includes(item.key) || index > -1) {
|
||||
if (item.children) {
|
||||
res.push({ title, key: item.key, children: loop(item.children) });
|
||||
} else {
|
||||
res.push({ title, key: item.key });
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
};
|
||||
if (searchValue !== '') {
|
||||
let returnData = loop(allData);
|
||||
return returnData;
|
||||
} else {
|
||||
return allData;
|
||||
}
|
||||
}, [searchValue, allData]);
|
||||
return (
|
||||
<Spin spinning={spin}>
|
||||
<PageHeader title="用户管理" />
|
||||
<div style={{ maxHeight: innerHeight - 130, height: innerHeight - 130 }} className='xsy-entrust bgCWhite'>
|
||||
<div style={{ display: 'flex', }}>
|
||||
<div style={{ backgroundColor: '#FFF', width: '220px', marginRight: '8px', }}>
|
||||
<Search style={{ marginBottom: 2 }} placeholder="关键字查询" onChange={onChange} />
|
||||
<div style={{ height: 'calc(100vh - 96px)', overflowY: 'auto', }}>
|
||||
<Tree
|
||||
// fieldNames={{ title: 'orgName', key: 'orgId', children: 'children' }}
|
||||
onExpand={onExpand}
|
||||
expandedKeys={expandedKeys}
|
||||
autoExpandParent={autoExpandParent}
|
||||
treeData={treeData}
|
||||
onSelect={onDepartmentClick}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ backgroundColor: '#FFF', flex: '1', width: '100%', }} >
|
||||
<ProTable<any>
|
||||
actionRef={actionRef}//action触发后更新表格
|
||||
columns={columns}//表格
|
||||
options={false}
|
||||
bordered={false}
|
||||
className='tableSearch'
|
||||
size='small'
|
||||
search={{ labelWidth: 'auto', span: 6 }}
|
||||
request={(params) =>
|
||||
getPage({
|
||||
...params,
|
||||
orgId: orgId,
|
||||
basePageRequest: { pageNo: pageData.pageNo, pageSize: pageData.pageSize },
|
||||
}).then((res) => {
|
||||
const result = {
|
||||
data: res.data.records,
|
||||
total: res.data.total,
|
||||
success: res.success,
|
||||
pageSize: res.data.size,
|
||||
current: res.data.current
|
||||
}
|
||||
return result;
|
||||
})
|
||||
}
|
||||
toolBarRender={() => [
|
||||
// <Button onClick={() => { handleAdd() }} type="primary">
|
||||
// 新增
|
||||
// </Button>,
|
||||
]
|
||||
}
|
||||
pagination={{
|
||||
defaultPageSize: 10,
|
||||
showSizeChanger: false,
|
||||
onChange: (page, pageSize) => pageDataSet({ pageNo: page, pageSize: pageSize }),
|
||||
onShowSizeChange: (current, size) => pageDataSet({ pageNo: current, pageSize: size }),
|
||||
}}
|
||||
onReset={() => { pageDataSet({ pageNo: 1, pageSize: 10 }); setOrgId(''); }}
|
||||
/>
|
||||
{setRoleModal}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 查看 */}
|
||||
</Spin >
|
||||
)
|
||||
};
|
||||
export default entrust;
|
89
src/pages/System/User/service.ts
Normal file
89
src/pages/System/User/service.ts
Normal file
@ -0,0 +1,89 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
// 分页查询角色
|
||||
export async function getPage(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysuser/getPage', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
export async function getDataById(id: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysuser/${id}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
export async function deleteRole(id: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysuser/del/${id}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
export async function addRole(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysuser/insert', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
export async function updateRole(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysuser/update', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
//分配人员查询数据
|
||||
export async function allocationIF(userId: any) {
|
||||
return request(`/api/sys-manager-ebtp-project/v1/sysrole/role/assign/${userId}`, {
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
export async function assignsRoles(params: any) {
|
||||
return request('/api/sys-manager-ebtp-project/v1/sysuserrole/assignsRoles', {
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
// import { TreeDataNode } from 'antd';
|
||||
|
||||
// export function userList(options?: { [key: string]: any }): Promise<{ data: any }> {
|
||||
// return request('/api/system/userList', {
|
||||
// method: 'GET',
|
||||
// ...(options || {}),
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function treeData(options?: { [key: string]: any }): Promise<{ data: TreeDataNode[] }> {
|
||||
// return request('/api/system/treeData', {
|
||||
// method: 'GET',
|
||||
// ...(options || {}),
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function fetchUserList(options?: any) {
|
||||
// return request('/api/sysuser/getPage', {
|
||||
// method: 'POST',
|
||||
// data: options,
|
||||
// });
|
||||
// }
|
||||
// //获取用户数据
|
||||
// export function getUser(userId?: any) {
|
||||
// return request(`/api/sysuser/${userId}`, {
|
||||
// method: 'get',
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function assignsRoles(options?: { [key: string]: any }): Promise<any> {
|
||||
// return request('/api/sysuser/assignsRoles', {
|
||||
// method: 'post',
|
||||
// ...(options || {}),
|
||||
// });
|
||||
// }
|
||||
|
||||
// //查询用户详情
|
||||
// export function getOneUserAll(options?: { [key: string]: any }): Promise<{ data: TreeDataNode[] }> {
|
||||
// return request(`/api/sysuser/getOneUserAll/${options?.id}`, {
|
||||
// method: 'GET',
|
||||
// params: options,
|
||||
// ...(options || {}),
|
||||
// });
|
||||
// }
|
Reference in New Issue
Block a user