|
@@ -1,14 +1,18 @@
|
|
|
import { Layout, Dropdown ,Menu } from 'antd';
|
|
|
import { withRouter } from 'react-router'
|
|
|
import { useState, useEffect } from 'react';
|
|
|
-import { useSelector } from 'react-redux';
|
|
|
+import { useSelector,useDispatch } from 'react-redux';
|
|
|
import utils from '@utils/index';
|
|
|
import logo from '@images/logo.png';
|
|
|
import msg from '@images/msg.png';
|
|
|
import me from '@images/me.png';
|
|
|
import down from '@images/down.png';
|
|
|
import './index.less'
|
|
|
+import {message} from "antd/lib/index";
|
|
|
+import { setSys,setUser } from '@reducers/userInfo.js';
|
|
|
+import apiObj from '@api/index';
|
|
|
|
|
|
+const {xPost,api} = apiObj;
|
|
|
const propTypes = {
|
|
|
|
|
|
}
|
|
@@ -16,6 +20,7 @@ const defaultProps = {};
|
|
|
const { Header } = Layout;
|
|
|
const { getTimeDetail } = utils;
|
|
|
function AHeader({ history,hideName }){
|
|
|
+ const dispatch = useDispatch();
|
|
|
const [dateTime,setDateTime] = useState('');
|
|
|
const { user, sysName} = useSelector((state)=>{
|
|
|
return state.userInfo;
|
|
@@ -23,8 +28,28 @@ function AHeader({ history,hideName }){
|
|
|
//退出
|
|
|
function loginOut(){
|
|
|
localStorage.removeItem("token");
|
|
|
+ localStorage.removeItem("systemId");
|
|
|
+ localStorage.removeItem("hospitalId");
|
|
|
history.push('/login');
|
|
|
}
|
|
|
+ //获取组织列表
|
|
|
+ function getOrgList(){
|
|
|
+ xPost(api.getUserHospitals).then((res)=>{
|
|
|
+ if(res.data.code===200){
|
|
|
+ const data = res.data.data;
|
|
|
+ const { userInfo,software } = data;
|
|
|
+ const sysId = localStorage.getItem("systemId");
|
|
|
+ const hisId = localStorage.getItem("hospitalId");
|
|
|
+ const sys = software.find((it)=>{return +it.id===+sysId});
|
|
|
+ dispatch(setUser(userInfo));
|
|
|
+ dispatch(setSys({sysId,sysName:sys.name,hisId}));
|
|
|
+ }else{
|
|
|
+ message.warning(res.data.msg||'获取医院列表失败');
|
|
|
+ }
|
|
|
+ }).catch(()=>{
|
|
|
+ message.error("接口出错");
|
|
|
+ });
|
|
|
+ }
|
|
|
//修改密码
|
|
|
function changePsd(){
|
|
|
|
|
@@ -38,6 +63,9 @@ function AHeader({ history,hideName }){
|
|
|
}
|
|
|
useEffect(()=>{
|
|
|
countTime();
|
|
|
+ if(!user.name){
|
|
|
+ getOrgList();
|
|
|
+ }
|
|
|
return function clearUp(){
|
|
|
clearInterval(interVal)
|
|
|
}
|