|
|
@ -5,14 +5,20 @@ import MeasurementCanvas, { |
|
|
|
BenchmarkShape, |
|
|
|
MeasurementCanvasRef, |
|
|
|
} from '../components/konva/MeasurementCanvas'; |
|
|
|
import { useEffect, useRef } from 'react'; |
|
|
|
import { rail6001 } from '../utils/constant'; |
|
|
|
import { useEffect, useRef, useState } from 'react'; |
|
|
|
import { rail6001, railTypes } from '../utils/constant'; |
|
|
|
|
|
|
|
import RailTypeBtn from '../components/RailTypeBtn'; |
|
|
|
import { Picker } from 'antd-mobile'; |
|
|
|
|
|
|
|
export default function Measure() { |
|
|
|
const navigate = useNavigate(); |
|
|
|
|
|
|
|
const canvasRef = useRef<MeasurementCanvasRef>(null); |
|
|
|
|
|
|
|
const [railPickerVisible, setRailPickerVisible] = useState(false); |
|
|
|
const [railId, setRailId] = useState<(number | string | null)[]>([1]); |
|
|
|
|
|
|
|
const onSaveClick = () => { |
|
|
|
navigate('/measure/save'); |
|
|
|
}; |
|
|
@ -20,62 +26,85 @@ export default function Measure() { |
|
|
|
useEffect(() => { |
|
|
|
const benchmarkShapes = JSON.parse(rail6001.points) as BenchmarkShape[]; |
|
|
|
if (canvasRef.current) { |
|
|
|
console.log('解析后的基础图形数据:', benchmarkShapes); |
|
|
|
canvasRef.current.setBenchmarkData(benchmarkShapes); |
|
|
|
} |
|
|
|
}, []); |
|
|
|
|
|
|
|
function railName() { |
|
|
|
return railTypes.find(r => r.id === railId[0])?.name || '' |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<div className="relative pt-[--navBarHeight]"> |
|
|
|
<div className="absolute top-0 w-full z-10"> |
|
|
|
<CustomNavBar title={'测量'}></CustomNavBar> |
|
|
|
</div> |
|
|
|
<> |
|
|
|
<div className="relative pt-[--navBarHeight]"> |
|
|
|
<div className="absolute top-0 w-full z-10"> |
|
|
|
<CustomNavBar title={'测量'}></CustomNavBar> |
|
|
|
</div> |
|
|
|
|
|
|
|
<main className="home-page-content overflow-x-hidden overflow-y-auto"> |
|
|
|
<div className="relative h-0 p-0 pb-[70%]"> |
|
|
|
<div className="absolute left-0 right-0 top-0 bottom-0 bg-title"> |
|
|
|
<MeasurementCanvas |
|
|
|
width={window.innerWidth} |
|
|
|
height={window.innerWidth * 0.7} |
|
|
|
logicalExtent={{ minX: -45, maxX: 45, minY: -18, maxY: 52 }} |
|
|
|
gridStep={3} |
|
|
|
origin={{ x: 0, y: 20 }} |
|
|
|
pixelPerMm={window.innerWidth / 90} |
|
|
|
maxZoom={5} |
|
|
|
showGrid={true} |
|
|
|
showBenchmark={true} |
|
|
|
showAnalysis={false} |
|
|
|
showScale={false} |
|
|
|
scaleInterval={1} |
|
|
|
showCoordinates={false} |
|
|
|
ref={canvasRef} |
|
|
|
/> |
|
|
|
<main className="home-page-content overflow-x-hidden overflow-y-auto"> |
|
|
|
<div className="relative h-0 p-0 pb-[70%]"> |
|
|
|
<div className="absolute left-0 right-0 top-0 bottom-0 bg-title"> |
|
|
|
<MeasurementCanvas |
|
|
|
width={window.innerWidth} |
|
|
|
height={window.innerWidth * 0.7} |
|
|
|
logicalExtent={{ minX: -45, maxX: 45, minY: -18, maxY: 52 }} |
|
|
|
gridStep={3} |
|
|
|
origin={{ x: 0, y: 20 }} |
|
|
|
pixelPerMm={window.innerWidth / 90} |
|
|
|
maxZoom={5} |
|
|
|
showGrid={true} |
|
|
|
showBenchmark={true} |
|
|
|
showAnalysis={false} |
|
|
|
showScale={false} |
|
|
|
scaleInterval={1} |
|
|
|
showCoordinates={false} |
|
|
|
ref={canvasRef} |
|
|
|
/> |
|
|
|
<div className="absolute left-1 bottom-1"> |
|
|
|
<RailTypeBtn |
|
|
|
text={railName()} |
|
|
|
onClick={() => setRailPickerVisible(true)} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<section className="h-10 bg-[#e3e8f5] flex justify-between items-center px-4"> |
|
|
|
<p className="text-text">北京铁路局 /客运段/京沪线/左侧</p> |
|
|
|
<Link to="/home/setting" className="text-primary underline"> |
|
|
|
修改 |
|
|
|
</Link> |
|
|
|
</section> |
|
|
|
<section className="h-10 bg-[#e3e8f5] flex justify-between items-center px-4"> |
|
|
|
<p className="text-text">北京铁路局 /客运段/京沪线/左侧</p> |
|
|
|
<Link to="/home/setting" className="text-primary underline"> |
|
|
|
修改 |
|
|
|
</Link> |
|
|
|
</section> |
|
|
|
|
|
|
|
<section className="flex items-center gap-4 px-4 my-4"> |
|
|
|
<div className="btn-contained rounded-md text-sm h-10 flex-1">开始测量</div> |
|
|
|
<div className="btn-contained rounded-md text-sm h-10 flex-1" onClick={onSaveClick}> |
|
|
|
保存 |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
<section className="flex items-center gap-4 px-4 my-4"> |
|
|
|
<div className="btn-contained rounded-md text-sm h-10 flex-1">开始测量</div> |
|
|
|
<div className="btn-contained rounded-md text-sm h-10 flex-1" onClick={onSaveClick}> |
|
|
|
保存 |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
|
|
|
|
<section className="grid grid-cols-2 gap-[10px] px-3"> |
|
|
|
<StepItem state={2} text={'移到顶部停留2秒'} /> |
|
|
|
<StepItem state={2} text={'移到顶部停留2秒'} /> |
|
|
|
<StepItem state={0} text={'开始测量左侧'} /> |
|
|
|
<StepItem state={0} text={'开始测量右侧'} /> |
|
|
|
<StepItem state={1} text={'左侧测量完成'} /> |
|
|
|
<StepItem state={1} text={'右侧测量完成'} /> |
|
|
|
</section> |
|
|
|
</main> |
|
|
|
</div> |
|
|
|
|
|
|
|
<section className="grid grid-cols-2 gap-[10px] px-3"> |
|
|
|
<StepItem state={2} text={'移到顶部停留2秒'} /> |
|
|
|
<StepItem state={2} text={'移到顶部停留2秒'} /> |
|
|
|
<StepItem state={0} text={'开始测量左侧'} /> |
|
|
|
<StepItem state={0} text={'开始测量右侧'} /> |
|
|
|
<StepItem state={1} text={'左侧测量完成'} /> |
|
|
|
<StepItem state={1} text={'右侧测量完成'} /> |
|
|
|
</section> |
|
|
|
</main> |
|
|
|
</div> |
|
|
|
<Picker |
|
|
|
columns={[railTypes.map(t => ({ ...t, label: t.name, value: t.id }))]} |
|
|
|
visible={railPickerVisible} |
|
|
|
onClose={() => { |
|
|
|
setRailPickerVisible(false); |
|
|
|
}} |
|
|
|
value={railId} |
|
|
|
onConfirm={v => { |
|
|
|
setRailId(v); |
|
|
|
}} |
|
|
|
/> |
|
|
|
</> |
|
|
|
); |
|
|
|
} |