import {useEffect,useState} from 'react'; import { useDispatch,useSelector } from 'react-redux' import { Table,Modal, message, Menu, Breadcrumb, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd'; import { DownOutlined,PlusOutlined } from '@ant-design/icons'; import AddSubOrg from './AddSubOrg'; import './index.less'; import apiObj from '@api/index'; import utils from '@utils/index'; const {post,api,xPost} = apiObj; const { handleResponse } = utils; const { Option } = Select; function OrgManager(){ useEffect(() => { getFilterList(); getTableData(); },[]); const [dataSource, setDataSource] = useState([]); const [typeList,setTypeList] = useState([]); const [visible,setVisible] = useState(false); const [addVisible,setAddVisible] = 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={}){ post(api.getHospitalListInfo,param).then((res)=>{ if(res.data.code===200){ const data = res.data.data; setDataSource(data); } }) } //启用/禁用 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 showAddModal(){ setAddVisible(true); } //表格渲染 function RenderTable(){ const columns = [ { title: '组织机构层级', dataIndex: 'hospitalName', key: 'hospitalName' }, { 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: '操作', key: 'operation', render: (row) => { //console.log(21,row) if(row.children){ return '-' } const menu = ( showModal(7,row.hospitalId)}>重置密码 showModal(1,row.hospitalId)}>删除 ); return ( 修改 {row.status==='1'?(showModal(4,row.hospitalId)}>禁用):(enable(row,1)}>启用)} 更多 ) }}, ]; return ( record.hospitalId} columns={columns} dataSource={dataSource} /> ) } //筛选项渲染 const [form] = Form.useForm(); const onFinish = (values: any) => { getTableData(values); console.log('筛选项:',values); }; const onReset = () => { form.resetFields(); getTableData(); }; return (
组织管理

{tipText[modalType]}

) } export default OrgManager;