|
@@ -1,9 +1,11 @@
|
|
|
import React, { useState, useEffect, useRef } from 'react';
|
|
|
-import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown, Modal, Breadcrumb, message, Row, Col } from 'antd';
|
|
|
+import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Modal, message, Row, Col, Tooltip } from 'antd';
|
|
|
import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
|
|
import '@common/common.less';
|
|
|
+import AddInpa from './addInpa'
|
|
|
import apiObj from '@api/index';
|
|
|
import { useSelector } from 'react-redux'
|
|
|
+import InpaContext from './inpa-context';
|
|
|
import utils from '@utils/index'
|
|
|
const { post, api, xPost } = apiObj;
|
|
|
const { organizationData } = utils;
|
|
@@ -11,89 +13,101 @@ const { Option } = Select;
|
|
|
function InpaManager() {
|
|
|
useEffect(() => {
|
|
|
getRegion();
|
|
|
+ // getDeptList()
|
|
|
}, []);
|
|
|
+ const [form] = Form.useForm();
|
|
|
const [userList, setUserList] = useState([]);
|
|
|
+ const [deptList, setDeptList] = useState([]);
|
|
|
const [title, setTitle] = useState("");
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
- const [userId, setUserId] = useState("");
|
|
|
+ const [id, setId] = useState("");
|
|
|
const [msvisible, setMsvisible] = useState(false);
|
|
|
const [modalType, setModalType] = useState("");
|
|
|
const [type, setType] = useState("");
|
|
|
const [formData, setFormData] = useState(null);
|
|
|
const [username, setUsername] = useState(null);
|
|
|
-
|
|
|
- const [form] = Form.useForm();
|
|
|
+ const [total, setTotal] = useState(0);
|
|
|
+ const { user, sysName } = useSelector((state) => {
|
|
|
+ return state.userInfo;
|
|
|
+ });
|
|
|
+ let params = {
|
|
|
+ pages: 1,
|
|
|
+ current: 1,
|
|
|
+ size: 15
|
|
|
+ }
|
|
|
const tipText = {
|
|
|
- 1: '确定要删除该用户?',
|
|
|
- 2: '禁用后该用户将无法登录,确定要禁用该用户?',
|
|
|
- 3: '确定要重置该用户密码?',
|
|
|
+ 1: '确定要删除该病区?',
|
|
|
+ 2: '确定要禁用该病区?',
|
|
|
};
|
|
|
const staticInfo = useSelector(state => {
|
|
|
return state.staticInfo;
|
|
|
});
|
|
|
const { statusList } = staticInfo;
|
|
|
//新增弹窗
|
|
|
- const showModal = (name, type, flag, userId) => {
|
|
|
+ const showModal = (name, type, flag, id) => {
|
|
|
setVisible(type);
|
|
|
setTitle(name);
|
|
|
setType(flag)
|
|
|
- setUserId(userId)
|
|
|
+ setId(id)
|
|
|
if (flag == 1) {
|
|
|
setFormData({
|
|
|
- status: '1'
|
|
|
+ hospitalName: user.name,
|
|
|
+ station: '病区',
|
|
|
+ status: 1
|
|
|
})
|
|
|
}
|
|
|
- if (flag == 3 || flag == 2) {
|
|
|
- getUserById(userId)
|
|
|
+ if (flag == 2) {
|
|
|
+ getRegionById(id)
|
|
|
}
|
|
|
}
|
|
|
//表格数据
|
|
|
function getRegion() {
|
|
|
- let param = {
|
|
|
- hospitalId:1
|
|
|
- }
|
|
|
- post(api.getRegion, param).then((res) => {
|
|
|
+ post(api.getRegion, params).then((res) => {
|
|
|
if (res.data.code === 200) {
|
|
|
const data = res.data.data;
|
|
|
setUserList(data.records);
|
|
|
+ setTotal(data.total)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ //科室列表
|
|
|
+ // function getDeptList(param = {}) {
|
|
|
+ // post(api.getDeptList, param).then((res) => {
|
|
|
+ // if (res.data.code === 200) {
|
|
|
+ // const data = res.data.data;
|
|
|
+ // setDeptList(data);
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
//查看用户
|
|
|
- function getUserById(userId) {
|
|
|
- xPost(api.getUserById, { userId: userId }).then((res) => {
|
|
|
+ function getRegionById(id) {
|
|
|
+ post(api.updateRegion, { mark: 1, id: id }).then((res) => {
|
|
|
if (res.data.code === 200) {
|
|
|
- const data = res.data.data;
|
|
|
- let roles = []
|
|
|
- data.roles.forEach(item => {
|
|
|
- roles.push(item.roleId)
|
|
|
- })
|
|
|
+ const data = res.data.data.records[0];
|
|
|
+ console.log(data)
|
|
|
const arr = {
|
|
|
- username: data.username,
|
|
|
- mobilePhone: data.mobilePhone,
|
|
|
- password: data.password,
|
|
|
- againpassword: data.password,
|
|
|
+ hospitalName: data.hospitalName,
|
|
|
name: data.name,
|
|
|
- idcard: data.idcard,
|
|
|
- // addHospitalTreeVO: organizationData(data.hospitals[0].children[0].children),
|
|
|
- titleId: data.titleId,
|
|
|
- jobNo: data.jobNo,
|
|
|
- roles: roles,
|
|
|
+ code: data.code,
|
|
|
+ liaison: data.liaison,
|
|
|
+ phoneNumber: data.phoneNumber,
|
|
|
+ station: '病区',
|
|
|
orderNo: data.orderNo,
|
|
|
- status: data.status,
|
|
|
+ status: data.status == '启用' ? '1' : '0',
|
|
|
}
|
|
|
setFormData(arr)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
// 禁用/启用接口
|
|
|
- function disableUser(userId, status) {
|
|
|
- const param = { userId: userId, status: status };
|
|
|
- xPost(api.disableUser, param).then((res) => {
|
|
|
+ function checkSolveRegion(id, mark) {
|
|
|
+ console.log(id)
|
|
|
+ const param = { id: id, mark: mark };
|
|
|
+ post(api.checkSolveRegion, param).then((res) => {
|
|
|
if (res.data.code === 200) {
|
|
|
getRegion();
|
|
|
setMsvisible(false);
|
|
|
- message.success((status ? '启用' : '禁用') + "成功");
|
|
|
+ message.success((mark == 2 ? '启用' : '禁用') + "成功");
|
|
|
} else {
|
|
|
message.warning(res.data.msg || '操作失败');
|
|
|
}
|
|
@@ -101,26 +115,13 @@ function InpaManager() {
|
|
|
message.error("接口出错");
|
|
|
});
|
|
|
}
|
|
|
- //重置密码
|
|
|
- function onResetPsd() {
|
|
|
- // const param = { HospitalId: operId };
|
|
|
- // xPost(api.disableHospital, param).then((res) => {
|
|
|
- // if (res.data.code === 200) {
|
|
|
- // getRegion();
|
|
|
- // message.success("重置成功");
|
|
|
- // } else {
|
|
|
- // message.warning(res.data.msg || '操作失败');
|
|
|
- // }
|
|
|
- // }).catch(() => {
|
|
|
- // message.error("接口出错");
|
|
|
- // });
|
|
|
- }
|
|
|
//删除
|
|
|
- function deleteUser() {
|
|
|
- const param = { userId: userId };
|
|
|
- xPost(api.deleteUser, param).then((res) => {
|
|
|
+ function deleteRegion() {
|
|
|
+ const param = { id: id };
|
|
|
+ xPost(api.deleteRegion, param).then((res) => {
|
|
|
if (res.data.code === 200) {
|
|
|
getRegion();
|
|
|
+ setMsvisible(false)
|
|
|
message.success("删除成功");
|
|
|
} else {
|
|
|
message.warning(res.data.msg || '操作失败');
|
|
@@ -129,9 +130,12 @@ function InpaManager() {
|
|
|
message.error("接口出错");
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
const onFinish = (value) => {
|
|
|
- getRegion(value);
|
|
|
+ params = {
|
|
|
+ ...params,
|
|
|
+ ...value
|
|
|
+ }
|
|
|
+ getRegion();
|
|
|
};
|
|
|
const onReset = () => {
|
|
|
form.resetFields();
|
|
@@ -139,18 +143,16 @@ function InpaManager() {
|
|
|
};
|
|
|
const messageBox = (type, id) => {
|
|
|
setMsvisible(true)
|
|
|
- setUserId(id)
|
|
|
+ setId(id)
|
|
|
setModalType(type)
|
|
|
+ console.log(type)
|
|
|
};
|
|
|
-
|
|
|
//提示框确认事件
|
|
|
function handleOk() {
|
|
|
if (modalType == 1) {
|
|
|
- deleteUser(userId)
|
|
|
+ deleteRegion(id)
|
|
|
} else if (modalType == 2) {
|
|
|
- disableUser(userId, 0)
|
|
|
- } else if (modalType == 3) {
|
|
|
- onResetPsd();
|
|
|
+ checkSolveRegion(id, 1)
|
|
|
}
|
|
|
}
|
|
|
//提示框取消
|
|
@@ -163,16 +165,38 @@ function InpaManager() {
|
|
|
}
|
|
|
function userChange() {
|
|
|
setVisible(false)
|
|
|
+ getRegion()
|
|
|
+ }
|
|
|
+ // function onSearch(val) {
|
|
|
+ // getDeptList({ deptName: val })
|
|
|
+ // }
|
|
|
+ function changePage(page, pageSize) {
|
|
|
+ params.current = page
|
|
|
+ params.size = pageSize
|
|
|
+ getRegion()
|
|
|
}
|
|
|
const columns = [
|
|
|
- { title: '用户名', dataIndex: 'username', key: 'index' },
|
|
|
- { title: '姓名', dataIndex: 'name', key: 'index' },
|
|
|
- { title: '所属组织', dataIndex: 'hospitalName', key: 'index' },
|
|
|
- { title: '工号', dataIndex: 'jobNo', key: 'index' },
|
|
|
+ { title: '病区名称', dataIndex: 'name', key: 'index' },
|
|
|
+ {
|
|
|
+ title: '所属病区', dataIndex: 'hospitalName', key: 'index',
|
|
|
+ onCell: () => {
|
|
|
+ return {
|
|
|
+ style: {
|
|
|
+ maxWidth: 150,
|
|
|
+ overflow: 'hidden',
|
|
|
+ whiteSpace: 'nowrap',
|
|
|
+ textOverflow: 'ellipsis',
|
|
|
+ cursor: 'pointer'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
|
|
|
+ },
|
|
|
+ // { title: '关联科室', dataIndex: 'deptName', key: 'index' },
|
|
|
{
|
|
|
title: '状态', dataIndex: 'status', key: 'status', render: (text, record) => (
|
|
|
<Space size="middle">
|
|
|
- {record.status == 1 ?
|
|
|
+ {record.status == '启用' ?
|
|
|
<span className="Enable">启用</span>
|
|
|
:
|
|
|
<span className="Disable">禁用</span>
|
|
@@ -180,83 +204,73 @@ function InpaManager() {
|
|
|
</Space>
|
|
|
)
|
|
|
},
|
|
|
+ { title: '创建时间', dataIndex: 'gmtCreate', key: 'index' },
|
|
|
{
|
|
|
title: '操作', dataIndex: 'key', render: (text, record) => (
|
|
|
<Space size="middle">
|
|
|
- <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}>
|
|
|
- <a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
|
|
|
- 更多 <DownOutlined />
|
|
|
- </a>
|
|
|
- </Dropdown>
|
|
|
+ <a onClick={e => showModal('修改用户', true, 2, record.id)} >修改</a>
|
|
|
+ {record.status === '启用' ? (<a onClick={() => messageBox(2, record.id)}>禁用</a>) : (<a onClick={() => checkSolveRegion(record.id, 2)}>启用</a>)}
|
|
|
+ <a target="_blank" onClick={() => messageBox(1, record.id)}>删除</a>
|
|
|
</Space>
|
|
|
)
|
|
|
}
|
|
|
]
|
|
|
- const menu = (record) => {
|
|
|
- return (
|
|
|
- <Menu>
|
|
|
- <Menu.Item key="0">
|
|
|
- <a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com">
|
|
|
- 重置密码
|
|
|
- </a>
|
|
|
- </Menu.Item>
|
|
|
- <Menu.Item key="1">
|
|
|
- {record.status === '1' ? (<a onClick={() => messageBox(2, record.userId)}>禁用</a>) : (<a onClick={() => disableUser(record.userId, 1)}>启用</a>)}
|
|
|
- </Menu.Item>
|
|
|
- <Menu.Item key="2">
|
|
|
- <a target="_blank" onClick={() => messageBox(1, record.userId)}>
|
|
|
- 删除
|
|
|
- </a>
|
|
|
- </Menu.Item>
|
|
|
- </Menu>
|
|
|
- )
|
|
|
- }
|
|
|
+
|
|
|
return (
|
|
|
<div className="wrapper">
|
|
|
<div className="filter-box">
|
|
|
<Form
|
|
|
form={form}
|
|
|
name="normal_login"
|
|
|
- className="basic"
|
|
|
onFinish={onFinish}
|
|
|
initialValues={{ status: '' }}
|
|
|
>
|
|
|
<Row gutter={24}>
|
|
|
- <Col span={6} key={0}>
|
|
|
- <Form.Item label="病区名称" name="username">
|
|
|
- <Input placeholder="请求方式" />
|
|
|
+ <Col span={5} key={0}>
|
|
|
+ <Form.Item label="病区名称" name="name">
|
|
|
+ <Input placeholder="病区名称" />
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
- <Col span={6} key={1}>
|
|
|
- <Form.Item label="管理科室" name="name">
|
|
|
- <Input placeholder="IP地址" />
|
|
|
+ {/* <Col span={5} key={1}>
|
|
|
+ <Form.Item label="关联科室" name="deptName">
|
|
|
+ <Select
|
|
|
+ allowClear
|
|
|
+ showSearch
|
|
|
+ placeholder="请选择"
|
|
|
+ onSearch={onSearch}
|
|
|
+ filterOption={(input, option) =>
|
|
|
+ option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
+ }
|
|
|
+ >
|
|
|
+ {deptList.map(item => {
|
|
|
+ return (
|
|
|
+ <Option value={item.id} key={item.id}>{item.name}</Option>
|
|
|
+ )
|
|
|
+ })}
|
|
|
+ </Select>
|
|
|
</Form.Item>
|
|
|
- </Col>
|
|
|
- <Col span={8} key={2}>
|
|
|
+ </Col> */}
|
|
|
+ <Col span={5} key={2}>
|
|
|
<Form.Item name="status" label="当前状态">
|
|
|
<Select
|
|
|
allowClear
|
|
|
>
|
|
|
- {statusList.map((item) => {
|
|
|
+ {statusList.map((item, index) => {
|
|
|
return (
|
|
|
- <Option value={item.name} key={item.name}>{item.val}</Option>
|
|
|
+ <Option value={item.name} key={index}>{item.val}</Option>
|
|
|
)
|
|
|
})}
|
|
|
</Select>
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
- <Col span={4} key={3}>
|
|
|
+ <Col span={6} key={3}>
|
|
|
<Form.Item>
|
|
|
- <Space size="middle">
|
|
|
- <Button type="primary" htmlType="submit">
|
|
|
- 查询
|
|
|
+ <Button type="primary" htmlType="submit">
|
|
|
+ 查询
|
|
|
</Button>
|
|
|
- <Button onClick={onReset}>
|
|
|
- 重置
|
|
|
+ <Button onClick={onReset}>
|
|
|
+ 重置
|
|
|
</Button>
|
|
|
- </Space>
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
</Row>
|
|
@@ -265,22 +279,40 @@ function InpaManager() {
|
|
|
|
|
|
<div className="table">
|
|
|
<div className="table-header">
|
|
|
- <Breadcrumb>
|
|
|
- <Breadcrumb.Item>异常日志</Breadcrumb.Item>
|
|
|
- </Breadcrumb>
|
|
|
+ <h2 className="table-title">病区管理</h2>
|
|
|
+ <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增病区', true, 1)}>新增病区</Button>
|
|
|
</div>
|
|
|
|
|
|
<Table
|
|
|
columns={columns}
|
|
|
dataSource={userList}
|
|
|
- rowKey={record => record.userId}
|
|
|
+ rowKey={record => record.id}
|
|
|
pagination={{
|
|
|
- showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 15,
|
|
|
pageSizeOptions: ['15', '30', '60', '120'],
|
|
|
- pageSize: 5,
|
|
|
+ showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
|
|
|
+ onShowSizeChange: (current, pageSize) => this.pageSize = pageSize, // 改变每页数量时更新显示
|
|
|
+ onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
|
|
|
+ total: total
|
|
|
}} />
|
|
|
</div>
|
|
|
-
|
|
|
+ {visible && formData ?
|
|
|
+ <Modal
|
|
|
+ title={title}
|
|
|
+ okText='确定'
|
|
|
+ cancelText='取消'
|
|
|
+ width={'35%'}
|
|
|
+ visible={visible}
|
|
|
+ onCancel={cancel}
|
|
|
+ footer={null}
|
|
|
+ forceRender={true}
|
|
|
+ >
|
|
|
+ <InpaContext.Provider value={{ id: id, type: type, formData: formData }}>
|
|
|
+ <AddInpa userChange={userChange} />
|
|
|
+ </InpaContext.Provider>
|
|
|
+ </Modal>
|
|
|
+ : ''}
|
|
|
<Modal
|
|
|
title="提示"
|
|
|
okText='确定'
|