import { NavBar, Toast } from 'antd-mobile'; import { useEffect, useRef, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import MeasurementCanvas, { BenchmarkShape, MeasurementCanvasRef, } from '../components/konva/MeasurementCanvas'; import Bridge from '../utils/bridge'; import { Measurement } from '../services/apiTypes'; import { useAppDispatch, useAppSelector } from '../utils/hooks'; // import { XB_CODES } from '../utils/constant'; import { updateRailPoints } from '../store/features/baseData'; export default function MeasureRecord() { const navigate = useNavigate(); const dispatch = useAppDispatch(); const baseState = useAppSelector((state) => state.baseData); const params = useParams(); // params.recordId const [measure, setMeasure] = useState(undefined); const canvasRef = useRef(null); const back = () => navigate(-1); useEffect(() => { Bridge.getMeasurementDetail({ id: +(params.recordId || '') }).then((res) => { if (res.success) { setMeasure({ ...res.data, extraDescObj: JSON.parse(res.data.extraDesc) }); } else { Toast.show(res.message); } }); }, [params.recordId]); function drawRailBaseLine(points: string) { const benchmarkShapes = JSON.parse(points) as BenchmarkShape[]; if (canvasRef.current) { canvasRef.current.setBenchmarkData(benchmarkShapes); } } function drawMeasurePoints(leftPoints: string, rightPoints: string) { if (canvasRef.current) { canvasRef.current.setMeasurementDataLeft(JSON.parse(leftPoints)); canvasRef.current.setMeasurementDataRight(JSON.parse(rightPoints)); } } useEffect(() => { if (measure) { const r = baseState.railTypes.find((rail) => rail.code === measure.railSize); if (!r) return; if (!!r.points) { drawRailBaseLine(r.points); drawMeasurePoints(measure.leftPoints, measure.rightPoints); return; } Bridge.getTrackPoint({ code: r.code }).then((res) => { if (res.success) { dispatch(updateRailPoints(res.data)); drawRailBaseLine(res.data.points!); drawMeasurePoints(measure.leftPoints, measure.rightPoints); } else { Toast.show(res.message); } }); } }, [baseState.railTypes, dispatch, measure]); // function railType(code: string) { // const rail = baseState.railTypes.find((rail) => rail.code === code); // return rail; // } // function direction(directCode: string) { // return XB_CODES.find((dire) => dire.value === directCode); // } return (
测量详情

详细信息

{measure && (

创建时间

{measure.createTime}

测量名称

{measure.name}

批次

{measure.batch}

数据来源

{measure.extraDescObj?.dataSource}

线路分类

{measure.extraDescObj?.lineClassify}

轨型

{measure.extraDescObj?.railSize}

铁路局名称

{measure.extraDescObj?.tljCode}

路段名称

{measure.extraDescObj?.gwdCode}

线路名称

{measure.extraDescObj?.xmCode}

车站

{measure.extraDescObj?.stationCode}

方向

{measure.extraDescObj?.xbCode}

股别

{measure.extraDescObj?.unitType}

里程

{`${measure.extraDescObj?.mile}公里+${measure.extraDescObj?.meter}米`}
)}
); }