|
@@ -1,11 +1,15 @@
|
|
|
import PageContent from '@/components/PageContent';
|
|
|
import TabsContent from '@/components/TabsContent';
|
|
|
-import { getNotificationList, readNotification } 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');
|
|
@@ -15,6 +19,7 @@ const MessageCenter = () => {
|
|
|
const { projectId } = useParams();
|
|
|
const [searchParams] = useSearchParams();
|
|
|
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,25 +39,49 @@ 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') {
|
|
@@ -145,7 +174,7 @@ const MessageCenter = () => {
|
|
|
},
|
|
|
]}
|
|
|
/>
|
|
|
- <div className={styles.allRead} onClick={handleReadClick}>
|
|
|
+ <div className={styles.allRead} onClick={runAllRead}>
|
|
|
全部已读
|
|
|
</div>
|
|
|
</PageContent>
|