60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import React, { useEffect, useState } from 'react';
|
|
import { Modal, Button, message } from 'antd';
|
|
import FullScreenPage from '../layout/FullScreenInter';
|
|
const PopupWindow = () => {
|
|
const [visible, setVisible] = useState(false);
|
|
const [params, setParams] = useState({});
|
|
|
|
useEffect(() => {
|
|
// 尝试从 URL 查询参数获取
|
|
const searchParams = new URLSearchParams(window.location.search);
|
|
const timeRange = searchParams.get('timeRange') || '';
|
|
const filterType = searchParams.get('filterType') || '';
|
|
|
|
if (timeRange || filterType) {
|
|
setParams({ timeRange, filterType });
|
|
setVisible(true);
|
|
} else {
|
|
// 从 localStorage 获取
|
|
const storedParams = localStorage.getItem('popupParams');
|
|
if (storedParams) {
|
|
try {
|
|
const parsedParams = JSON.parse(storedParams);
|
|
setParams(parsedParams);
|
|
setVisible(true);
|
|
localStorage.removeItem('popupParams');
|
|
} catch (error) {
|
|
message.error('参数解析错误');
|
|
}
|
|
}
|
|
}
|
|
}, []);
|
|
|
|
return (
|
|
<div style={{ background: '#f0f2f5' }}>
|
|
<Modal
|
|
title="数据筛选"
|
|
visible={visible}
|
|
onCancel={() => setVisible(false)}
|
|
footer={[
|
|
<Button key="close" onClick={() => setVisible(false)}>
|
|
关闭
|
|
</Button>,
|
|
]}
|
|
width={700}
|
|
centered
|
|
>
|
|
<FullScreenPage />
|
|
</Modal>
|
|
|
|
{!visible && (
|
|
<div style={{ textAlign: 'center' }}>
|
|
<FullScreenPage />
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default PopupWindow;
|