From f669520fd3e90501d64682ba131cc6bc737bfdaf Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期日, 07 四月 2024 16:56:34 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/device/shuttle/index.jsx  |  318 ++++++++++++++++++++++++++++++----------------------
 zy-asrs-flow/src/pages/device/shuttle/index.less |   15 ++
 2 files changed, 198 insertions(+), 135 deletions(-)

diff --git a/zy-asrs-flow/src/pages/device/shuttle/index.jsx b/zy-asrs-flow/src/pages/device/shuttle/index.jsx
index 13a5bb2..11d4f34 100644
--- a/zy-asrs-flow/src/pages/device/shuttle/index.jsx
+++ b/zy-asrs-flow/src/pages/device/shuttle/index.jsx
@@ -1,66 +1,18 @@
 import React, { useEffect, useRef, useState } from "react";
 import { getToken } from '@/utils/token-util'
-import { Badge, Descriptions } from 'antd';
+import Http from '@/utils/http';
+import { Badge, Button, Descriptions, Drawer, Input, Card, Select, message } from 'antd';
 import {
     PageContainer,
 } from '@ant-design/pro-components';
-
-let items = [
-    {
-        key: '1',
-        label: '浠诲姟鍙�',
-        children: '1',
-    },
-    {
-        key: '2',
-        label: '宸ヤ綔鐘舵��',
-        children: <Badge status="processing" text="Running" />,
-    },
-    {
-        key: '3',
-        label: '璁惧鐘舵��',
-        children: <Badge status="processing" text="Running" />,
-    },
-    {
-        key: '4',
-        label: '鍧愭爣鐮�',
-        children: '1,2,3',
-    },
-    {
-        key: '5',
-        label: '鐢甸噺',
-        children: '50%',
-    },
-    {
-        key: '6',
-        label: '閿欒鐮�',
-        children: '0',
-    },
-    {
-        key: '7',
-        label: '椤跺崌鐘舵��',
-        children: 'Y',
-    },
-    {
-        key: '8',
-        label: '鍏呯數鐘舵��',
-        children: 'Y',
-    },
-    {
-        key: '9',
-        label: '浣滀笟鏍囪',
-        children: 'Y',
-    },
-    {
-        key: '10',
-        label: '璺戝簱寮�鍏�',
-        children: 'Y',
-    },
-];
+import './index.less'
 
 const Main = () => {
     const [deviceInfos, setDeviceInfos] = useState([]);
     const [ws, setWs] = useState(null);
+    const [openOpera, setOpenOpera] = useState(false);
+    const [currentData, setCurrentData] = useState(null);
+    const [targetLoc, setTargetLoc] = useState("");
 
     useEffect(() => {
         var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket");
@@ -74,7 +26,6 @@
     }, [])
 
     useEffect(() => {
-
         if (ws) {
             ws.onopen = function () {
                 console.log("open");
@@ -122,87 +73,184 @@
         }))
     }
 
-    return (
-        <PageContainer
-            header={{
-                breadcrumb: {},
-            }}
-        >
-            <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-around' }}>
-                {deviceInfos.map(item => {
-                    if(item == null) {
-                        return;
-                    }
-                    let tmpTitle = item.shuttleNo + "鍙峰洓鍚戣溅"
-                    let tmpData = [
-                        {
-                            key: '1',
-                            label: '浠诲姟鍙�',
-                            children: item.taskNo,
-                        },
-                        {
-                            key: '2',
-                            label: '宸ヤ綔鐘舵��',
-                            children: <Badge status="processing" text={item.protocolStatusType} />,
-                        },
-                        {
-                            key: '3',
-                            label: '璁惧鐘舵��',
-                            children: <Badge status="processing" text={item.deviceStatus$} />,
-                        },
-                        {
-                            key: '4',
-                            label: '鍧愭爣鐮�',
-                            children: item.currentCode,
-                        },
-                        {
-                            key: '5',
-                            label: '鐢甸噺',
-                            children: item.batteryPower,
-                        },
-                        {
-                            key: '6',
-                            label: '閿欒鐮�',
-                            children: '0',
-                        },
-                        {
-                            key: '7',
-                            label: '椤跺崌鐘舵��',
-                            children: item.hasLift ? 'Y' : 'N',
-                        },
-                        {
-                            key: '8',
-                            label: '鍏呯數鐘舵��',
-                            children: item.hasCharge ? 'Y' : 'N',
-                        },
-                        {
-                            key: '9',
-                            label: '浣滀笟鏍囪',
-                            children: item.pakMk ? 'Y' : 'N',
-                        },
-                        {
-                            key: '10',
-                            label: '璺戝簱寮�鍏�',
-                            children: item.moveLoc ? 'Y' : 'N',
-                        },
-                        {
-                            key: '11',
-                            label: '杩愯鏂瑰悜',
-                            children: item.runDirection,
-                        },
-                        {
-                            key: '12',
-                            label: '鏄惁鏈夋墭鐩�',
-                            children: item.hasPallet ? 'Y' : 'N',
-                        },
-                    ];
-                    return <div key={item.id} style={{ width: '45%' }}>
-                        <Descriptions size="small" title={tmpTitle} bordered items={tmpData} />
+    const showOpera = (data) => {
+        setOpenOpera(true);
+        console.log(data);
+        setCurrentData(data);
+    };
+
+    const closeOpera = () => {
+        setOpenOpera(false);
+    };
+
+    const targetLocChange = (e) => {
+        setTargetLoc(e.target.value)
+    }
+
+    const shuttleOperator = async (type) => {
+        if (type == 'moveLoc') {
+            if (targetLoc == '') {
+                message.warning('璇疯緭鍏ョ洰鏍囦綅缃�');
+                return;
+            }
+        }
+
+        try {
+            const resp = await Http.doPost('api/basShuttle/operator/shuttle', {
+                shuttleNo: currentData.shuttleNo,
+                shuttleTaskMode: type,
+                targetLocNo: targetLoc
+            });
+            if (resp.code === 200) {
+                message.success("璇锋眰鎴愬姛");
+                return true;
+            } else {
+                message.warning(resp.msg);
+                return false;
+            }
+        } catch (error) {
+            message.warning("璇锋眰澶辫触");
+            return false;
+        }
+    }
+
+    let codeContent = (<PageContainer
+        header={{
+            breadcrumb: {},
+        }}
+    >
+        <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-around' }}>
+            {deviceInfos.map(item => {
+                if (item == null) {
+                    return;
+                }
+                let tmpTitle = item.shuttleNo + "鍙峰洓鍚戣溅"
+                let tmpData = [
+                    {
+                        key: '1',
+                        label: '浠诲姟鍙�',
+                        children: item.taskNo,
+                    },
+                    {
+                        key: '2',
+                        label: '宸ヤ綔鐘舵��',
+                        children: <Badge status="processing" text={item.protocolStatusType} />,
+                    },
+                    {
+                        key: '3',
+                        label: '璁惧鐘舵��',
+                        children: <Badge status="processing" text={item.deviceStatus$} />,
+                    },
+                    {
+                        key: '4',
+                        label: '鍧愭爣鐮�',
+                        children: item.currentCode,
+                    },
+                    {
+                        key: '5',
+                        label: '鐢甸噺',
+                        children: item.batteryPower,
+                    },
+                    {
+                        key: '6',
+                        label: '閿欒鐮�',
+                        children: '0',
+                    },
+                    {
+                        key: '7',
+                        label: '椤跺崌鐘舵��',
+                        children: item.hasLift ? 'Y' : 'N',
+                    },
+                    {
+                        key: '8',
+                        label: '鍏呯數鐘舵��',
+                        children: item.hasCharge ? 'Y' : 'N',
+                    },
+                    {
+                        key: '9',
+                        label: '浣滀笟鏍囪',
+                        children: item.pakMk ? 'Y' : 'N',
+                    },
+                    {
+                        key: '10',
+                        label: '璺戝簱寮�鍏�',
+                        children: item.moveLoc ? 'Y' : 'N',
+                    },
+                    {
+                        key: '11',
+                        label: '杩愯鏂瑰悜',
+                        children: item.runDirection,
+                    },
+                    {
+                        key: '12',
+                        label: '鏄惁鏈夋墭鐩�',
+                        children: item.hasPallet ? 'Y' : 'N',
+                    },
+                ];
+                return <div key={item.id} style={{ width: '45%' }}>
+                    <div style={{ marginBottom: '10px' }}>
+                        <span style={{ marginRight: '10px' }}>{tmpTitle}</span>
+                        <Button type="primary" onClick={() => showOpera(item)}>鎿嶄綔</Button>
                     </div>
-                })}
-            </div>
-        </PageContainer>
-    )
+                    <Descriptions size="small" bordered items={tmpData} />
+                </div>
+            })}
+        </div>
+    </PageContainer>);
+
+    if (currentData) {
+        codeContent = (
+            <>
+                {codeContent}
+                <Drawer title="鎿嶄綔闈㈡澘" onClose={closeOpera} open={openOpera}>
+                    <h2 style={{ marginBottom: '15px' }}>{currentData.shuttleNo}鍙峰洓鍚戣溅</h2>
+                    <div style={{ marginBottom: '15px' }}>
+                        <Card title="绉诲姩鎸囦护" style={{ width: 300 }}>
+                            <p>
+                                <Input addonBefore="鐩爣浣嶇疆" defaultValue="1-1-1" onChange={targetLocChange} />
+                            </p>
+                            <p>
+                                <Button onClick={() => shuttleOperator('moveLoc')}>绉诲姩鍒扮洰鏍囦綅缃�</Button>
+                            </p>
+                        </Card>
+                    </div>
+
+                    <div style={{ marginBottom: '15px' }}>
+                        <Card title="鐩稿叧鎸囦护" style={{ width: 300 }}>
+                            <div className="commandItem">
+                                <Button onClick={() => shuttleOperator('palletLift')}>鎵樼洏椤跺崌</Button>
+                                <Button onClick={() => shuttleOperator('palletDown')}>鎵樼洏涓嬮檷</Button>
+                                <Button onClick={() => shuttleOperator('chargeOpen')}>鍏呯數寮�</Button>
+                                <Button onClick={() => shuttleOperator('chargeClose')}>鍏呯數鍏�</Button>
+                                <Button onClick={() => shuttleOperator('reset')}>澶嶄綅</Button>
+                            </div>
+                        </Card>
+                    </div>
+
+                    <div style={{ marginBottom: '15px' }}>
+                        <Card title="璺戝簱绯荤粺" style={{ width: 300 }}>
+                            <div className="commandItem">
+                                <div><Input addonBefore="X璧风偣" defaultValue="1" /></div>
+                                <div><Input addonBefore="X缁堢偣" defaultValue="1" /></div>
+                                <div><Input addonBefore="Y璧风偣" defaultValue="1" /></div>
+                                <div><Input addonBefore="Y缁堢偣" defaultValue="1" /></div>
+                                <div>
+                                    <Select
+                                        defaultValue="0"
+                                        style={{ width: 120 }}
+                                        options={[{ value: '0', label: '璺戣建閬�' }, { value: '1', label: '璺戝簱浣�' }, { value: '2', label: '姣嶈建閬撳惊鐜窇' }, { value: '3', label: '瀛愯建閬撳惊鐜窇' }]}
+                                    />
+                                </div>
+                                <Button>璺戝簱</Button>
+                            </div>
+                        </Card>
+                    </div>
+                </Drawer>
+            </>
+        )
+    }
+
+    return (codeContent);
 }
 
 export default Main;
\ No newline at end of file
diff --git a/zy-asrs-flow/src/pages/device/shuttle/index.less b/zy-asrs-flow/src/pages/device/shuttle/index.less
new file mode 100644
index 0000000..d70f38a
--- /dev/null
+++ b/zy-asrs-flow/src/pages/device/shuttle/index.less
@@ -0,0 +1,15 @@
+.commandItem {
+    display: flex;
+    justify-content: space-between;
+    flex-wrap: wrap;
+}
+
+.commandItem > Button {
+    width: 120px;
+    margin-bottom: 10px;
+}
+
+.commandItem > div {
+    width: 120px;
+    margin-bottom: 10px;
+}
\ No newline at end of file

--
Gitblit v1.9.1