|
|
@ -9,6 +9,10 @@ import ResultLayer from "./graph/ResultLayer"; |
|
|
|
import MarkLayer from "./graph/MarkLayer"; |
|
|
|
import { useDispatch, useSelector } from "react-redux"; |
|
|
|
import { switchMeasureAfterSave } from "../../../store/features/contextSlice"; |
|
|
|
import { AnalyzeAngle } from "../../../services/measure/type"; |
|
|
|
import { MeasureState, taskStatusDescMap } from "../../../services/wsTypes"; |
|
|
|
|
|
|
|
const wsClient = createWebSocket(sharedWsUrl); |
|
|
|
|
|
|
|
export default function MeasureAction() { |
|
|
|
const dispatch = useDispatch(); |
|
|
@ -23,6 +27,9 @@ export default function MeasureAction() { |
|
|
|
|
|
|
|
const navigate = useNavigate(); |
|
|
|
|
|
|
|
const [angles, setAngles] = useState<AnalyzeAngle[]>([]); |
|
|
|
const [taskStatus, setTaskStatus] = useState<MeasureState["data"]["taskStatus"]>("IDLE"); |
|
|
|
|
|
|
|
const onAfterSaveChange: CheckboxProps["onChange"] = e => { |
|
|
|
dispatch(switchMeasureAfterSave(e.target.checked)); |
|
|
|
}; |
|
|
@ -30,12 +37,11 @@ export default function MeasureAction() { |
|
|
|
// navigate("../detail");
|
|
|
|
analyzeMeasurement().then(res => { |
|
|
|
if (res.success) { |
|
|
|
// mask
|
|
|
|
|
|
|
|
setAngles(res.data.angles); |
|
|
|
} else { |
|
|
|
message.error(res.data.info); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const onStart = () => { |
|
|
@ -61,6 +67,15 @@ export default function MeasureAction() { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
const subscription = wsClient.dataOb.subscribe(data => { |
|
|
|
if (data.messageType === "STATE" && data.path === "/measurement-task/get-task-state") { |
|
|
|
setTaskStatus(data.data.taskStatus); |
|
|
|
} |
|
|
|
}); |
|
|
|
wsClient.connect(); |
|
|
|
return () => subscription.unsubscribe(); |
|
|
|
}); |
|
|
|
return ( |
|
|
|
<div className="flex h-full "> |
|
|
|
<div className="flex-none"> |
|
|
@ -77,10 +92,12 @@ export default function MeasureAction() { |
|
|
|
<Switch defaultChecked onChange={checked => setShowResult(checked)} /> |
|
|
|
<span>对比线</span> |
|
|
|
</div> |
|
|
|
<div className="flex gap-2 items-center"> |
|
|
|
<Switch defaultChecked onChange={checked => setShowMark(checked)} /> |
|
|
|
<span>角度线</span> |
|
|
|
</div> |
|
|
|
{angles.length > 0 && ( |
|
|
|
<div className="flex gap-2 items-center"> |
|
|
|
<Switch defaultChecked onChange={checked => setShowMark(checked)} /> |
|
|
|
<span>角度线</span> |
|
|
|
</div> |
|
|
|
)} |
|
|
|
</div> |
|
|
|
<div className="relative"> |
|
|
|
<GridLayer |
|
|
@ -122,25 +139,28 @@ export default function MeasureAction() { |
|
|
|
visibility={showResult ? "visible" : "hidden"} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
<div className="absolute top-0"> |
|
|
|
<MarkLayer |
|
|
|
width={840} |
|
|
|
height={600} |
|
|
|
leftPadding={30} |
|
|
|
rightPadding={10} |
|
|
|
topPadding={10} |
|
|
|
bottomPadding={30} |
|
|
|
columns={10} |
|
|
|
rows={7} |
|
|
|
visibility={showMark ? "visible" : "hidden"} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
{angles.length > 0 && ( |
|
|
|
<div className="absolute top-0"> |
|
|
|
<MarkLayer |
|
|
|
width={840} |
|
|
|
height={600} |
|
|
|
leftPadding={30} |
|
|
|
rightPadding={10} |
|
|
|
topPadding={10} |
|
|
|
bottomPadding={30} |
|
|
|
columns={10} |
|
|
|
rows={7} |
|
|
|
visibility={showMark ? "visible" : "hidden"} |
|
|
|
angles={angles} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
)} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="w-[300px] flex-none py-6"> |
|
|
|
<h1 className="font-medium text-xl text-center">测量步骤</h1> |
|
|
|
<section className="flex flex-col items-center gap-4 mt-6 border-t border-[#D8D8D8] py-4"> |
|
|
|
<div>正在测量的状态</div> |
|
|
|
<div>测量状态: {taskStatusDescMap[taskStatus]}</div> |
|
|
|
<Button style={{ width: 200 }} size="large" type="primary" onClick={onStart}> |
|
|
|
开始测量 |
|
|
|
</Button> |
|
|
|