Commit ab27a766 authored by 叶飞's avatar 叶飞

fix: notice

parent 6151b3f5
...@@ -2,13 +2,8 @@ module.exports = { ...@@ -2,13 +2,8 @@ module.exports = {
dev: { dev: {
'/CityInterface': { '/CityInterface': {
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
<<<<<<< HEAD
// target: 'https://panda-water.cn',
target: 'https://panda-water.com',
=======
target: 'https://panda-water.cn', target: 'https://panda-water.cn',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
>>>>>>> 933261f5fb1407b8a8e5c423964807f4542a36bb
// target: 'http://192.168.19.103:8112', // target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
...@@ -22,13 +17,8 @@ module.exports = { ...@@ -22,13 +17,8 @@ module.exports = {
}, },
'/cityinterface': { '/cityinterface': {
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
<<<<<<< HEAD
// target: 'https://panda-water.cn',
target: 'https://panda-water.com',
=======
target: 'https://panda-water.cn', target: 'https://panda-water.cn',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
>>>>>>> 933261f5fb1407b8a8e5c423964807f4542a36bb
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
changeOrigin: true, changeOrigin: true,
...@@ -43,13 +33,8 @@ module.exports = { ...@@ -43,13 +33,8 @@ module.exports = {
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
<<<<<<< HEAD
// target: 'https://panda-water.cn',
target: 'https://panda-water.com',
=======
target: 'https://panda-water.cn', target: 'https://panda-water.cn',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
>>>>>>> 933261f5fb1407b8a8e5c423964807f4542a36bb
changeOrigin: true, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
......
...@@ -29,17 +29,24 @@ class NoticeList extends React.Component { ...@@ -29,17 +29,24 @@ class NoticeList extends React.Component {
this.state = { this.state = {
isLoading: false, isLoading: false,
}; };
this.mounted=false;
this.handleScrollCallback=this.throttle(this.handleScroll.bind(this), 30).bind(this);
} }
componentDidMount() { componentDidMount() {
this.mounted=true;
if (this.container.current) { if (this.container.current) {
this.container.current.addEventListener( this.container.current.addEventListener(
'scroll', 'scroll',
this.throttle(this.handleScroll.bind(this), 30), this.handleScrollCallback,
); );
} }
} }
componentWillUnmount(){
this.mounted=false;
}
throttle(fn, wait) { throttle(fn, wait) {
var pre = Date.now(); var pre = Date.now();
return function() { return function() {
...@@ -55,6 +62,7 @@ class NoticeList extends React.Component { ...@@ -55,6 +62,7 @@ class NoticeList extends React.Component {
handleScroll(e) { handleScroll(e) {
e.stopPropagation(); e.stopPropagation();
if(!this.mounted) return;
if (!this.container.current) return; if (!this.container.current) return;
let current = this.container.current; let current = this.container.current;
if ( if (
...@@ -75,11 +83,10 @@ class NoticeList extends React.Component { ...@@ -75,11 +83,10 @@ class NoticeList extends React.Component {
() => { () => {
if (!this.loadMore) return; if (!this.loadMore) return;
this.loadMore().then(data => { this.loadMore().then(data => {
if(!this.mounted) return;
this.setState({ this.setState({
isLoading: false, isLoading: false,
}); });
this.forceUpdate();
console.log("开始更新了。。。。。",data);
}); });
}, },
); );
......
...@@ -4,22 +4,41 @@ import commonStyles from '../common.less'; ...@@ -4,22 +4,41 @@ import commonStyles from '../common.less';
import classNames from 'classnames'; import classNames from 'classnames';
const Unknown = ({ message, confirmRead }) => { const Unknown = ({ message, confirmRead }) => {
let alarmContent = message.infoContent; console.log('未知类型消息', message);
let content = '';
try {
let type = typeof message.infoContent;
switch (type) {
case 'object':
content = JSON.stringify(message.infoContent);
break;
case 'string':
content = message.infoContent;
break;
default:
break;
}
} catch (e) {
console.log;
}
return ( return (
<div className={classNames(styles.unknown,commonStyles.messageContainer) } title="点击查看详情"> <div
className={classNames(styles.unknown, commonStyles.messageContainer)}
title="点击查看详情"
>
<div className={commonStyles.title}> <div className={commonStyles.title}>
<span>消息</span> <span>消息</span>
<img <img
className={commonStyles.confirm} className={commonStyles.confirm}
title="点击标为已读" title="点击标为已读"
onClick={() => { onClick={() => {
confirmRead(false,[message.id]); confirmRead(false, [message.id]);
}} }}
src="https://panda-water.cn/Web4/assets/images/message/%E5%8B%BE%E6%B5%85.png" src="https://panda-water.cn/Web4/assets/images/message/%E5%8B%BE%E6%B5%85.png"
/> />
</div> </div>
<div className={commonStyles.content}> <div className={commonStyles.content}>
<p>{message.infoContent}</p> <p>{content}</p>
<p className={commonStyles.messageTime}>{message.time}</p> <p className={commonStyles.messageTime}>{message.time}</p>
</div> </div>
</div> </div>
......
...@@ -68,9 +68,9 @@ class Notifier { ...@@ -68,9 +68,9 @@ class Notifier {
// 对外接口 // 对外接口
async start() { async start() {
window.cc=this.messageCache; window.cc = this.messageCache;
this._getMqttSiteCode().then(() => { this._getMqttSiteCode().then(() => {
this.loadHisMessages(this.currentPageIndex,this.currentPageSize); this.loadHisMessages(this.currentPageIndex, this.currentPageSize);
this.connectMQTTServer(); this.connectMQTTServer();
}); });
} }
...@@ -108,7 +108,7 @@ class Notifier { ...@@ -108,7 +108,7 @@ class Notifier {
try { try {
handler(payload); handler(payload);
} catch (e) { } catch (e) {
console.log('订阅器委托错误'); console.log('订阅器委托错误' + e.message);
} }
}); });
} }
...@@ -135,7 +135,7 @@ class Notifier { ...@@ -135,7 +135,7 @@ class Notifier {
if (isAll) { if (isAll) {
me.messageCache.totalCount = 0; me.messageCache.totalCount = 0;
me.messageCache.messages = []; me.messageCache.messages = [];
me.currentPageIndex= 1; me.currentPageIndex = 1;
} else { } else {
hisIDs.forEach(id => { hisIDs.forEach(id => {
let index = me.messageCache.messages.findIndex( let index = me.messageCache.messages.findIndex(
...@@ -160,7 +160,7 @@ class Notifier { ...@@ -160,7 +160,7 @@ class Notifier {
} }
loadMore(callback) { loadMore(callback) {
if (!this.hasMore()) return Promise.resolve([]); if (!this.hasMore()) return Promise.resolve([]);
this.currentPageIndex+=1; this.currentPageIndex += 1;
return this.loadHisMessages(this.currentPageIndex, this.currentPageSize); return this.loadHisMessages(this.currentPageIndex, this.currentPageSize);
} }
...@@ -292,7 +292,7 @@ class Notifier { ...@@ -292,7 +292,7 @@ class Notifier {
} }
// 工具类 // 工具类
async loadHisMessages(pageIndex,pageSize) { async loadHisMessages(pageIndex, pageSize) {
let me = this; let me = this;
return Http.getInformationInfo({ return Http.getInformationInfo({
userID: me.userInfo.OID, userID: me.userInfo.OID,
...@@ -312,6 +312,10 @@ class Notifier { ...@@ -312,6 +312,10 @@ class Notifier {
}); });
index == -1 && me.messageCache.messages.push(message); index == -1 && me.messageCache.messages.push(message);
}); });
if(me.messageCache.totalCount > me.messageCache.messages.length && res.getMe.length==0){
// 服务端返回总数还有,但是查不到数据了,前端修正服务端返回的总数
me.messageCache.totalCount=me.messageCache.messages.length;
};
me.publish(NEW_MESSAGE, me.messageCache); me.publish(NEW_MESSAGE, me.messageCache);
return Promise.resolve(result); return Promise.resolve(result);
}); });
...@@ -379,6 +383,7 @@ class Notifier { ...@@ -379,6 +383,7 @@ class Notifier {
infoType = 'remindType'; infoType = 'remindType';
break; break;
case 'SCADA报警': case 'SCADA报警':
case '':
infoType = 'scadaType'; infoType = 'scadaType';
default: default:
break; break;
...@@ -423,23 +428,30 @@ class Notifier { ...@@ -423,23 +428,30 @@ class Notifier {
} }
_handleMessageStrToJSON(infoType, messString) { _handleMessageStrToJSON(infoType, messString) {
let infoContent = messString; let infoContent = messString;
switch (infoType) { try{
case 'scadaType': switch (infoType) {
infoContent = this._analysisAlarm(messString); case 'scadaType':
break; infoContent = this._analysisAlarm(messString);
case 'caseType': break;
infoContent = this._analysisCase(messString); case 'caseType':
break; infoContent = this._analysisCase(messString);
case 'sysType': break;
infoContent = this._analysisNotice(messString); case 'sysType':
break; infoContent = this._analysisNotice(messString);
case 'saveWaType': break;
break; case 'saveWaType':
case 'EIMType': break;
break; case 'EIMType':
default: break;
break; case 'unknown':
break;
default:
break;
}
}catch(e){
console.log("1.0消息通知解析消息内容出错:"+e.message,"消息对象:",messString);
} }
return infoContent; return infoContent;
} }
_analysisCase(messString) { _analysisCase(messString) {
...@@ -482,7 +494,6 @@ class Notifier { ...@@ -482,7 +494,6 @@ class Notifier {
}; };
return noticeContent; return noticeContent;
} }
} }
export default Notifier; export default Notifier;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment