#
luxiaotao1123
2024-04-12 8c7348dab003a558bcd1b465c239d768584d2dc0
#
1个文件已修改
139 ■■■■■ 已修改文件
zy-asrs-flow/src/pages/map/drawer/shuttle/handle.jsx 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,77 @@
        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;
        }
    }
    return (
        <>
            <Drawer
                title={intl.formatMessage({ id: 'map.command', defaultMessage: '命令' })}
                width={350}
                width={420}
                closable={false}
                open={props.open}
                getContainer={props.refCurr}
@@ -36,13 +112,62 @@
                        <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: '子轨道循环跑' }
                                    ]}
                                />
                            </div>
                            <Button onClick={() => shuttleMoveLoc()}>跑库</Button>
                        </div>
                    </Card>
                </div>
            </Drawer>
        </>
@@ -50,4 +175,4 @@
}
export default ShuttleHandle;
export default ShuttleHandle