|
|
@ -1,7 +1,7 @@ |
|
|
|
import { NavBar, Picker, Toast } from 'antd-mobile'; |
|
|
|
import { useNavigate } from 'react-router'; |
|
|
|
import icon_arr_r from '../assets/icon_arr_s_r.svg'; |
|
|
|
import { ChangeEvent, useEffect, useState } from 'react'; |
|
|
|
import {ChangeEvent, useCallback, useEffect, useState} from 'react'; |
|
|
|
import { useAppDispatch, useAppSelector } from '../utils/hooks'; |
|
|
|
import { DATA_SOURCE, LINE_CLASSIFY, UNIT_TYPES, XB_CODES } from '../utils/constant'; |
|
|
|
import { ExtraDesc, MeasurementDTO } from '../services/apiTypes'; |
|
|
@ -19,6 +19,32 @@ export default function MeasureSave() { |
|
|
|
const measureState = useAppSelector((state) => state.measure); |
|
|
|
const orgTextArr = useAppSelector(selectOrgTextArr); |
|
|
|
|
|
|
|
|
|
|
|
const loadData = useCallback(() => { |
|
|
|
Bridge.getRecordList({ pageNum: 1, size: 1 }).then((res) => { |
|
|
|
if (res.success && res.data.list.length) { |
|
|
|
const data = res.data.list[0]?.records?.[0] |
|
|
|
console.log(data) |
|
|
|
setName(data?.name) |
|
|
|
setBatch(data?.batch) |
|
|
|
setMile(data?.mileage?.split('+')?.[0]) |
|
|
|
setMeter(data?.mileage?.split('+')?.[1]) |
|
|
|
setLineClassCode([data?.lineClassify]) |
|
|
|
setDataSourceCode([data?.dataSource]) |
|
|
|
setDirectionCode([data?.xbCode]) |
|
|
|
setUnitType([data?.unitType]) |
|
|
|
setTurnoutNum(Number(data?.turnoutNum || 1)) |
|
|
|
setSleeperNum(Number(data?.sleeperNum || 1)) |
|
|
|
setStationCode([data?.stationCode]) |
|
|
|
document.getElementById('name-id')?.focus() |
|
|
|
} |
|
|
|
}); |
|
|
|
}, []); |
|
|
|
useEffect(() => { |
|
|
|
loadData(); |
|
|
|
}, [loadData]); |
|
|
|
|
|
|
|
|
|
|
|
const [name, setName] = useState(''); |
|
|
|
const [batch, setBatch] = useState(''); |
|
|
|
const [mile, setMile] = useState('10'); |
|
|
@ -110,8 +136,8 @@ export default function MeasureSave() { |
|
|
|
stationCode: stationCode.length > 0 ? stationCode[0] : '', |
|
|
|
lineClassify: lineClassCode[0], |
|
|
|
dataSource: dataSourceCode[0], |
|
|
|
turnoutNum: turnoutNum.toFixed(), |
|
|
|
sleeperNum: sleeperNum.toFixed(), |
|
|
|
turnoutNum: turnoutNum?.toFixed(), |
|
|
|
sleeperNum: sleeperNum?.toFixed(), |
|
|
|
unitType: unitType[0], |
|
|
|
mileage: `${mile}+${meter.padStart(3, '0')}`, |
|
|
|
radius: '', |
|
|
@ -149,6 +175,7 @@ export default function MeasureSave() { |
|
|
|
<div className="h-12 flex items-center border-b border-[#eee]"> |
|
|
|
<span>测量名称</span> |
|
|
|
<input |
|
|
|
id='name-id' |
|
|
|
type="text" |
|
|
|
name="name" |
|
|
|
value={name} |
|
|
|