zjj
2025-02-17 a4093814b51bba7eae9530cfa076f6242df3f5f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import React, { useRef, useEffect, useState } from "react";
import { Button, Drawer, Input, Switch, Select, Checkbox } from 'antd';
import { initNodeData } from "../GraphConfig";
 
const { TextArea } = Input;
const CheckboxGroup = Checkbox.Group;
 
export const GraphDrawerLift = ({ graphRef, isReady }) => {
 
    const [open, setOpen] = useState(false);
    const [init, setInit] = useState(false);
    const [nodeData, setNodeData] = useState(null);
    const [codeContent, setCodeContent] = useState(null);
    const [execClass, setExecClass] = useState(null);
    const [execApi, setExecApi] = useState(null);
    const [liftOper, setLiftOper] = useState([]);
    const [sourceLev, setSourceLev] = useState(null);
    const [targetLev, setTargetLev] = useState(null);
 
    const classList = [
        { value: 'ShuttleThread', label: '提升机' },
    ];
 
    const apiList = [
        { value: 'load', label: '取货' },
        { value: 'unload', label: '放货' },
        { value: 'loadAndUnload', label: '取放货' },
    ];
 
    const liftOptions = [
        {
            label: '无',
            value: 'none'
        },
        {
            label: '升降',
            value: 'move'
        },
    ];
 
    const liftOptions2 = [
        {
            label: '无',
            value: 'none'
        },
        {
            label: '穿梭车层',
            value: 'shuttleLev'
        },
        {
            label: '工作档源库位层',
            value: 'originLev'
        },
        {
            label: '工作档目标库位层',
            value: 'targetLev'
        },
    ];
 
    const sourceLevChange = (event) => {
        setSourceLev(event);
        nodeData.data.liftType.sourceLev = event;
    }
 
    const targetLevChange = (event) => {
        setTargetLev(event);
        nodeData.data.liftType.targetLev = event;
    }
 
    const liftOptionsChange = (event) => {
        setLiftOper(event);
        nodeData.data.liftType.liftOper = event;
    };
 
    const showNodeDrawer = (graph, node) => {
        if (node.data.type == "lift") {
            setOpen(true);
            setNodeData(node);
            if (node.data == null) {
                node.data = initNodeData;
            }
 
            if (node.data.codeContent != null) {
                setCodeContent(node.data.codeContent);
            }
 
            if (node.data.execClass != null) {
                setExecClass(node.data.execClass);
            } else {
                setExecClass(null);
            }
 
            if (node.data.execApi != null) {
                setExecApi(node.data.execApi);
            } else {
                setExecApi(null);
            }
 
            if (node.data.liftType == null) {
                node.data.liftType = {
                    liftOper: '',//操作方法
                }
            } else {
                const liftType = node.data.liftType;
                setLiftOper(liftType.liftOper);
            }
 
        }
    };
 
    const onNodeClose = (e) => {
        setOpen(false);
        setNodeData(null);
        setCodeContent(null);
    };
 
    const nodeTextAreaChange = (e) => {
        setCodeContent(e.target.value);
        nodeData.data.codeContent = e.target.value;
    }
 
    const nodeDataInputChange = (e) => {
        nodeData.label = e.target.value;
    }
 
    const classListChange = (e) => {
        setExecClass(e);
        nodeData.data.execClass = e;
    }
 
    const apiListChange = (e) => {
        setExecApi(e);
        nodeData.data.execApi = e;
    }
 
    useEffect(() => {
        if (isReady) {
            const graph = graphRef.current;
 
            if (!init) {
                graph.on("node:dblclick", ({ node }) => {
                    showNodeDrawer(graph, node);
                })
                setInit(true);
            }
        }
    }, [apiList])
 
    if (nodeData) {
        return (
            <>
                <Drawer title={nodeData.label} onClose={onNodeClose} open={open} size="large">
                    <div className="graphDrawerContainer">
                        <div>提升机组件</div>
                        <div>ID:{nodeData.id}</div>
                        <div>组件名:<Input defaultValue={nodeData.label} onChange={nodeDataInputChange} /></div>
                        <div>根节点:<Switch checkedChildren="是" unCheckedChildren="否" checked={nodeData.data.root} /></div>
                        <div>
                            源层:
                            <Select
                                style={{ width: 240 }}
                                options={liftOptions2}
                                value={sourceLev}
                                onChange={sourceLevChange}
                            />
                        </div>
                        <div>
                            目标层:
                            <Select
                                style={{ width: 240 }}
                                options={liftOptions2}
                                value={targetLev}
                                onChange={targetLevChange}
                            />
                        </div>
                        <div>
                            操作方法:
                            <Select
                                style={{ width: 240 }}
                                options={liftOptions}
                                value={liftOper}
                                onChange={liftOptionsChange}
                            />
                        </div>
                        <div>
                            执行类:
                            <Select
                                style={{ width: 120 }}
                                options={classList}
                                onChange={classListChange}
                                defaultValue={execClass}
                            />
                        </div>
                        <div>
                            执行接口:
                            <Select
                                style={{ width: 120 }}
                                options={apiList}
                                onChange={apiListChange}
                                defaultValue={execApi}
                            />
                        </div>
                        <div>可执行代码:</div>
                        <TextArea value={codeContent} onChange={nodeTextAreaChange} rows={10} />
                    </div>
                </Drawer>
            </>
        );
    }
}