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/map/drawer/shuttle/handle.jsx |  159 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 152 insertions(+), 7 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/drawer/shuttle/handle.jsx b/zy-asrs-flow/src/pages/map/drawer/shuttle/handle.jsx
index 2e94e36..40d5946 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shuttle/handle.jsx
+++ b/zy-asrs-flow/src/pages/map/drawer/shuttle/handle.jsx
@@ -1,8 +1,9 @@
 import React, { useState, useRef, useEffect } from 'react';
-import { Col, Form, Input, Row, Switch, Slider, message, Drawer, Space, Button, InputNumber, Segmented } from 'antd';
+import { Card, Form, Input, Row, Switch, Slider, message, Drawer, Space, Button, InputNumber, Select } from 'antd';
 import { FormattedMessage, useIntl, useModel } from '@umijs/max';
 import { createStyles } from 'antd-style';
 import Http from '@/utils/http';
+import { log } from 'three/examples/jsm/nodes/Nodes.js';
 
 const useStyles = createStyles(({ token, css }) => {
 
@@ -12,6 +13,16 @@
     const intl = useIntl();
     const { styles } = useStyles();
 
+    const { shuttleNo } = props;
+
+    const [sourceLoc, setSourceLoc] = useState(null);
+    const [targetLoc, setTargetLoc] = useState(null);
+    const [xStart, setXStart] = useState(null);
+    const [xTarget, setXTarget] = useState(null);
+    const [yStart, setYStart] = useState(null);
+    const [yTarget, setYTarget] = useState(null);
+    const [moveLocType, setMoveLocType] = useState(1);
+
     useEffect(() => {
 
     }, []);
@@ -20,12 +31,95 @@
         props.onClose();
     }
 
+    const shuttleOperator = async (type) => {
+        if (type == 'moveLoc') {
+            if (!targetLoc) {
+                message.warning('璇疯緭鍏ョ洰鏍囦綅缃�');
+                return;
+            }
+        }
+        if (type == 'takeMove') {
+            if (!sourceLoc) {
+                message.warning('璇疯緭鍏ヨ捣濮嬩綅缃�');
+                return;
+            }
+            if (!targetLoc) {
+                message.warning('璇疯緭鍏ョ洰鏍囦綅缃�');
+                return;
+            }
+        }
+
+        try {
+            const resp = await Http.doPost('api/basShuttle/operator/shuttle', {
+                shuttleNo: shuttleNo,
+                shuttleTaskMode: type,
+                sourceLocNo: sourceLoc,
+                targetLocNo: targetLoc,
+            });
+            if (resp.code === 200) {
+                message.success("璇锋眰鎴愬姛");
+                return true;
+            } else {
+                message.warning(resp.msg);
+                return false;
+            }
+        } catch (error) {
+            message.warning("璇锋眰澶辫触");
+            return false;
+        }
+    }
+
+    const shuttleMoveLoc = async () => {
+        if (!xStart || !xTarget || !yStart || !yTarget) {
+            message.warning('璇疯緭鍏ュ弬鏁�');
+            return;
+        }
+
+        try {
+            const resp = await Http.doPost('api/basShuttle/moveLoc', {
+                shuttleNo: shuttleNo,
+                moveType: moveLocType,
+                startX: xStart,
+                targetX: xTarget,
+                startY: yStart,
+                targetY: yTarget,
+            });
+            if (resp.code === 200) {
+                message.success("璇锋眰鎴愬姛");
+                return true;
+            } else {
+                message.warning(resp.msg);
+                return false;
+            }
+        } catch (error) {
+            message.warning("璇锋眰澶辫触");
+            return false;
+        }
+    }
+
+    const shuttleMoveLocClose = async () => {
+        try {
+            const resp = await Http.doPost('api/basShuttle/moveLocClose', {
+                shuttleNo: currentData.shuttleNo,
+            });
+            if (resp.code === 200) {
+                message.success("璇锋眰鎴愬姛");
+                return true;
+            } else {
+                message.warning(resp.msg);
+                return false;
+            }
+        } catch (error) {
+            message.warning("璇锋眰澶辫触");
+            return false;
+        }
+    }
 
     return (
         <>
             <Drawer
                 title={intl.formatMessage({ id: 'map.command', defaultMessage: '鍛戒护' })}
-                width={350}
+                width={420}
                 closable={false}
                 open={props.open}
                 getContainer={props.refCurr}
@@ -36,13 +130,64 @@
                         <Button onClick={handleCancel}>
                             <FormattedMessage id='common.cancel' defaultMessage='鍙栨秷' />
                         </Button>
-                        {/* <Button onClick={handleOk} type="primary">
-                            <FormattedMessage id='common.submit' defaultMessage='纭畾' />
-                        </Button> */}
                     </Space>
                 }
             >
-                <h1>asds</h1>
+
+                <h2 style={{ marginBottom: '15px' }}>{shuttleNo}鍙峰洓鍚戣溅</h2>
+                <div style={{ marginBottom: '15px' }}>
+                    <Card title="绉诲姩鎸囦护">
+                        <p>
+                            <Input addonBefore="璧峰浣嶇疆" value={sourceLoc} onChange={e => setSourceLoc(e.target.value)} />
+                        </p>
+                        <p>
+                            <Input addonBefore="鐩爣浣嶇疆" value={targetLoc} onChange={e => setTargetLoc(e.target.value)} />
+                        </p>
+                        <p>
+                            <Button onClick={() => shuttleOperator('moveLoc')}>绉诲姩鍒扮洰鏍囦綅缃�</Button>
+                            <Button onClick={() => shuttleOperator('takeMove')} style={{ marginLeft: '30px' }}>鍙栨斁璐т綔涓�</Button>
+                        </p>
+                    </Card>
+                </div>
+
+                <div style={{ marginBottom: '15px' }}>
+                    <Card title="鐩稿叧鎸囦护" >
+                        <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="璺戝簱绯荤粺" >
+                        <div className="commandItem">
+                            <div><Input addonBefore="X璧风偣" defaultValue="1" value={xStart} onChange={e => setXStart(e.target.value)} /></div>
+                            <div><Input addonBefore="X缁堢偣" defaultValue="1" value={xTarget} onChange={e => setXTarget(e.target.value)} /></div>
+                            <div><Input addonBefore="Y璧风偣" defaultValue="1" value={yStart} onChange={e => setYStart(e.target.value)} /></div>
+                            <div><Input addonBefore="Y缁堢偣" defaultValue="1" value={yTarget} onChange={e => setYTarget(e.target.value)} /></div>
+                            <div>
+                                <Select
+                                    defaultValue="0"
+                                    onChange={setMoveLocType}
+                                    style={{ width: 120 }}
+                                    options={[
+                                        { value: '0', label: '璺戣建閬�' },
+                                        { value: '1', label: '璺戝簱浣�' },
+                                        { value: '2', label: '姣嶈建閬撳惊鐜窇' },
+                                        { value: '3', label: '瀛愯建閬撳惊鐜窇' },
+                                        { value: '4', label: '鍙栨斁璐�' }
+                                    ]}
+                                />
+                            </div>
+                            <Button onClick={() => shuttleMoveLoc()}>璺戝簱</Button>
+                            <Button onClick={() => shuttleMoveLocClose()}>璺戝簱鍏抽棴</Button>
+                        </div>
+                    </Card>
+                </div>
 
             </Drawer>
         </>
@@ -50,4 +195,4 @@
 
 }
 
-export default ShuttleHandle;
\ No newline at end of file
+export default ShuttleHandle
\ No newline at end of file

--
Gitblit v1.9.1