import PageContent from '@/components/PageContent'; import TabsContent from '@/components/TabsContent'; import { 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 styles from './index.less'; const icon1 = require('@/assets/message/work.png'); const icon2 = require('@/assets/message/check.png'); const icon3 = require('@/assets/message/warning.png'); const MessageCenter = () => { const { projectId } = useParams(); const [searchParams] = useSearchParams(); const [tab, setTab] = useState(searchParams.get('type') || '1'); //, msgType: 工况:11, 自检:12, 预警:13 const { data, run, loading } = useRequest(() => getNotificationList({ projectId, msgType: 11 }, { manual: true }), ); const { data: dataWarning, run: runWarning, loading: loadingWarning, } = useRequest(() => getNotificationList({ projectId, msgType: 13 }, { manual: true }), ); const { data: dataSelf, run: runSelf, loading: loadingSelf, } = useRequest(() => getNotificationList({ projectId, msgType: 12 })); const handleTabsChange = (tab) => { setTab(tab); switch (tab) { case '1': runSelf(); break; case '2': runWarning(); break; case '3': 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(); } }; const RenderContent = ({ loading, data, icon }) => { return ( {data?.map((item) => { const time = item?.CreatedOn ? dayjs(item.CreatedOn).format('YYYY-MM-DD HH:mm') : ''; return ( {item.MsgBody} {time} handlerSeeClick(item)} > 查看 ); })} ); }; return ( ), }, { label: `预警数据`, key: '2', children: ( ), }, { label: `水厂工况`, key: '3', children: ( ), }, ]} /> 全部已读 ); }; export default MessageCenter;