新增水质分析功能模块
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
} from "@mui/icons-material";
|
||||
import AnalysisParameters from "./AnalysisParameters";
|
||||
import SchemeQuery from "./SchemeQuery";
|
||||
import LocationResults, { LocationResult } from "./LocationResults";
|
||||
import LocationResults from "./LocationResults";
|
||||
import ContaminantAnalysisParameters from "../ContaminantSimulation/AnalysisParameters";
|
||||
import ContaminantSchemeQuery from "../ContaminantSimulation/SchemeQuery";
|
||||
import ContaminantResultsPanel from "../ContaminantSimulation/ResultsPanel";
|
||||
@@ -27,25 +27,7 @@ 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[];
|
||||
modify_total_duration: number;
|
||||
modify_fixed_pump_pattern: any;
|
||||
modify_valve_opening: any;
|
||||
modify_variable_pump_pattern: any;
|
||||
}
|
||||
|
||||
interface SchemeRecord {
|
||||
id: number;
|
||||
schemeName: string;
|
||||
type: string;
|
||||
user: string;
|
||||
create_time: string;
|
||||
startTime: string;
|
||||
// 详情信息
|
||||
schemeDetail?: SchemeDetail;
|
||||
}
|
||||
import { LocationResult, SchemeRecord } from "./types";
|
||||
|
||||
interface TabPanelProps {
|
||||
children?: React.ReactNode;
|
||||
@@ -82,7 +64,7 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
const [currentTab, setCurrentTab] = useState(0);
|
||||
const [panelMode, setPanelMode] = useState<PanelMode>("burst");
|
||||
const previousMapText = useRef<{ junction?: string; pipe?: string } | null>(
|
||||
null
|
||||
null,
|
||||
);
|
||||
|
||||
const data = useData();
|
||||
@@ -108,28 +90,10 @@ 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(
|
||||
`${config.BACKEND_URL}/api/v1/burst-locate-result/${scheme.schemeName}`
|
||||
`${config.BACKEND_URL}/api/v1/burst-locate-result/${scheme.schemeName}`,
|
||||
);
|
||||
setLocationResults(response.data);
|
||||
setCurrentTab(2); // 切换到定位结果标签页
|
||||
@@ -304,7 +268,7 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
|
||||
onLocate={handleLocateScheme}
|
||||
/>
|
||||
) : (
|
||||
<ContaminantSchemeQuery />
|
||||
<ContaminantSchemeQuery onViewResults={() => setCurrentTab(2)} />
|
||||
)}
|
||||
</TabPanel>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user