3 changed files with 190 additions and 6 deletions
-
5src/index.tsx
-
101src/pages/measure/components/Detail.tsx
-
90src/pages/measure/components/MeasureDetail.tsx
@ -0,0 +1,101 @@ |
|||
import {getDetailList, delDetail, getDetail, getPointByUuid} from '../../../services/measure/analysis' |
|||
import { useState, useEffect, useRef } from 'react' |
|||
import {message } from 'antd'; |
|||
|
|||
import { useNavigate, useParams } from 'react-router-dom'; |
|||
import type { AnalysisReport, DetailTable, } from "../../../services/measure/type"; |
|||
import { AnalysisData, BenchmarkShape, MeasurementCanvasRef } from './konva/MeasurementCanvas'; |
|||
import MeasurementCanvas from "./konva/MeasurementCanvas"; |
|||
import { |
|||
getBaseRecordPointSetByCode, |
|||
getReport |
|||
} from "../../../services/measure/analysis"; |
|||
export default function MeasureDetail() { |
|||
const {id} = useParams() |
|||
const navigate = useNavigate(); |
|||
|
|||
const [measureId, setMeasureId] = useState<number>(Number(id)) |
|||
useEffect(()=>{ |
|||
onShowDetail(measureId) |
|||
}, []) |
|||
|
|||
const onShowDetail = (measureId:number)=> { |
|||
//获取基线
|
|||
getBaseRecordPointSetByCode("6001").then(res => { |
|||
if (res.success) { |
|||
const benchmarkShapes = JSON.parse(res.data.points) as BenchmarkShape[]; |
|||
if (canvasRef.current) { |
|||
console.log("解析后的基础图形数据:", benchmarkShapes); |
|||
canvasRef.current.setBenchmarkData(benchmarkShapes); |
|||
} |
|||
} |
|||
}); |
|||
getDetail({id:measureId}).then(res=>{ |
|||
console.log('res==测量记录详情=', res) |
|||
if(res){ |
|||
//@ts-ignore
|
|||
getRecordByUuid(res.data.uuid) |
|||
//@ts-ignore
|
|||
onDetaiResult(res.data.uuid) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
//法线
|
|||
const onDetaiResult = (uuid:string) => { |
|||
getReport(uuid,'6001').then(res=> { |
|||
if (res.success) { |
|||
const report: AnalysisReport = res.data; |
|||
console.log(report); |
|||
// 更新 canvas 的分析数据
|
|||
if (report && report.angleAnalysisList) { |
|||
// 先过滤掉 distance 为 null 的数据
|
|||
const validItems = report.angleAnalysisList.filter(item => item.distance !== null); |
|||
const analysisData: AnalysisData[] = validItems.map(item => ({ |
|||
pointA: { x: parseFloat(item.pointA.x), y: parseFloat(item.pointA.y) }, |
|||
pointB: { x: parseFloat(item.pointB.x), y: parseFloat(item.pointB.y) }, |
|||
base: { x: parseFloat(item.pointA.x), y: parseFloat(item.pointA.y) }, |
|||
measure: { x: parseFloat(item.pointB.x), y: parseFloat(item.pointB.y) }, |
|||
distance: parseFloat(item.distance), |
|||
describe: item.describe, |
|||
})); |
|||
canvasRef.current?.setAnalysisData(analysisData); |
|||
} |
|||
} else { |
|||
message.error("分析报告请求失败: " + res.data.info); |
|||
} |
|||
}) |
|||
|
|||
} |
|||
|
|||
const getRecordByUuid = (uuid:string) => { |
|||
getPointByUuid({uuid}).then(res=>{ |
|||
canvasRef.current?.setMeasurementData(res.data.points); |
|||
}) |
|||
} |
|||
|
|||
const canvasRef = useRef<MeasurementCanvasRef>(null); |
|||
const [showGrid, setShowGrid] = useState(true); |
|||
const [showStandard, setShowStandard] = useState(true); |
|||
const [showMark, setShowMark] = useState(true); |
|||
return ( |
|||
<div className="flex p-[1.5rem]"> |
|||
<MeasurementCanvas |
|||
width={800} |
|||
height={600} |
|||
logicalExtent={{ minX: -50, maxX: 50, minY: -20, maxY: 60 }} |
|||
gridStep={1} |
|||
origin={{ x: 0, y: 20 }} |
|||
pixelPerMm={8} |
|||
maxZoom={10} |
|||
showGrid={showGrid} |
|||
showBenchmark={showStandard} |
|||
showAnalysis={showMark} |
|||
showScale={false} |
|||
scaleInterval={1} |
|||
showCoordinates={true} |
|||
ref={canvasRef} |
|||
/> |
|||
</div> |
|||
); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue