|
@@ -1,13 +1,15 @@
|
|
import React, { useState, useEffect, useRef } from 'react';
|
|
import React, { useState, useEffect, useRef } from 'react';
|
|
-import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown, Modal, Row, Col, message } from 'antd';
|
|
|
|
|
|
+import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown, Modal, Breadcrumb, message, Row, Col } from 'antd';
|
|
import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
|
import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
|
-import NormalPlayer from './addUser'
|
|
|
|
|
|
+import AddUser from './addUser'
|
|
import '@common/common.less';
|
|
import '@common/common.less';
|
|
import apiObj from '@api/index';
|
|
import apiObj from '@api/index';
|
|
|
|
+import utils from '@utils/index'
|
|
|
|
+import UserContext from './user-context';
|
|
const { post, api, xPost } = apiObj;
|
|
const { post, api, xPost } = apiObj;
|
|
|
|
+const { organizationData } = utils;
|
|
const { Option } = Select;
|
|
const { Option } = Select;
|
|
function UserManager() {
|
|
function UserManager() {
|
|
- const parentRef = useRef();
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
getUserPage();
|
|
getUserPage();
|
|
}, []);
|
|
}, []);
|
|
@@ -18,32 +20,32 @@ function UserManager() {
|
|
const [msvisible, setMsvisible] = useState(false);
|
|
const [msvisible, setMsvisible] = useState(false);
|
|
const [modalType, setModalType] = useState("");
|
|
const [modalType, setModalType] = useState("");
|
|
const [type, setType] = useState("");
|
|
const [type, setType] = useState("");
|
|
|
|
+ const [formData, setFormData] = useState(null);
|
|
|
|
+ const [username, setUsername] = useState(null);
|
|
|
|
+
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
const tipText = {
|
|
const tipText = {
|
|
1: '确定要删除该用户?',
|
|
1: '确定要删除该用户?',
|
|
2: '禁用后该用户将无法登录,确定要禁用该用户?',
|
|
2: '禁用后该用户将无法登录,确定要禁用该用户?',
|
|
3: '确定要重置该用户密码?',
|
|
3: '确定要重置该用户密码?',
|
|
};
|
|
};
|
|
- const ChildrenChange = (val) => {
|
|
|
|
- setVisible(false);
|
|
|
|
- getUserPage()
|
|
|
|
- }
|
|
|
|
- const getChildrenMsg = (result, msg) => {
|
|
|
|
- // console.log(result, msg)
|
|
|
|
- // 很奇怪这里的result就是子组件那bind的第一个参数this,msg是第二个参数
|
|
|
|
- }
|
|
|
|
//新增弹窗
|
|
//新增弹窗
|
|
- const showModal = (name, type, flag) => {
|
|
|
|
|
|
+ const showModal = (name, type, flag, userId) => {
|
|
setVisible(type);
|
|
setVisible(type);
|
|
setTitle(name);
|
|
setTitle(name);
|
|
setType(flag)
|
|
setType(flag)
|
|
- if (flag == 3) {
|
|
|
|
- getUserById()
|
|
|
|
|
|
+ setUserId(userId)
|
|
|
|
+ if (flag == 1) {
|
|
|
|
+ setFormData({
|
|
|
|
+ status: '1'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if (flag == 3 || flag == 2) {
|
|
|
|
+ getUserById(userId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//表格数据
|
|
//表格数据
|
|
function getUserPage(param = {}) {
|
|
function getUserPage(param = {}) {
|
|
- //const param = filterData;
|
|
|
|
post(api.getUserPage, param).then((res) => {
|
|
post(api.getUserPage, param).then((res) => {
|
|
if (res.data.code === 200) {
|
|
if (res.data.code === 200) {
|
|
const data = res.data.data;
|
|
const data = res.data.data;
|
|
@@ -52,12 +54,29 @@ function UserManager() {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
//查看用户
|
|
//查看用户
|
|
- function getUserById() {
|
|
|
|
- xPost(api.getUserById, { userId: 39 }).then((res) => {
|
|
|
|
|
|
+ function getUserById(userId) {
|
|
|
|
+ xPost(api.getUserById, { userId: userId }).then((res) => {
|
|
if (res.data.code === 200) {
|
|
if (res.data.code === 200) {
|
|
const data = res.data.data;
|
|
const data = res.data.data;
|
|
- // let arr = JSON.parse(JSON.stringify(data).replaceAll(/name/g, 'title').replaceAll(/id/g, 'value'))
|
|
|
|
- // setTreeRloe(arr)
|
|
|
|
|
|
+ let roles = []
|
|
|
|
+ data.roles.forEach(item => {
|
|
|
|
+ roles.push(item.roleId)
|
|
|
|
+ })
|
|
|
|
+ const arr = {
|
|
|
|
+ username: data.username,
|
|
|
|
+ mobilePhone: data.mobilePhone,
|
|
|
|
+ password: data.password,
|
|
|
|
+ againpassword: data.password,
|
|
|
|
+ name: data.name,
|
|
|
|
+ idcard: data.idcard,
|
|
|
|
+ // addHospitalTreeVO: organizationData(data.hospitals[0].children[0].children),
|
|
|
|
+ titleId: data.titleId,
|
|
|
|
+ jobNo: data.jobNo,
|
|
|
|
+ roles: roles,
|
|
|
|
+ orderNo: data.orderNo,
|
|
|
|
+ status: data.status,
|
|
|
|
+ }
|
|
|
|
+ setFormData(arr)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -76,10 +95,6 @@ function UserManager() {
|
|
message.error("接口出错");
|
|
message.error("接口出错");
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- // 启用/禁用用户
|
|
|
|
- function enable(userId, status) {
|
|
|
|
- disableUser(userId, status)
|
|
|
|
- }
|
|
|
|
//重置密码
|
|
//重置密码
|
|
function onResetPsd() {
|
|
function onResetPsd() {
|
|
// const param = { HospitalId: operId };
|
|
// const param = { HospitalId: operId };
|
|
@@ -95,9 +110,9 @@ function UserManager() {
|
|
// });
|
|
// });
|
|
}
|
|
}
|
|
//删除
|
|
//删除
|
|
- function onDelete() {
|
|
|
|
|
|
+ function deleteUser() {
|
|
const param = { userId: userId };
|
|
const param = { userId: userId };
|
|
- xPost(api.deleteHospital, param).then((res) => {
|
|
|
|
|
|
+ xPost(api.deleteUser, param).then((res) => {
|
|
if (res.data.code === 200) {
|
|
if (res.data.code === 200) {
|
|
getUserPage();
|
|
getUserPage();
|
|
message.success("删除成功");
|
|
message.success("删除成功");
|
|
@@ -108,16 +123,7 @@ function UserManager() {
|
|
message.error("接口出错");
|
|
message.error("接口出错");
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- // 确定按钮
|
|
|
|
- function addUser(param = {}) {
|
|
|
|
- //const param = filterData;
|
|
|
|
- post(api.addUser, param).then((res) => {
|
|
|
|
- if (res.data.code === 200) {
|
|
|
|
- message.success(res.data.message);
|
|
|
|
- form.resetFields();
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
const onFinish = (value) => {
|
|
const onFinish = (value) => {
|
|
getUserPage(value);
|
|
getUserPage(value);
|
|
};
|
|
};
|
|
@@ -130,31 +136,11 @@ function UserManager() {
|
|
setUserId(id)
|
|
setUserId(id)
|
|
setModalType(type)
|
|
setModalType(type)
|
|
};
|
|
};
|
|
- // 新增
|
|
|
|
- const submit = () => {
|
|
|
|
- console.log(parentRef.current)
|
|
|
|
- form
|
|
|
|
- .validateFields()
|
|
|
|
- .then((values) => {
|
|
|
|
- let params = parentRef.current.form
|
|
|
|
- parentRef.current.addHospitalTreeVO.hospitals = unique(parentRef.current.addHospitalTreeVO.hospitals)
|
|
|
|
- params.addHospitalTreeVO = parentRef.current.addHospitalTreeVO
|
|
|
|
- addUser(params)
|
|
|
|
- })
|
|
|
|
- .catch((info) => {
|
|
|
|
- console.log('Validate Failed:', info);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- // 去重
|
|
|
|
- function unique(arr) {
|
|
|
|
- return arr.filter(function (item, index, arr) {
|
|
|
|
- return arr.indexOf(item, 0) === index;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
//提示框确认事件
|
|
//提示框确认事件
|
|
function handleOk() {
|
|
function handleOk() {
|
|
- if (modalType == 2) {
|
|
|
|
- disableUser(userId, 0)
|
|
|
|
|
|
+ if (modalType == 1) {
|
|
|
|
+ deleteUser(userId)
|
|
} else if (modalType == 2) {
|
|
} else if (modalType == 2) {
|
|
disableUser(userId, 0)
|
|
disableUser(userId, 0)
|
|
} else if (modalType == 3) {
|
|
} else if (modalType == 3) {
|
|
@@ -165,6 +151,13 @@ function UserManager() {
|
|
function handleCancel() {
|
|
function handleCancel() {
|
|
setMsvisible(false);
|
|
setMsvisible(false);
|
|
}
|
|
}
|
|
|
|
+ function cancel() {
|
|
|
|
+ setVisible(false)
|
|
|
|
+ setFormData(null)
|
|
|
|
+ }
|
|
|
|
+ function userChange() {
|
|
|
|
+ setVisible(false)
|
|
|
|
+ }
|
|
const columns = [
|
|
const columns = [
|
|
{ title: '用户名', dataIndex: 'username', key: 'index' },
|
|
{ title: '用户名', dataIndex: 'username', key: 'index' },
|
|
{ title: '姓名', dataIndex: 'name', key: 'index' },
|
|
{ title: '姓名', dataIndex: 'name', key: 'index' },
|
|
@@ -184,8 +177,8 @@ function UserManager() {
|
|
{
|
|
{
|
|
title: '操作', dataIndex: 'key', render: (text, record) => (
|
|
title: '操作', dataIndex: 'key', render: (text, record) => (
|
|
<Space size="middle">
|
|
<Space size="middle">
|
|
- <a onClick={e => showModal('查看用户', true, 3)}>查看</a>
|
|
|
|
- <a onClick={e => showModal('修改用户', true, 2)} >修改</a>
|
|
|
|
|
|
+ <a onClick={e => showModal('查看用户', true, 3, record.userId)}>查看</a>
|
|
|
|
+ <a onClick={e => showModal('修改用户', true, 2, record.userId)} >修改</a>
|
|
<Dropdown overlay={menu.bind(this, record)} record={record}>
|
|
<Dropdown overlay={menu.bind(this, record)} record={record}>
|
|
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
|
|
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
|
|
更多 <DownOutlined />
|
|
更多 <DownOutlined />
|
|
@@ -204,10 +197,10 @@ function UserManager() {
|
|
</a>
|
|
</a>
|
|
</Menu.Item>
|
|
</Menu.Item>
|
|
<Menu.Item key="1">
|
|
<Menu.Item key="1">
|
|
- {record.status === '1' ? (<a onClick={() => messageBox(2, record.userId)}>禁用</a>) : (<a onClick={() => enable(record.userId, 1)}>启用</a>)}
|
|
|
|
|
|
+ {record.status === '1' ? (<a onClick={() => messageBox(2, record.userId)}>禁用</a>) : (<a onClick={() => disableUser(record.userId, 1)}>启用</a>)}
|
|
</Menu.Item>
|
|
</Menu.Item>
|
|
<Menu.Item key="2">
|
|
<Menu.Item key="2">
|
|
- <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com">
|
|
|
|
|
|
+ <a target="_blank" onClick={() => messageBox(1, record.userId)}>
|
|
删除
|
|
删除
|
|
</a>
|
|
</a>
|
|
</Menu.Item>
|
|
</Menu.Item>
|
|
@@ -216,7 +209,7 @@ function UserManager() {
|
|
}
|
|
}
|
|
return (
|
|
return (
|
|
<div className="wrapper">
|
|
<div className="wrapper">
|
|
- <div className="filter-box">
|
|
|
|
|
|
+ <div className="filter-box">
|
|
<Form
|
|
<Form
|
|
form={form}
|
|
form={form}
|
|
name="normal_login"
|
|
name="normal_login"
|
|
@@ -224,16 +217,16 @@ function UserManager() {
|
|
onFinish={onFinish}
|
|
onFinish={onFinish}
|
|
initialValues={{ status: '' }}
|
|
initialValues={{ status: '' }}
|
|
>
|
|
>
|
|
- <Row gutter={24}>
|
|
|
|
- <Col span={6} key={0}>
|
|
|
|
- <Form.Item label="用户名" name="username">
|
|
|
|
- <Input placeholder="用户名" />
|
|
|
|
- </Form.Item>
|
|
|
|
- </Col>
|
|
|
|
- <Col span={6} key={1}>
|
|
|
|
- <Form.Item label="姓名" name="name">
|
|
|
|
- <Input placeholder="姓名" />
|
|
|
|
- </Form.Item>
|
|
|
|
|
|
+ <Row gutter={24}>
|
|
|
|
+ <Col span={6} key={0}>
|
|
|
|
+ <Form.Item label="用户名" name="username">
|
|
|
|
+ <Input placeholder="用户名" />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ </Col>
|
|
|
|
+ <Col span={6} key={1}>
|
|
|
|
+ <Form.Item label="姓名" name="name">
|
|
|
|
+ <Input placeholder="姓名" />
|
|
|
|
+ </Form.Item>
|
|
</Col>
|
|
</Col>
|
|
<Col span={8} key={2}>
|
|
<Col span={8} key={2}>
|
|
<Form.Item label="当前状态" name="status">
|
|
<Form.Item label="当前状态" name="status">
|
|
@@ -253,7 +246,7 @@ function UserManager() {
|
|
<Button type="primary" htmlType="submit">
|
|
<Button type="primary" htmlType="submit">
|
|
查询
|
|
查询
|
|
</Button>
|
|
</Button>
|
|
- <Button onClick={onReset}>
|
|
|
|
|
|
+ <Button onClick={onReset}>
|
|
重置
|
|
重置
|
|
</Button>
|
|
</Button>
|
|
</Space>
|
|
</Space>
|
|
@@ -262,9 +255,12 @@ function UserManager() {
|
|
</Row>
|
|
</Row>
|
|
</Form>
|
|
</Form>
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
<div className="table">
|
|
<div className="table">
|
|
<div className="table-header">
|
|
<div className="table-header">
|
|
- <h2 className="table-title">组织管理</h2>
|
|
|
|
|
|
+ <Breadcrumb>
|
|
|
|
+ <Breadcrumb.Item>用户管理</Breadcrumb.Item>
|
|
|
|
+ </Breadcrumb>
|
|
<Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增用户', true, 1)}>新增用户</Button>
|
|
<Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增用户', true, 1)}>新增用户</Button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -278,17 +274,24 @@ function UserManager() {
|
|
pageSize: 5,
|
|
pageSize: 5,
|
|
}} />
|
|
}} />
|
|
</div>
|
|
</div>
|
|
- <Modal
|
|
|
|
- title="提示"
|
|
|
|
- okText='确定'
|
|
|
|
- cancelText='取消'
|
|
|
|
- width={400}
|
|
|
|
- visible={visible}
|
|
|
|
- onOk={submit}
|
|
|
|
- onCancel={handleCancel}
|
|
|
|
- >
|
|
|
|
- <NormalPlayer title={title} visible={visible} type={type} ref={parentRef}></NormalPlayer>
|
|
|
|
- </Modal>
|
|
|
|
|
|
+ {visible && formData ?
|
|
|
|
+ <Modal
|
|
|
|
+ title={title}
|
|
|
|
+ okText='确定'
|
|
|
|
+ cancelText='取消'
|
|
|
|
+ width={'45%'}
|
|
|
|
+ height={'50%'}
|
|
|
|
+ visible={visible}
|
|
|
|
+ onCancel={cancel}
|
|
|
|
+ footer={null}
|
|
|
|
+ forceRender={true}
|
|
|
|
+ >
|
|
|
|
+ <UserContext.Provider value={{ userId: userId, type: type, formData: formData }}>
|
|
|
|
+ <AddUser userChange={userChange} />
|
|
|
|
+ </UserContext.Provider>
|
|
|
|
+
|
|
|
|
+ </Modal>
|
|
|
|
+ : ''}
|
|
<Modal
|
|
<Modal
|
|
title="提示"
|
|
title="提示"
|
|
okText='确定'
|
|
okText='确定'
|