修复标签索引报错的问题

This commit is contained in:
JIANG
2026-02-03 11:11:42 +08:00
parent 6f0ef342e9
commit 0690b0b804

View File

@@ -99,6 +99,16 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
setCurrentTab(newValue); setCurrentTab(newValue);
}; };
const handleModeChange = (_event: React.SyntheticEvent, newMode: PanelMode) => {
setPanelMode(newMode);
// 切换模式时,如果当前标签索引超出新模式的标签数量,重置为第一个标签
// 爆管分析有4个标签(0-3)水质模拟有3个标签(0-2)
const maxTabIndex = newMode === "burst" ? 3 : 2;
if (currentTab > maxTabIndex) {
setCurrentTab(0);
}
};
const handleLocateScheme = async (scheme: SchemeRecord) => { const handleLocateScheme = async (scheme: SchemeRecord) => {
try { try {
const response = await axios.get( const response = await axios.get(
@@ -204,7 +214,7 @@ const BurstPipeAnalysisPanel: React.FC<BurstPipeAnalysisPanelProps> = ({
<Box className="border-b border-gray-200 bg-white"> <Box className="border-b border-gray-200 bg-white">
<Tabs <Tabs
value={panelMode} value={panelMode}
onChange={(_event, value: PanelMode) => setPanelMode(value)} onChange={handleModeChange}
variant="fullWidth" variant="fullWidth"
sx={{ sx={{
minHeight: 46, minHeight: 46,