#
whycq
2024-07-11 18d258c246cb9e4812964968769eb32fa990065a
zy-asrs-flow/src/pages/device/shuttle/index.jsx
@@ -6,6 +6,7 @@
    PageContainer,
} from '@ant-design/pro-components';
import './index.less'
import { WEBSOCKET_BASE_URL } from '@/config/setting';
const Main = () => {
    const [deviceInfos, setDeviceInfos] = useState([]);
@@ -21,8 +22,7 @@
    const [moveLocType, setMoveLocType] = useState(1);
    useEffect(() => {
        var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket");
        setWs(newWs);
        connect();
        return () => {
            if (ws) {
@@ -58,6 +58,7 @@
            ws.onclose = function (e) {
                console.log("close");
                reconnect();
            }
            ws.onerror = function (e) {
@@ -65,6 +66,18 @@
            }
        }
    }, [ws]);
    const connect = () => {
        var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/shuttle/websocket");
        setWs(newWs);
    }
    const reconnect = () => {
        setTimeout(() => {
            console.log('WebSocketClient: Attempting to reconnect...');
            connect();
        }, 3000);
    }
    const sendWs = (message) => {
        if (ws.readyState == WebSocket.OPEN) {
@@ -278,7 +291,12 @@
                        key: '13',
                        label: '自动',
                        children: item.mode ? 'Y' : 'N',
                    }
                    },
                    {
                        key: '14',
                        label: '库位号',
                        children: item.currentLocNo,
                    },
                ];
                return <div key={item.id} style={{ width: '45%' }}>
                    <div style={{ marginBottom: '10px' }}>