From c30f0544c268bfe7e51c44068f4be5958dfe8fee Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Fri, 4 Sep 2026 10:22:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8F=91=E7=94=B5=E8=B6=8B?= =?UTF-8?q?=E5=8A=BF=20=E6=94=AF=E6=8C=81=E6=94=BE=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Home.tsx | 135 +++++++++++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 55 deletions(-) diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 1314208..e415838 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -7,6 +7,7 @@ import { MoneyCollectOutlined, DashboardOutlined, FullscreenOutlined, + FullscreenExitOutlined, RocketOutlined, VideoCameraOutlined, AppstoreOutlined, @@ -21,27 +22,57 @@ import { getWeatherData, getWeatherType } from '../lib/utils'; import WeatherDisplay from '../components/Weather'; import bgMain from '../assets/images/bgmain.jpg'; import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts'; - // 👇 在这里引入你的工单接口(改成你真实的接口地址) import { addWorkOrder } from '../api/workOrder'; import { useSelector } from 'react-redux'; import { getAlarmList } from '../api/alarmApi'; import { RootState } from '../store'; import { useTranslation } from 'react-i18next'; - const { Text } = Typography; export default function StationDashboard() { const { t } = useTranslation(); // 👇 消息提示(修复缺失) const [messageApi, contextHolder] = message.useMessage(); - // 👇 获取当前选中的电站(从redux拿,修复缺失) const { currentStation } = useSelector((state) => state.station); const { userInfo } = useSelector((state) => state.user); const { stationId } = useSelector((state: RootState) => state.station); const [alarmList, setAlarmList] = useState([]); + // ========== 发电趋势卡片全屏相关 ========== + const powerTrendCardRef = useRef(null); + const [isPowerCardFullscreen, setIsPowerCardFullscreen] = useState(false); + + const togglePowerCardFullScreen = async () => { + const el = powerTrendCardRef.current; + if (!el) return; + try { + if (!document.fullscreenElement) { + await el.requestFullscreen(); + } else { + await document.exitFullscreen(); + } + } catch (err) { + console.error('全屏切换异常:', err); + } + }; + + const handleRefreshPowerTrend = () => { + console.log('刷新发电趋势数据'); + // 这里可以写重新请求接口逻辑 + }; + + useEffect(() => { + const onFullScreenChange = () => { + setIsPowerCardFullscreen(!!document.fullscreenElement); + }; + document.addEventListener('fullscreenchange', onFullScreenChange); + return () => { + document.removeEventListener('fullscreenchange', onFullScreenChange); + }; + }, []); + // ========================================= // 天气数据 const [weatherdata, setWeatherData] = useState({ @@ -58,7 +89,6 @@ export default function StationDashboard() { report_time: "2026-03-27 12:35:08" }); const weatherType = getWeatherType(weatherdata.weather); - // 请求天气 useEffect(() => { const fetchWeather = async () => { @@ -71,7 +101,6 @@ export default function StationDashboard() { }; fetchWeather(); }, []); - // 模拟数据 const stationOverview = { todayEnergy: 4752.0, @@ -85,27 +114,22 @@ export default function StationDashboard() { }; // 组件内部 const navigate = useNavigate(); - - const deviceStatus = [ { name: t('home.combinerBox'), count: "2/2", status: "异常 1" }, { name: t('home.inverter'), count: "3/3", status: "异常 1" }, { name: "电表", count: "1/1", status: t('roles.normal') }, { name: t('home.inspectionRobot'), count: "1/1", status: t('roles.normal') } ]; - const patrolRecords = [ { name: "升压站安防巡检任务", device: "UAV-01", status: "草稿", time: "04-29T...", person: "张运维" }, { name: "B区清洗任务", device: "CLEAN-01", status: "待执行", time: "04-29T...", person: "张运维" }, { name: "A区巡检任务", device: "ROBOT-01", status: "已派发", time: "04-29T...", person: "张运维" } ]; - const aiAnalysis = [ { type: "AI分析", content: t('home.fixed2AiInverterFixed2TemperatureAbnormalADevice'), desc: "发现2处组件存在异常热斑" }, { type: t('constants.critical'), content: t('home.invA02MaintenanceInvA02Repair'), desc: "3个组串存在发电异常" }, { type: t('constants.critical'), content: t('home.a05HotspotPvA05018PvA05020StatusAbnormal'), desc: "整体发电偏差-2.8%" } ]; - // 图表数据 const powerTrendData = [ { time: '00:00', actual: 1800, predict: 1600 }, @@ -120,7 +144,6 @@ export default function StationDashboard() { { time: '20:00', actual: 3000, predict: 2500 }, { time: '24:00', actual: 1800, predict: 1600 }, ]; - const irradianceData = [ { time: '00:00', irradiance: 40, temperature: 14 }, { time: '04:00', irradiance: 30, temperature: 12 }, @@ -141,16 +164,13 @@ export default function StationDashboard() { { device: 'INV-04', efficiency: 96.5 }, { device: 'INV-05', efficiency: 95.8 }, ]; - const taskProgressData = [ { name: t('workOrder.completed'), value: 40, color: '#1890ff' }, { name: '进行中', value: 35, color: '#52c41a' }, { name: '待开始', value: 20, color: '#faad14' }, { name: t('home.abnormal'), value: 5, color: '#ff4d4f' }, ]; - const cardStyle = { borderRadius: 12, border: '1px solid #f0f0f0', boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }; - // ============================================== // 👇 【完整完善】生成清洗工单(核心修复) // ============================================== @@ -165,12 +185,12 @@ export default function StationDashboard() { try { // 严格按照你给的接口字段传参 const params = { - id: '', // 主键ID(新增为空) - orderNo: '', // 工单编号(后端生成) + id: '', // 主键ID(新增为空) + orderNo: '', // 工单编号(后端生成) orderTitle: '光伏组件清洗工单', // 工单标题 - sourceType: 3, // 来源 3=清洗 - orderType: 3, // 类型 3=清洗 - priorityLevel: 2, // 优先级 2=中 + sourceType: 3, // 来源 3=清洗 + orderType: 3, // 类型 3=清洗 + priorityLevel: 2, // 优先级 2=中 deviceId: currentStation.id || '', deviceName: currentStation.siteName || '电站', deviceType: 1, // 设备类型:电站 @@ -186,7 +206,7 @@ export default function StationDashboard() { deadlineTime: '', actualStartTime: '', actualEndTime: '', - orderStatus: 1, // 状态 1=待处理 + orderStatus: 1, // 状态 1=待处理 alarmId: '', alarmNo: '', taskDescription: '根据电站清洁度建议进行组件清洗,提升发电效率', @@ -196,9 +216,7 @@ export default function StationDashboard() { handleResult: '', handleRemark: '' }; - const res = await addWorkOrder(params); - if (res.code === 0 || res.code === 200) { messageApi.success(t('home.cleaningOrderGeneratedSuccessfullyFixed2')); } else { @@ -220,24 +238,19 @@ export default function StationDashboard() { if (res.code === 200) { setAlarmList(res?.rows || []); } - } catch (err) { messageApi.error(t('common.loadFailed')); } finally { - } }; useEffect(() => { fetchList() }, [stationId]) - - return (
{/* 👇 必须加这个,message才能正常显示 */} {contextHolder} - {/* 顶部统计卡片 */} {[ @@ -276,27 +289,45 @@ export default function StationDashboard() { ))} - {/* 主体布局 */} {/* 左侧图表 */} - {t('home.generationTrend')}} extra={} variant="borderless" style={cardStyle} styles={{ body: { padding: '8px' } }}> -
今日发电功率趋势 (kW)
- -
+ {/* ========== 发电趋势卡片,增加ref与全屏逻辑 ========== */} +
+ {t('home.generationTrend')}} + extra={ + + + {isPowerCardFullscreen ? ( + + ) : ( + + )} + + } + variant="borderless" + style={{ ...cardStyle, width: "100%" }} + styles={{ body: { padding: '8px' } }} + > +
今日发电功率趋势 (kW)
+ +
+
+ {t('home.irradianceTempTrend')}} variant="borderless" style={cardStyle} styles={{ body: { padding: '8px' } }}>
- {/* 中间 */} @@ -364,18 +394,15 @@ export default function StationDashboard() { >
{/*