|
@@ -1,11 +1,15 @@
|
|
|
import PageContent from '@/components/PageContent';
|
|
|
import TabsContent from '@/components/TabsContent';
|
|
|
-import { getNotificationList } from '@/services/message';
|
|
|
+import {
|
|
|
+ getAllRead,
|
|
|
+ getNotificationList,
|
|
|
+ readNotification,
|
|
|
+} from '@/services/message';
|
|
|
import { UnityAction } from '@/utils/utils';
|
|
|
import { useParams, useRequest, useSearchParams } from '@umijs/max';
|
|
|
import { Button, Spin } from 'antd';
|
|
|
import dayjs from 'dayjs';
|
|
|
-import { useState } from 'react';
|
|
|
+import { useRef, useState } from 'react';
|
|
|
import styles from './index.less';
|
|
|
const icon1 = require('@/assets/message/work.png');
|
|
|
const icon2 = require('@/assets/message/check.png');
|
|
@@ -14,7 +18,8 @@ const icon3 = require('@/assets/message/warning.png');
|
|
|
const MessageCenter = () => {
|
|
|
const { projectId } = useParams();
|
|
|
const [searchParams] = useSearchParams();
|
|
|
- const [tab, setTab] = useState('2');
|
|
|
+ const [tab, setTab] = useState(searchParams.get('type') || '1');
|
|
|
+ const msgTypeRef = useRef();
|
|
|
//, msgType: 工况:11, 自检:12, 预警:13
|
|
|
const { data, run, loading } = useRequest(() =>
|
|
|
getNotificationList({ projectId, msgType: 11 }, { manual: true }),
|
|
@@ -34,32 +39,61 @@ const MessageCenter = () => {
|
|
|
loading: loadingSelf,
|
|
|
} = useRequest(() => getNotificationList({ projectId, msgType: 12 }));
|
|
|
|
|
|
+ const { run: runAllRead } = useRequest(
|
|
|
+ () =>
|
|
|
+ getAllRead({
|
|
|
+ project_id: projectId * 1,
|
|
|
+ msg_type: msgTypeRef.current,
|
|
|
+ }),
|
|
|
+ {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: () => {
|
|
|
+ UnityAction.sendMsg('notiReadAll', '');
|
|
|
+ switch (tab) {
|
|
|
+ case '1':
|
|
|
+ runSelf();
|
|
|
+ break;
|
|
|
+ case '2':
|
|
|
+ runWarning();
|
|
|
+ break;
|
|
|
+ case '3':
|
|
|
+ run();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
const handleTabsChange = (tab) => {
|
|
|
setTab(tab);
|
|
|
switch (tab) {
|
|
|
case '1':
|
|
|
+ msgTypeRef.current = 12;
|
|
|
runSelf();
|
|
|
break;
|
|
|
case '2':
|
|
|
+ msgTypeRef.current = 13;
|
|
|
runWarning();
|
|
|
break;
|
|
|
case '3':
|
|
|
+ msgTypeRef.current = 11;
|
|
|
run();
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const handleReadClick = () => {
|
|
|
- UnityAction.sendMsg('notiReadAll', '');
|
|
|
- };
|
|
|
-
|
|
|
const handlerSeeClick = (item) => {
|
|
|
+ readNotification(item.ID);
|
|
|
if (tab === '3') {
|
|
|
// if (item?.MandateId) {
|
|
|
UnityAction.sendMsg('OpenTaskModal', `mandate_id=${item.MandateId}`);
|
|
|
+ run();
|
|
|
// }
|
|
|
} else if (tab == '1') {
|
|
|
UnityAction.sendMsg('notiZiJian', item.PatrolId);
|
|
|
+ runSelf();
|
|
|
+ } else {
|
|
|
+ runWarning();
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -84,7 +118,7 @@ const MessageCenter = () => {
|
|
|
<div className={styles.right}>
|
|
|
<div
|
|
|
className={
|
|
|
- item?.ReadStatus ? styles.redPoint : styles.nonePoint
|
|
|
+ item.ReadStatus === 0 ? styles.redPoint : styles.nonePoint
|
|
|
}
|
|
|
/>
|
|
|
<Button
|
|
@@ -106,7 +140,7 @@ const MessageCenter = () => {
|
|
|
<PageContent tabs>
|
|
|
<TabsContent
|
|
|
center={false}
|
|
|
- defaultActiveKey={searchParams.get('type') || '2'}
|
|
|
+ defaultActiveKey={tab}
|
|
|
onChange={handleTabsChange}
|
|
|
items={[
|
|
|
{
|
|
@@ -140,7 +174,7 @@ const MessageCenter = () => {
|
|
|
},
|
|
|
]}
|
|
|
/>
|
|
|
- <div className={styles.allRead} onClick={handleReadClick}>
|
|
|
+ <div className={styles.allRead} onClick={runAllRead}>
|
|
|
全部已读
|
|
|
</div>
|
|
|
</PageContent>
|