From a0db23bacfab06c3974833f07265ad75af29b04d Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Thu, 10 Apr 2025 00:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E7=AB=99=E5=8F=AF=E8=83=BD=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/MeasureSave.tsx | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/pages/MeasureSave.tsx b/src/pages/MeasureSave.tsx index ec5ce37..3d93136 100644 --- a/src/pages/MeasureSave.tsx +++ b/src/pages/MeasureSave.tsx @@ -33,7 +33,9 @@ export default function MeasureSave() { const [directionCode, setDirectionCode] = useState([XB_CODES[0].value]); const [dataSourceCode, setDataSourceCode] = useState([DATA_SOURCE[0].value]); const [lineClassCode, setLineClassCode] = useState([LINE_CLASSIFY[0].value]); - const [stationCode, setStationCode] = useState([contextState.stationList[0].value]); + const [stationCode, setStationCode] = useState( + contextState.stationList.length > 0 ? [contextState.stationList[0].value] : [] + ); const [unitType, setUnitType] = useState([UNIT_TYPES[0].value]); const onInputChange = (evt: ChangeEvent) => { @@ -74,7 +76,10 @@ export default function MeasureSave() { gwdCode: gwd, xmCode: xm, xbCode: XB_CODES.find((x) => x.value === directionCode[0])!.label, - stationCode: contextState.stationList.find((s) => s.value === stationCode[0])!.label, + stationCode: + stationCode.length > 0 + ? contextState.stationList.find((s) => s.value === stationCode[0])!.label + : '', lineClassify: LINE_CLASSIFY.find((l) => l.value === lineClassCode[0])!.label, dataSource: DATA_SOURCE.find((d) => d.value === dataSourceCode[0])!.label, unitType: UNIT_TYPES.find((u) => u.value === unitType[0])!.label, @@ -91,7 +96,7 @@ export default function MeasureSave() { gwdCode: contextState.currGWDCode, xmCode: contextState.currXMCode, xbCode: directionCode[0], - stationCode: stationCode[0], + stationCode: stationCode.length > 0 ? stationCode[0] : '', lineClassify: lineClassCode[0], dataSource: dataSourceCode[0], turnoutNum: turnoutNum.toFixed(), @@ -177,6 +182,20 @@ export default function MeasureSave() { onChange={onInputChange} /> +
{ + if (contextState.stationList.length > 0) { + setStationPickerVisible(true); + } + }} + > + 车站 + + {contextState.stationList.find((r) => r.value === stationCode[0])?.label || ''} + + arr +
) : (
@@ -199,16 +218,7 @@ export default function MeasureSave() {
)} -
setStationPickerVisible(true)} - > - 车站 - - {contextState.stationList.find((r) => r.value === stationCode[0])?.label || ''} - - arr -
+
setLineClassPickerVisible(true)}