|
@@ -12,7 +12,7 @@ import down from '@images/down.png';
|
|
|
import './index.less'
|
|
|
import { message } from "antd/lib/index";
|
|
|
import { add, active } from '@reducers/tabPanes'
|
|
|
-import { setSys, setUser} from '@reducers/userInfo.js';
|
|
|
+/*import { setSys, setUser} from '@reducers/userInfo.js';*/
|
|
|
import apiObj from '@api/index';
|
|
|
|
|
|
const { post, api, xPost } = apiObj;
|
|
@@ -30,8 +30,14 @@ function AHeader({ history, hideName }) {
|
|
|
const [form] = Form.useForm();
|
|
|
const [dateTime, setDateTime] = useState('');
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
- //const [socket,setSocket] = useState(null);
|
|
|
const [unReadNum,setUnReadNum] = useState(0);
|
|
|
+ const [systemName,setSystemName] = useState("");
|
|
|
+ //const [userName,setUserName] = useState("");
|
|
|
+ console.log(11)
|
|
|
+ const userName = getCookie("userName");
|
|
|
+ const hospitalId = getCookie("hospitalId");
|
|
|
+ const softwareArr = JSON.parse(localStorage.getItem("software"));
|
|
|
+
|
|
|
const { user, sysName } = useSelector((state) => {
|
|
|
return state.userInfo;
|
|
|
});
|
|
@@ -42,8 +48,6 @@ function AHeader({ history, hideName }) {
|
|
|
localStorage.removeItem("hospitalId");
|
|
|
localStorage.removeItem("software")
|
|
|
setCookie();
|
|
|
- /*localStorage.removeItem("systemId");
|
|
|
- localStorage.removeItem("hospitalId");*/
|
|
|
dispatch(panesNow([]));
|
|
|
history.push('/login');
|
|
|
}
|
|
@@ -56,7 +60,6 @@ function AHeader({ history, hideName }) {
|
|
|
count = count>99?'99+':count;
|
|
|
setUnReadNum(count)
|
|
|
initWebsocket(count);
|
|
|
- //dispatch(setUnReadNum(count));
|
|
|
} else {
|
|
|
//message.warning(res.data.msg || '请求失败');
|
|
|
}
|
|
@@ -76,16 +79,12 @@ function AHeader({ history, hideName }) {
|
|
|
}
|
|
|
async function initWebsocket(num){
|
|
|
const mqtt = require('mqtt');
|
|
|
- const client = mqtt.connect('ws://192.168.2.237:15675/ws');
|
|
|
- //const userInfo = await getUserHos();
|
|
|
- //const userdata = userInfo.data.data;
|
|
|
- //handleUserInfo(userdata);
|
|
|
- const hisId = getCookie("hospitalId");
|
|
|
- //setSocket(client)
|
|
|
+ const client = mqtt.connect(api.websocketUrl);
|
|
|
+ //const hisId = getCookie("hospitalId");
|
|
|
client.on('connect', function () {
|
|
|
- client.subscribe(hisId+"-"+user.id, function (err) {
|
|
|
+ client.subscribe(hospitalId+"-"+user.id, function (err) {
|
|
|
if (!err) {
|
|
|
- console.log(hisId+"-"+user.id+"订阅成功")
|
|
|
+ console.log(hospitalId+"-"+user.id+"订阅成功")
|
|
|
}
|
|
|
})
|
|
|
})
|
|
@@ -96,7 +95,16 @@ function AHeader({ history, hideName }) {
|
|
|
console.log('收到消息+1:',message.toString())
|
|
|
})
|
|
|
}
|
|
|
- function handleUserInfo(data){
|
|
|
+ //获取系统、用户名称用于页头显示
|
|
|
+ function getSysName(){
|
|
|
+ const mySys = (softwareArr||[]).find((it)=>{
|
|
|
+ return it.id === +hospitalId;
|
|
|
+ });
|
|
|
+ if(mySys){
|
|
|
+ setSystemName(mySys.name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*function handleUserInfo(data){
|
|
|
const { userInfo, software } = data;
|
|
|
const sysId = getCookie("systemId");
|
|
|
const hisId = getCookie("hospitalId");
|
|
@@ -113,7 +121,7 @@ function AHeader({ history, hideName }) {
|
|
|
resolve(res);
|
|
|
});
|
|
|
});
|
|
|
- }
|
|
|
+ }*/
|
|
|
//修改密码
|
|
|
function changePsd() {
|
|
|
setVisible(true)
|
|
@@ -138,13 +146,9 @@ function AHeader({ history, hideName }) {
|
|
|
})
|
|
|
}
|
|
|
useEffect(() => {
|
|
|
+ getSysName();
|
|
|
countTime();
|
|
|
getNotNoticeCount();
|
|
|
- //initWebsocket();
|
|
|
- /*if (!user.name) {
|
|
|
- //刷新操作时重新获取数据
|
|
|
- //getOrgList();
|
|
|
- }*/
|
|
|
return function clearUp() {
|
|
|
clearInterval(interVal)
|
|
|
}
|
|
@@ -162,7 +166,7 @@ function AHeader({ history, hideName }) {
|
|
|
<Header className='page-header'>
|
|
|
<img className='logo' src={logo} alt="" />
|
|
|
{hideName ? '' : <><span className='break-line'>|</span>
|
|
|
- <span className='sys-name'>{sysName}</span></>}
|
|
|
+ <span className='sys-name'>{systemName}</span></>}
|
|
|
<div className='infos'>
|
|
|
<span className='time'>{dateTime}</span>
|
|
|
<span className='break-line'>|</span>
|
|
@@ -174,7 +178,7 @@ function AHeader({ history, hideName }) {
|
|
|
<Dropdown overlay={menu} trigger={['click']}>
|
|
|
<span className="ant-dropdown-link" onClick={e => e.preventDefault()}>
|
|
|
<img className='user-icon' src={me} alt="用户头像" />
|
|
|
- <i className='user-name'>{user.name}</i>
|
|
|
+ <i className='user-name'>{userName}</i>
|
|
|
<img src={down} alt="" />
|
|
|
</span>
|
|
|
</Dropdown>
|