From d7e954aa78f00639d476608ce15804016bf32008 Mon Sep 17 00:00:00 2001 From: JIANG Date: Mon, 27 Oct 2025 10:12:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=88=86=E7=AE=A1=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=96=B9=E6=A1=88=E5=88=9B=E5=BB=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=90=91=E5=90=8E=E5=81=8F=E7=A7=BB=E4=B8=80?= =?UTF-8?q?=E5=88=86=E9=92=9F=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitoring-place-optimization/page.tsx | 2 +- .../BurstPipeAnalysis/AnalysisParameters.tsx | 16 ++- src/components/olmap/SCADADataPanel.tsx | 123 ++++++++++-------- 3 files changed, 83 insertions(+), 58 deletions(-) diff --git a/src/app/(main)/monitoring-place-optimization/page.tsx b/src/app/(main)/monitoring-place-optimization/page.tsx index 917acf3..274703a 100644 --- a/src/app/(main)/monitoring-place-optimization/page.tsx +++ b/src/app/(main)/monitoring-place-optimization/page.tsx @@ -7,7 +7,7 @@ export default function Home() { return (
- +
diff --git a/src/components/olmap/BurstPipeAnalysis/AnalysisParameters.tsx b/src/components/olmap/BurstPipeAnalysis/AnalysisParameters.tsx index 56f51cd..9ea065f 100644 --- a/src/components/olmap/BurstPipeAnalysis/AnalysisParameters.tsx +++ b/src/components/olmap/BurstPipeAnalysis/AnalysisParameters.tsx @@ -41,7 +41,7 @@ const AnalysisParameters: React.FC = () => { const [pipePoints, setPipePoints] = useState([]); const [startTime, setStartTime] = useState(dayjs(new Date())); - const [duration, setDuration] = useState(3000); + const [duration, setDuration] = useState(3600); const [schemeName, setSchemeName] = useState( "FANGAN" + new Date().getTime() ); @@ -52,6 +52,14 @@ const AnalysisParameters: React.FC = () => { useState | null>(null); const [highlightFeatures, setHighlightFeatures] = useState([]); const [analyzing, setAnalyzing] = useState(false); + + // 检查是否所有必要参数都已填写 + const isFormValid = + pipePoints.length > 0 && + startTime !== null && + duration > 0 && + schemeName.trim() !== ""; + // 初始化管道图层和高亮图层 useEffect(() => { if (!map) return; @@ -254,11 +262,11 @@ const AnalysisParameters: React.FC = () => { const burst_size = pipePoints.map((pipe) => parseInt(pipe.area.toString(), 10) ); + // 格式化开始时间,去除秒部分 const modify_pattern_start_time = startTime - ? startTime.format("YYYY-MM-DDTHH:mm:ssZ") + ? startTime.format("YYYY-MM-DDTHH:mm:00Z") : ""; const modify_total_duration = duration; - const body = { name: network, modify_pattern_start_time: modify_pattern_start_time, @@ -464,7 +472,7 @@ const AnalysisParameters: React.FC = () => { variant="contained" size="large" onClick={handleAnalyze} - disabled={analyzing} + disabled={analyzing || !isFormValid} className="bg-blue-600 hover:bg-blue-700" > {analyzing ? "方案提交分析中..." : "方案分析"} diff --git a/src/components/olmap/SCADADataPanel.tsx b/src/components/olmap/SCADADataPanel.tsx index 73ff8c5..ee8909e 100644 --- a/src/components/olmap/SCADADataPanel.tsx +++ b/src/components/olmap/SCADADataPanel.tsx @@ -258,13 +258,12 @@ const SCADADataPanel: React.FC = ({ headerName: deviceLabels?.[id] ?? id, minWidth: 140, flex: 1, - valueFormatter: (params) => { - const value = (params as any).value; - return value === null || value === undefined - ? "--" - : Number.isFinite(Number(value)) - ? Number(value).toFixed(fractionDigits) - : String(value); + valueFormatter: (value: any) => { + if (value === null || value === undefined) return "--"; + if (Number.isFinite(Number(value))) { + return Number(value).toFixed(fractionDigits); + } + return String(value); }, })); @@ -305,52 +304,70 @@ const SCADADataPanel: React.FC = ({ ); }; - const chartSection = hasData ? ( - - value instanceof Date - ? dayjs(value).format("MM-DD HH:mm") - : String(value), - }, - ]} - yAxis={[{ label: "值" }]} - series={deviceIds.map((id) => ({ - dataKey: id, - label: deviceLabels?.[id] ?? id, - showMark: false, - curve: "linear", - }))} - slotProps={{ - legend: { - direction: "row", - position: { horizontal: "middle", vertical: "bottom" }, - }, - loadingOverlay: { - style: { backgroundColor: "transparent" }, - }, - }} - /> - ) : ( - renderEmpty() - ); + const renderChart = () => { + if (!hasData) return renderEmpty(); - const tableSection = hasData ? ( - - ) : ( - renderEmpty() - ); + return ( + + value instanceof Date + ? dayjs(value).format("MM-DD HH:mm") + : String(value), + }, + ]} + yAxis={[{ label: "值" }]} + series={deviceIds.map((id) => ({ + dataKey: id, + label: deviceLabels?.[id] ?? id, + showMark: false, + curve: "linear", + }))} + slotProps={{ + legend: { + direction: "row", + position: { horizontal: "middle", vertical: "bottom" }, + }, + loadingOverlay: { + style: { backgroundColor: "transparent" }, + }, + }} + /> + ); + }; + + const renderTable = () => { + if (!hasData) return renderEmpty(); + + console.debug("[SCADADataPanel] 表格数据:", { + rowsCount: rows.length, + columnsCount: columns.length, + sampleRow: rows[0], + columns: columns.map(c => c.field), + }); + + return ( + + ); + }; return ( = ({ )} - {activeTab === "chart" ? chartSection : tableSection} + {activeTab === "chart" ? renderChart() : renderTable()}