#
whycq
2024-03-14 1a3d4450cfcde83cb430d955f48fdf1775b539ca
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<template>
    <view class="container">
        <!-- 左 -->
        <view class="zcard">
            <view class="zcard-flex">
                <view class="button-nk" v-for="item in groundSiteList" @click="click(item,'left')">{{item.name}}</view>
            </view>
        </view>
        <!-- 右 -->
        <view class="zcard">
            <view class="zcard-flex">
                <view class="button-nk" style="background-color: brown;" v-for="item in traySiteList" @click="click(item,'right')">{{item.name}}</view>
            </view>
        </view>
        
        <view>
            <uni-popup ref="revise" type="dialog">
                <view class="popup">
                    <view>{{text}}</view>
                    <view class="button-nk" @click="upTray()">{{btnTitle1}}</view>
                    <view class="button-nk" @click="downTray()">{{btnTitle2}}</view>
                    <view v-show="outType" class="button-nk" @click="downTray1()">{{btnTitle3}}</view>
                </view>
            </uni-popup>
        </view>
        
        <view>
            <uni-popup ref="numberPopup" type="dialog">
                <view class="popup2">
                    <view>上架数量</view>
                    <view class="button-nk" @click="goUp(2)">2个</view>
                    <view class="button-nk" @click="goUp(4)">4个</view>
                </view>
            </uni-popup>
        </view>
        
        <view>
            <uni-popup ref="numberPopup" type="dialog">
                <view class="popup2">
                    <view>上架数量</view>
                    <view class="button-nk" @click="goUp(2)">2个</view>
                    <view class="button-nk" @click="goUp(4)">4个</view>
                </view>
            </uni-popup>
        </view>
        
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                baseUrl: '',
                token: '',
                groundSiteList: [
                    {name: '1号地面站',code:'1-C1',traget: '1-A1',type: 'foolr'},
                    {name: '2号地面站',code:'2-C1',traget: '2-A1',type: 'foolr'},
                    {name: '3号地面站',code:'3-C1',traget: '3-A1',type: 'foolr'},
                    {name: '4号地面站',code:'4-C1',traget: '4-A1',type: 'foolr'},
                    {name: '5号地面站',code:'5-C1',traget: '5-A1',type: 'foolr'},
                    {name: '6号地面站',code:'6-C1',traget: '6-A1',type: 'foolr'},
                    {name: '7号地面站',code:'7-C1',traget: '7-A1',type: 'foolr'},
                    {name: '8号地面站',code:'8-C1',traget: '8-A1',type: 'foolr'},
                    {name: '9号地面站',code:'9-C1',traget: '9-A1',type: 'foolr'},
                    {name: '10号地面站',code:'10-C1',traget: '10-A1',type: 'foolr'}
                ],
                traySiteList: [
                    {name: '1号托盘站',code:'KW-1',type: 'tray'},
                    {name: '2号托盘站',code:'KW-2',type: 'tray'},
                    {name: '3号托盘站',code:'KW-3',type: 'tray'},
                    {name: '4号托盘站',code:'KW-4',type: 'tray'},
                    {name: '5号托盘站',code:'KW-5',type: 'tray'},
                    {name: '6号托盘站',code:'KW-6',type: 'tray'},
                    {name: '7号托盘站',code:'KW-7',type: 'tray'},
                    {name: '8号托盘站',code:'KW-8',type: 'tray'},
                    {name: '9号托盘站',code:'KW-9',type: 'tray'},
                    {name: '10号托盘站',code:'KW-10',type: 'tray'}
                ],
                item: '',
                text: '',
                btnTitle1: '',
                btnTitle2: '',
                btnTitle3: '',
                outType: '',
                stationType: 'load',
                type: '' ,
                originLocal: '',
                targetLocal: '',
            }
        },
        onShow() {
            let network = uni.getStorageSync('Network')
            this.baseUrl = `http://${network[0].ip}:${network[0].port}/${network[0].address}` 
            this.token = uni.getStorageSync('token');
        },
        methods: {
            click(item,type) {
                this.item = item
                this.text = item.name
                if (type == 'left') {
                    this.outType = false
                    this.btnTitle1 = '地面站放置托盘(上架)'
                    this.btnTitle2 = '托盘站取置地面(下架)'
                } else {
                    this.outType = true
                    this.btnTitle1 = '托盘-仓库(入库)'
                    this.btnTitle2 = '仓库-空托盘(出库)'
                    this.btnTitle3 = '仓库-满托盘(出库)'
                }
                this.$refs.revise.open(type)
            },
            // 地面站上架 / 托盘站入库按钮
            upTray() {
                if (this.item.type == 'foolr') {
                    this.type = 'load', // 上架
                    this.originLocal = this.item.code,
                    this.targetLocal = this.item.traget
                    this.numberPopup()
                } else {
                    this.type = 'in' // 入库
                    this.originLocal = this.item.code,
                    this.targetLocal = 'KW-J'
                    this.pakin()
                }
            },
            downTray() {
                if (this.item.type == 'foolr') {
                    this.type = 'unload', // 下架
                    this.originLocal = this.item.traget,
                    this.targetLocal = this.item.code
                    this.numberPopup()
                } else {
                    this.type = 'out1' // 出库
                    this.originLocal = 'KW-C'
                    this.targetLocal = this.item.code
                }
            },
            downTray1() {
                let _this = this
                let type = '',originLocal = '',targetLocal = '';
                if (this.item.type == 'foolr') {
                    type = 'unload', // 下架
                    originLocal = this.item.traget,
                    targetLocal = this.item.code
                } else {
                    type = 'out2' // 出库
                    originLocal = 'KW-C'
                    targetLocal = this.item.code
                }
                // this.text = originLocal + targetLocal
                uni.request({
                    url: `${_this.baseUrl}/agv/requestTask`,
                    data: {
                        originLocal: originLocal,
                        targetLocal: targetLocal,
                        type: type
                    },
                    header: { 'token': uni.getStorageSync('token') },
                    method: 'POST',
                    success(res) {
                        res = res.data
                        if (res.code === 200) {
                            this.$refs.revise.close()
                            uni.showToast({ title: '操作成功', icon: "none", position: 'top' })
                        } else {
                            uni.showToast({ title: res.msg, icon: "none", position: 'top' })
                        }
                    }
                })
            },
            numberPopup() {
                this.$refs.numberPopup.open('center')
            },
            // 上 / 下 架数量
            goUp(num) {
                let data = {}
                data = {
                    originLocal: this.originLocal,
                    targetLocal: this.targetLocal,
                    type: this.type,
                    anfme: num,
                }
                this.webServer(data)
                setTimeout(()=>{
                    this.$refs.numberPopup.close()
                },300)
            },
            pakin() {
                let data = {}
                data = {
                    originLocal: this.originLocal,
                    targetLocal: this.targetLocal,
                    type: this.type,
                }
                this.webServer(data)
            },
            // 所有服务
            webServer(data) {
                let _this = this
                uni.request({
                    url: `${_this.baseUrl}/agv/requestTask`,
                    data: data,
                    header: { 'token': uni.getStorageSync('token') },
                    method: 'POST',
                    success(res) {
                        res = res.data
                        if (res.code === 200) {
                            this.$refs.revise.close()
                            uni.showToast({ title: '操作成功', icon: "none", position: 'top' })
                        } else {
                            uni.showToast({ title: res.msg, icon: "none", position: 'top' })
                        }
                        
                    }
                })
            }
        }
    }
