|
@@ -1,53 +1,158 @@
|
|
import {useEffect,useState} from 'react';
|
|
import {useEffect,useState} from 'react';
|
|
import { useDispatch,useSelector } from 'react-redux'
|
|
import { useDispatch,useSelector } from 'react-redux'
|
|
-import { Table, Badge, Menu, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
|
|
|
|
|
|
+import { Table,Modal, message, Menu, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
|
|
import { DownOutlined } from '@ant-design/icons';
|
|
import { DownOutlined } from '@ant-design/icons';
|
|
import './index.less';
|
|
import './index.less';
|
|
import apiObj from '@api/index';
|
|
import apiObj from '@api/index';
|
|
|
|
+import utils from '@utils/index';
|
|
|
|
|
|
-const {post,api} = apiObj;
|
|
|
|
|
|
+const {post,api,xPost} = apiObj;
|
|
|
|
+const { handleResponse } = utils;
|
|
const { Option } = Select;
|
|
const { Option } = Select;
|
|
function OrgManager(){
|
|
function OrgManager(){
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
+ getFilterList();
|
|
getTableData();
|
|
getTableData();
|
|
},[]);
|
|
},[]);
|
|
|
|
|
|
const [dataSource, setDataSource] = useState([]);
|
|
const [dataSource, setDataSource] = useState([]);
|
|
- //const [filterData, setFilterData] = useState({});
|
|
|
|
|
|
+ const [typeList,setTypeList] = useState([]);
|
|
|
|
+ const [visible,setVisible] = useState(false);
|
|
|
|
+ const [confirmLoading, setConfirmLoading] = useState(false);
|
|
|
|
+ //弹窗类型:1删除 2有子组织删除 3有用户删除 4禁用 5有子组织禁用 6有用户禁用 7重置密码
|
|
|
|
+ const [modalType,setModalType] = useState(1);
|
|
|
|
+ const [operId,setOperId] = useState('');
|
|
|
|
+ const tipText={
|
|
|
|
+ 1:'确定要删除该组织?',
|
|
|
|
+ 2:'当前组织存在子组织,删除后子组织将一并被删除',
|
|
|
|
+ 3:'当前组织或子组织存在用户,删除后用户将一并被删除',
|
|
|
|
+ 4:'确定要禁用该组织?',
|
|
|
|
+ 5:'当前组织存在子组织,禁用后子组织将一并被禁用',
|
|
|
|
+ 6:'当前组织或子组织存在用户,禁用后用户将一并被禁用',
|
|
|
|
+ 7:'确定要重置该组织密码?',
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ //获取筛选下拉数据
|
|
|
|
+ function getFilterList(){
|
|
|
|
+ post(api.getManagerBoxInfo).then((res)=>{
|
|
|
|
+ if(res.data.code===200){
|
|
|
|
+ const data = res.data.data;
|
|
|
|
+ setTypeList(data["类型"]);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ //获取表格数据
|
|
function getTableData(param={}){
|
|
function getTableData(param={}){
|
|
- //const param = filterData;
|
|
|
|
post(api.getHospitalListInfo,param).then((res)=>{
|
|
post(api.getHospitalListInfo,param).then((res)=>{
|
|
if(res.data.code===200){
|
|
if(res.data.code===200){
|
|
const data = res.data.data;
|
|
const data = res.data.data;
|
|
- setDataSource(data[0].hospitalDTOS);
|
|
|
|
|
|
+ setDataSource(data);
|
|
}
|
|
}
|
|
|
|
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- function RenderTable(){
|
|
|
|
- const menu = (
|
|
|
|
- <Menu>
|
|
|
|
- <Menu.Item key="0">重置密码</Menu.Item>
|
|
|
|
- <Menu.Item key="1">禁用</Menu.Item>
|
|
|
|
- <Menu.Item key="3">删除</Menu.Item>
|
|
|
|
- </Menu>
|
|
|
|
- );
|
|
|
|
|
|
+ //启用/禁用
|
|
|
|
+ function enable(flag) {
|
|
|
|
+ const param = {HospitalId:operId,status:flag};
|
|
|
|
+ xPost(api.disableHospital,param).then((res)=>{
|
|
|
|
+ if(res.data.code===200){
|
|
|
|
+ getTableData();
|
|
|
|
+ message.success((flag?'启用':'禁用')+"成功");
|
|
|
|
+ }else{
|
|
|
|
+ message.warning(res.data.msg||'操作失败');
|
|
|
|
+ }
|
|
|
|
+ }).catch(()=>{
|
|
|
|
+ message.error("接口出错");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //重置密码
|
|
|
|
+ function onResetPsd(){
|
|
|
|
+ const param = {HospitalId:operId};
|
|
|
|
+ xPost(api.disableHospital,param).then((res)=>{
|
|
|
|
+ if(res.data.code===200){
|
|
|
|
+ getTableData();
|
|
|
|
+ message.success("重置成功");
|
|
|
|
+ }else{
|
|
|
|
+ message.warning(res.data.msg||'操作失败');
|
|
|
|
+ }
|
|
|
|
+ }).catch(()=>{
|
|
|
|
+ message.error("接口出错");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //删除
|
|
|
|
+ function onDelete(){
|
|
|
|
+ const param = {HospitalId:operId};
|
|
|
|
+ xPost(api.deleteHospital,param).then((res)=>{
|
|
|
|
+ if(res.data.code===200){
|
|
|
|
+ getTableData();
|
|
|
|
+ message.success("删除成功");
|
|
|
|
+ }else{
|
|
|
|
+ message.warning(res.data.msg||'操作失败');
|
|
|
|
+ }
|
|
|
|
+ }).catch(()=>{
|
|
|
|
+ message.error("接口出错");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //显示弹窗
|
|
|
|
+ function showModal(type,id){
|
|
|
|
+ setModalType(type);
|
|
|
|
+ setOperId(id);
|
|
|
|
+ setVisible(true);
|
|
|
|
+ }
|
|
|
|
+ //弹窗确认事件
|
|
|
|
+ function handleOk(type){
|
|
|
|
+ if("1,2,3".indexOf(type)>-1){
|
|
|
|
+ onDelete();
|
|
|
|
+ }else if("4,5,6".indexOf(type)>-1){
|
|
|
|
+ enable(0);
|
|
|
|
+ }else if(type===7){
|
|
|
|
+ onResetPsd();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ //弹窗取消
|
|
|
|
+ function handleCancel(){
|
|
|
|
+ setVisible(false);
|
|
|
|
+ }
|
|
|
|
+ //表格渲染
|
|
|
|
+ function RenderTable(){
|
|
const columns = [
|
|
const columns = [
|
|
{ title: '组织机构层级', dataIndex: 'hospitalName', key: 'hospitalName' },
|
|
{ title: '组织机构层级', dataIndex: 'hospitalName', key: 'hospitalName' },
|
|
- { title: '类型', dataIndex: 'type', key: 'type' },
|
|
|
|
- { title: '状态', dataIndex: 'status', key: 'status' },
|
|
|
|
|
|
+ { title: '类型', key: 'type',render:(row)=>{
|
|
|
|
+ if(row.children){
|
|
|
|
+ return '-'
|
|
|
|
+ }else{
|
|
|
|
+ return row.type;
|
|
|
|
+ }
|
|
|
|
+ } },
|
|
|
|
+ { title: '状态', key: 'status',render:(row)=>{
|
|
|
|
+ if(row.children){
|
|
|
|
+ return '-'
|
|
|
|
+ }else{
|
|
|
|
+ return row.status;
|
|
|
|
+ }
|
|
|
|
+ } },
|
|
{ title: '创建时间', dataIndex: 'gmtCreate', key: 'gmtCreate' },
|
|
{ title: '创建时间', dataIndex: 'gmtCreate', key: 'gmtCreate' },
|
|
- { title: '操作', key: 'operation', render: () => (<Space size="middle">
|
|
|
|
|
|
+ { title: '操作', key: 'operation', render: (row) => {
|
|
|
|
+ //console.log(21,row)
|
|
|
|
+ if(row.children){
|
|
|
|
+ return '-'
|
|
|
|
+ }
|
|
|
|
+ const menu = (
|
|
|
|
+ <Menu>
|
|
|
|
+ <Menu.Item key="0" onClick={(row)=>showModal(7,row.hospitalId)}>重置密码</Menu.Item>
|
|
|
|
+ <Menu.Item key="1" onClick={(row)=>showModal(1,row.hospitalId)}>删除</Menu.Item>
|
|
|
|
+ </Menu>
|
|
|
|
+ );
|
|
|
|
+ return (<Space size="middle">
|
|
<a>修改</a>
|
|
<a>修改</a>
|
|
- <a>启用</a>
|
|
|
|
|
|
+ {row.status==='1'?(<a onClick={()=>showModal(4,row.hospitalId)}>禁用</a>):(<a onClick={()=>enable(row,1)}>启用</a>)}
|
|
<Dropdown overlay={menu} trigger={['click']}>
|
|
<Dropdown overlay={menu} trigger={['click']}>
|
|
<a className="ant-dropdown-link">
|
|
<a className="ant-dropdown-link">
|
|
更多 <DownOutlined />
|
|
更多 <DownOutlined />
|
|
</a>
|
|
</a>
|
|
</Dropdown>
|
|
</Dropdown>
|
|
- </Space>) },
|
|
|
|
|
|
+ </Space>) }},
|
|
];
|
|
];
|
|
return (
|
|
return (
|
|
<Table
|
|
<Table
|
|
@@ -58,14 +163,12 @@ function OrgManager(){
|
|
/>
|
|
/>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //筛选项渲染
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
-
|
|
|
|
const onFinish = (values: any) => {
|
|
const onFinish = (values: any) => {
|
|
getTableData(values);
|
|
getTableData(values);
|
|
console.log('筛选项:',values);
|
|
console.log('筛选项:',values);
|
|
};
|
|
};
|
|
-
|
|
|
|
const onReset = () => {
|
|
const onReset = () => {
|
|
form.resetFields();
|
|
form.resetFields();
|
|
getTableData();
|
|
getTableData();
|
|
@@ -82,13 +185,17 @@ function OrgManager(){
|
|
</Form.Item>
|
|
</Form.Item>
|
|
</Col>
|
|
</Col>
|
|
<Col span={5} key={1}>
|
|
<Col span={5} key={1}>
|
|
|
|
+
|
|
<Form.Item name="type" label="类型">
|
|
<Form.Item name="type" label="类型">
|
|
<Select
|
|
<Select
|
|
allowClear
|
|
allowClear
|
|
>
|
|
>
|
|
<Option value="">全部</Option>
|
|
<Option value="">全部</Option>
|
|
- <Option value="female">集团医院</Option>
|
|
|
|
- <Option value="other">医共体</Option>
|
|
|
|
|
|
+ {/*{typeList.map((item)=>{
|
|
|
|
+ return (
|
|
|
|
+ <Option value={item.value}>{item.name}</Option>
|
|
|
|
+ )
|
|
|
|
+ })}*/}
|
|
</Select>
|
|
</Select>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
</Col>
|
|
</Col>
|
|
@@ -116,7 +223,20 @@ function OrgManager(){
|
|
</Row>
|
|
</Row>
|
|
</Form>
|
|
</Form>
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
<RenderTable />
|
|
<RenderTable />
|
|
|
|
+ <Modal
|
|
|
|
+ title="提示"
|
|
|
|
+ okText='确定'
|
|
|
|
+ cancelText='取消'
|
|
|
|
+ width={400}
|
|
|
|
+ visible={visible}
|
|
|
|
+ onOk={handleOk}
|
|
|
|
+ confirmLoading={confirmLoading}
|
|
|
|
+ onCancel={handleCancel}
|
|
|
|
+ >
|
|
|
|
+ <p>{tipText[modalType]}</p>
|
|
|
|
+ </Modal>
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|
|
}
|
|
}
|