You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. import { Button, Checkbox, CheckboxProps, Radio, RadioChangeEvent, message } from "antd";
  2. import { useState, useEffect } from "react";
  3. import { useNavigate } from "react-router";
  4. import SectionalView from "./SectionalView";
  5. import { startMeasurement } from "../../../services/measure/analysis"
  6. import { createWebSocket, sharedWsUrl } from "../../../services/socket";
  7. export default function MeasureAction() {
  8. const navigate = useNavigate();
  9. const [sideVal, setSideVal] = useState<1 | 2>(1);
  10. const onSideChange = (e: RadioChangeEvent) => {
  11. setSideVal(e.target.value);
  12. };
  13. const onAfterSaveChange: CheckboxProps["onChange"] = e => {
  14. console.log(`checked = ${e.target.checked}`);
  15. };
  16. const onAnalysisBtnClick = () => {
  17. // navigate("../detail");
  18. };
  19. useEffect(()=>{
  20. connectWebpacket()
  21. },[])
  22. const connectWebpacket = ()=>{
  23. //连接websocket
  24. const wsClient = createWebSocket(sharedWsUrl);
  25. let subscription = wsClient.dataOb.subscribe(data => {
  26. console.log('data--wsClient-显示上报的数据')
  27. });
  28. wsClient.connect();
  29. }
  30. const onStart = () => {
  31. startMeasurement().then(res=>{
  32. console.log('startMeasurement===', res)
  33. message.success('已通知设备开始测量')
  34. })
  35. }
  36. return (
  37. <div className="flex h-full ">
  38. <div className="flex-none border">
  39. <SectionalView width={840} height={600} leftPadding={30} rightPadding={10} topPadding={10} bottomPadding={30} columns={10} rows={7} cellNum={10} />
  40. </div>
  41. <div className="w-[300px] flex-none py-6">
  42. <h1 className="font-medium text-xl text-center"></h1>
  43. <section className="flex flex-col items-center gap-4 mt-6 border-t border-[#D8D8D8] py-4">
  44. <div></div>
  45. {/* <Radio.Group
  46. value={sideVal}
  47. onChange={onSideChange}
  48. options={[
  49. { value: 1, label: "测量左侧" },
  50. { value: 2, label: "测量右侧" },
  51. ]}
  52. /> */}
  53. <Button style={{ width: 200 }} size="large" type="primary" onClick={onStart}>
  54. </Button>
  55. <Button style={{ width: 200 }} size="large" type="primary" onClick={onAnalysisBtnClick}>
  56. </Button>
  57. <Button style={{ width: 200 }} size="large" type="primary">
  58. </Button>
  59. <Checkbox onChange={onAfterSaveChange}></Checkbox>
  60. </section>
  61. </div>
  62. </div>
  63. );
  64. }