</script>
 
<style>
    .container {
        height: 100%;
        /* background-color: aqua; */
        display: grid;
        grid-template-columns: 50% 50%;
 
    }
    .btn-box {
        /* margin: 1%; */
        background-color: azure;
    }
    /* .zcard {
        margin: 10px 100px;
        background-color: #409EFF;
    } */
    .zcard-flex {
        /* background-color: coral; */
        margin-top: 20rpx;
        width: 100%;
        height: 100%;
        display: flex;
        flex-wrap: wrap;
        /* flex-direction: column; */
        justify-content: space-around;
        align-items: center;
    }
    .button-nk {
        margin: 10rpx 0rpx;
        /* padding: 20rpx 70rpx; */
        /* background-color: azure; */
        min-width: 150rpx;
        /* margin: 0 auto; */
        height: 50rpx;
        text-align: center;
        line-height: 50rpx;
        font-size: 20rpx;
        background-color: #409EFF;
        color: #ECF0F1;
        border-radius: 7px;
        box-shadow: inset 4px 4px 4px rgba(0, 0, 0, .3),
            inset -4px -4px 4px rgba(255, 255, 255, .4),
            -4px -4px 5px rgba(0, 0, 0, .4);
    }
    .button-nk:active {
        transform: translateY(2px) scale(0.99, 0.99);
        box-shadow: inset 4px 4px 4px rgba(0, 0, 0, .3),
            inset -4px -4px 8px rgba(255, 255, 255, .7),
            -5px -5px 5px rgba(0, 0, 0, .3);
    }
    .popup {
        background-color: #eee;
        width: 30vw;
        height: 100%;
        padding: 0 10vw;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
    }
    .popup2 {
        background-color: #eee;
        width: 30vw;
        height: 100%;
        padding: 0 10vw;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
    }
</style>