| import React, { useState, useRef, useEffect } from 'react'; | 
| 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 }) => { | 
|   | 
| }) | 
|   | 
| const ShuttleHandle = (props) => { | 
|     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(() => { | 
|   | 
|     }, []); | 
|   | 
|     const handleCancel = () => { | 
|         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={420} | 
|                 closable={false} | 
|                 open={props.open} | 
|                 getContainer={props.refCurr} | 
|                 rootStyle={{ position: "absolute" }} | 
|                 onClose={handleCancel} | 
|                 extra={ | 
|                     <Space> | 
|                         <Button onClick={handleCancel}> | 
|                             <FormattedMessage id='common.cancel' defaultMessage='取消' /> | 
|                         </Button> | 
|                     </Space> | 
|                 } | 
|             > | 
|   | 
|                 <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> | 
|         </> | 
|     ) | 
|   | 
| } | 
|   | 
| export default ShuttleHandle |