From d835d1b51f832889929cdf69010034a30ef44d02 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 17 十月 2024 13:57:29 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/device/lift/index.jsx |   80 +++++++++++++++++++++++++++++++++-------
 1 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/zy-asrs-flow/src/pages/device/lift/index.jsx b/zy-asrs-flow/src/pages/device/lift/index.jsx
index 9d046e4..d6e0405 100644
--- a/zy-asrs-flow/src/pages/device/lift/index.jsx
+++ b/zy-asrs-flow/src/pages/device/lift/index.jsx
@@ -6,18 +6,21 @@
     PageContainer,
 } from '@ant-design/pro-components';
 import './index.less'
+import { WEBSOCKET_BASE_URL } from '@/config/setting';
 
 const Main = () => {
     const [deviceInfos, setDeviceInfos] = useState([]);
     const [ws, setWs] = useState(null);
     const [openOpera, setOpenOpera] = useState(false);
     const [currentData, setCurrentData] = useState(null);
-    const [moveLocType, setMoveLocType] = useState(1);
     const [mapLev, setMapLev] = useState([]);
+    const [targetLoc, setTargetLoc] = useState(1);
+    const [originLoc, setOriginLoc] = useState(null);
+    const [originSite, setOriginSite] = useState(null);
+    const [targetSite, setTargetSite] = useState(null);
 
     useEffect(() => {
-        var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/lift/websocket");
-        setWs(newWs);
+        connect();
 
         getMapLev();
 
@@ -55,6 +58,7 @@
 
             ws.onclose = function (e) {
                 console.log("close");
+                reconnect();
             }
 
             ws.onerror = function (e) {
@@ -62,6 +66,18 @@
             }
         }
     }, [ws]);
+    
+    const connect = () => {
+        var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/lift/websocket");
+        setWs(newWs);
+    }
+
+    const reconnect = () => {
+        setTimeout(() => {
+            console.log('WebSocketClient: Attempting to reconnect...');
+            connect();
+        }, 3000);
+    }
 
     const sendWs = (message) => {
         if (ws.readyState == WebSocket.OPEN) {
@@ -78,7 +94,6 @@
 
     const showOpera = (data) => {
         setOpenOpera(true);
-        console.log(data);
         setCurrentData(data);
     };
 
@@ -110,8 +125,20 @@
         }
     }
 
-    const targetLocChange = (e) => {
-        setTargetLoc(e.target.value)
+    const targetLocChange = (value) => {
+        setTargetLoc(value)
+    }
+
+    const originLocChange = (e) => {
+        setOriginLoc(e.target.value)
+    }
+
+    const targetSiteChange = (e) => {
+        setTargetSite(e.target.value)
+    }
+
+    const originSiteChange = (e) => {
+        setOriginSite(e.target.value)
     }
 
     const liftOperator = async (type) => {
@@ -119,8 +146,10 @@
             const resp = await Http.doPost('api/basLift/operator/lift', {
                 liftNo: currentData.liftNo,
                 liftTaskMode: type,
-                sourceStaNo: 0,
-                staNo: moveLocType
+                sourceStaNo: originSite,
+                staNo: targetSite,
+                sourceLev: originLoc,
+                targetLev: targetLoc,
             });
             if (resp.code === 200) {
                 message.success("璇锋眰鎴愬姛");
@@ -133,10 +162,6 @@
             message.warning("璇锋眰澶辫触");
             return false;
         }
-    }
-
-    const moveLocTypeChange = (e) => {
-        setMoveLocType(e)
     }
 
     let codeContent = (<PageContainer
@@ -201,6 +226,16 @@
                         label: '褰撳墠灞�',
                         children: item.lev,
                     },
+                    {
+                        key: '11',
+                        label: '宸插畬鎴愪换鍔″彿',
+                        children: item.completeTaskNo,
+                    },
+                    {
+                        key: '12',
+                        label: '鎵╁睍',
+                        children: JSON.stringify(item.extend),
+                    },
                 ];
                 return <div key={item.id} style={{ width: '45%' }}>
                     <div style={{ marginBottom: '10px' }}>
@@ -224,12 +259,23 @@
                             <p>
                                 <Select
                                     defaultValue="1"
-                                    onChange={moveLocTypeChange}
+                                    onChange={targetLocChange}
                                     style={{ width: 120 }}
                                     options={mapLev}
                                 />
-                                <span><Button onClick={() => liftOperator('move')}>绉诲姩</Button></span>
+                                <span><Button onClick={() => liftOperator('move')}>鍗囬檷</Button></span>
                             </p>
+                            <p>
+                                <Input addonBefore="璧峰浣嶇疆" onChange={originSiteChange} />
+                            </p>
+                            <p>
+                                <Input addonBefore="鐩爣浣嶇疆" onChange={targetSiteChange} />
+                            </p>
+                            <p>
+                            </p>
+                            <div className="commandItem">
+                                <Button onClick={() => liftOperator('movePallet')}>鎵樼洏鍑哄叆</Button>
+                            </div>
                         </Card>
                     </div>
 
@@ -238,6 +284,12 @@
                             <div className="commandItem">
                                 <Button onClick={() => liftOperator('reset')}>澶嶄綅</Button>
                             </div>
+                            <div className="commandItem">
+                                <Button onClick={() => liftOperator('lock')}>閿佸畾</Button>
+                            </div>
+                            <div className="commandItem">
+                                <Button onClick={() => liftOperator('unlock')}>瑙i攣</Button>
+                            </div>
                         </Card>
                     </div>
                 </Drawer>

--
Gitblit v1.9.1