新增水质模拟模块;移除docker配置文件,现放置到后端项目中
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
Box,
|
||||
Drawer,
|
||||
@@ -20,9 +20,13 @@ import {
|
||||
import AnalysisParameters from "./AnalysisParameters";
|
||||
import SchemeQuery from "./SchemeQuery";
|
||||
import LocationResults, { LocationResult } from "./LocationResults";
|
||||
import ContaminantAnalysisParameters from "../ContaminantSimulation/AnalysisParameters";
|
||||
import ContaminantSchemeQuery from "../ContaminantSimulation/SchemeQuery";
|
||||
import ContaminantResultsPanel from "../ContaminantSimulation/ResultsPanel";
|
||||
import axios from "axios";
|
||||
import { config } from "@config/config";
|
||||
import { useNotification } from "@refinedev/core";
|
||||
import { useData } from "@app/OlMap/MapComponent";
|
||||
interface SchemeDetail {
|
||||
burst_ID: string[];
|
||||
burst_size: number[];
|
||||
@@ -68,12 +72,20 @@ interface BurstPipeAnalysisPanelProps {
|
||||
onToggle?: () => void;
|
||||
}
|
||||
|
||||
type PanelMode = "burst" | "contaminant";
|
||||
|
||||
const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
open: controlledOpen,
|
||||
onToggle,
|
||||
}) => {
|
||||
const [internalOpen, setInternalOpen] = useState(true);
|
||||
const [currentTab, setCurrentTab] = useState(0);
|
||||
const [panelMode, setPanelMode] = useState<PanelMode>("burst");
|
||||
const previousMapText = useRef<{ junction?: string; pipe?: string } | null>(
|
||||
null
|
||||
);
|
||||
|
||||
const data = useData();
|
||||
|
||||
// 持久化方案查询结果
|
||||
const [schemes, setSchemes] = useState<SchemeRecord[]>([]);
|
||||
@@ -96,6 +108,24 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
setCurrentTab(newValue);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) return;
|
||||
if (panelMode === "contaminant") {
|
||||
if (!previousMapText.current) {
|
||||
previousMapText.current = {
|
||||
junction: data.junctionText,
|
||||
pipe: data.pipeText,
|
||||
};
|
||||
}
|
||||
data.setJunctionText?.("quality");
|
||||
data.setPipeText?.("quality");
|
||||
} else if (panelMode === "burst" && previousMapText.current) {
|
||||
data.setJunctionText?.(previousMapText.current.junction || "pressure");
|
||||
data.setPipeText?.(previousMapText.current.pipe || "flow");
|
||||
previousMapText.current = null;
|
||||
}
|
||||
}, [panelMode, data]);
|
||||
|
||||
const handleLocateScheme = async (scheme: SchemeRecord) => {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
@@ -114,6 +144,8 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
};
|
||||
|
||||
const drawerWidth = 520;
|
||||
const isBurstMode = panelMode === "burst";
|
||||
const panelTitle = isBurstMode ? "爆管分析" : "水质模拟";
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -131,7 +163,7 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
className="text-gray-700 font-semibold my-1 text-xs"
|
||||
style={{ writingMode: "vertical-rl" }}
|
||||
>
|
||||
爆管分析
|
||||
{panelTitle}
|
||||
</Typography>
|
||||
<ChevronLeft className="text-gray-600 w-4 h-4" />
|
||||
</Box>
|
||||
@@ -175,7 +207,7 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
<Box className="flex items-center gap-2">
|
||||
<AnalyticsIcon className="w-5 h-5" />
|
||||
<Typography variant="h6" className="text-lg font-semibold">
|
||||
爆管分析
|
||||
{panelTitle}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Tooltip title="收起">
|
||||
@@ -190,6 +222,31 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
</Box>
|
||||
|
||||
{/* Tabs 导航 */}
|
||||
<Box className="border-b border-gray-200 bg-white">
|
||||
<Tabs
|
||||
value={panelMode}
|
||||
onChange={(_event, value: PanelMode) => setPanelMode(value)}
|
||||
variant="fullWidth"
|
||||
sx={{
|
||||
minHeight: 46,
|
||||
"& .MuiTab-root": {
|
||||
minHeight: 46,
|
||||
textTransform: "none",
|
||||
fontSize: "0.8rem",
|
||||
fontWeight: 600,
|
||||
},
|
||||
"& .Mui-selected": {
|
||||
color: "#257DD4",
|
||||
},
|
||||
"& .MuiTabs-indicator": {
|
||||
backgroundColor: "#257DD4",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Tab value="burst" label="爆管分析" />
|
||||
<Tab value="contaminant" label="水质模拟" />
|
||||
</Tabs>
|
||||
</Box>
|
||||
<Box className="border-b border-gray-200 bg-white">
|
||||
<Tabs
|
||||
value={currentTab}
|
||||
@@ -225,26 +282,38 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
<Tab
|
||||
icon={<MyLocationIcon fontSize="small" />}
|
||||
iconPosition="start"
|
||||
label="定位结果"
|
||||
label={isBurstMode ? "定位结果" : "模拟结果"}
|
||||
/>
|
||||
</Tabs>
|
||||
</Box>
|
||||
|
||||
{/* Tab 内容 */}
|
||||
<TabPanel value={currentTab} index={0}>
|
||||
<AnalysisParameters />
|
||||
{isBurstMode ? (
|
||||
<AnalysisParameters />
|
||||
) : (
|
||||
<ContaminantAnalysisParameters />
|
||||
)}
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel value={currentTab} index={1}>
|
||||
<SchemeQuery
|
||||
schemes={schemes}
|
||||
onSchemesChange={setSchemes}
|
||||
onLocate={handleLocateScheme}
|
||||
/>
|
||||
{isBurstMode ? (
|
||||
<SchemeQuery
|
||||
schemes={schemes}
|
||||
onSchemesChange={setSchemes}
|
||||
onLocate={handleLocateScheme}
|
||||
/>
|
||||
) : (
|
||||
<ContaminantSchemeQuery />
|
||||
)}
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel value={currentTab} index={2}>
|
||||
<LocationResults results={locationResults} />
|
||||
{isBurstMode ? (
|
||||
<LocationResults results={locationResults} />
|
||||
) : (
|
||||
<ContaminantResultsPanel schemeName={data?.schemeName} />
|
||||
)}
|
||||
</TabPanel>
|
||||
</Box>
|
||||
</Drawer>
|
||||
|
||||
@@ -336,6 +336,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
|
||||
timeRange={timeRange}
|
||||
disableDateSelection={!!timeRange}
|
||||
schemeName={schemeName}
|
||||
schemeType="burst_Analysis"
|
||||
/>,
|
||||
mapContainer // 渲染到地图容器中,而不是 body
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user