#
whycq
2024-09-29 d8a5af48e83a64903c63624b994d3aa2b4992e7e
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<template>
    <view>
        <view class="list list-font-color shop-car" :class="orderDetl.color" v-for="(orderDetl,index) in orderCarList" :key="index">
            <view class="list-left">
                <view class="detl-threeCode">{{orderDetl.threeCode}}</view>
                <view>库位号:{{orderDetl.locNo}}</view>
                <view>托盘码:{{orderDetl.barcode}}</view>
                <view>库位状态:{{orderDetl.locSts}}</view>
                <view>满板:{{orderDetl.fullPlt}}</view>
            </view>
            <view class="list-right" @click="chageDetl(orderDetl)">
                <uni-icons type="upload-filled" size="25"  color="#fff" v-if="orderDetl.locSts == 'F'"></uni-icons>
                <uni-icons type="upload-filled" size="25"  color="#fff" v-if="orderDetl.locSts == 'R' || orderDetl.locSts == 'S' || orderDetl.locSts == 'Q'"></uni-icons>
                <uni-icons type="download" size="25"  color="#fff" v-if="orderDetl.locSts == 'P'"></uni-icons>
            </view>
        </view>
        <!-- 垫高 -->
        <view style="height: 120rpx;"></view>
        <!-- 底部操作按钮 -->
        <!-- <view class="buttom">
            <button size="mini" type="primary" @click="agvStart('warn')">确认组托</button>
        </view> -->
        <!-- 弹窗 -->
        <view>
            <uni-popup ref="chageDetl" type="dialog">
                <view class="popup">
                    <!-- 标题 -->
                    <view class="title">入库数量</view>
                    <view class="popup-item">
                        <uni-number-box :value="count" :step='1' :max="9999999" color="#747474" @change="changeValue" />
                    </view>
                    <view class="btn">
                        <view class="btn-left" @click="remove()">移除物料</view>
                        <view class="btn-right" @click="changeCount()">修改数量</view>
                    </view>
                </view>
            </uni-popup>
        </view>
        
        <!-- 弹窗 -->
        <view>
            <uni-popup ref="stapop" type="dialog">
                <view class="popup">
                    <!-- 标题 -->
                    <view class="title">站点选择</view>
                    <view class="popup-item">
                        <uni-combox style="height: 20px;" :candidates="staNos" placeholder="请选择补料出库站点" v-model="staNo"></uni-combox>
                    </view>
                    <view class="btn">
                        <view class="btn-left" @click="mergeOutCancel()">取消</view>
                        <view class="btn-right" @click="mergeOut()">并板出库</view>
                    </view>
                </view>
            </uni-popup>
        </view>
        
        <!-- 弹窗 -->
        <view>
            <uni-popup ref="merge" type="dialog">
                <view class="popup">
                    <!-- 标题 -->
                    <view class="title">站点选择</view>
                    <view class="popup-item">
                        <view class="popup-item-left">数量:</view>
                        <view class="popup-item-right" style="border: none;">
                            <uni-number-box :value="anfme" :step='1' :max="maxAnfme" color="#747474" @change="changeValue2" />
                        </view>
                    </view>
                    <view class="popup-item">
                        <view class="popup-item-left">满板:</view>
                        <view class="popup-item-right" style="border: none;">
                            <radio-group @change="isFullPlt">
                                <label>
                                    <radio :checked="ck1" style="transform: scale(0.7)"/><text>是</text>
                                </label>
                                <label>
                                    <radio :checked="ck2" style="margin-left: 50rpx;transform: scale(0.7);"/><text>否</text>
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    <view class="btn">
                        <view class="btn-left" @click="mergeCancel()">取消</view>
                        <view class="btn-right" @click="mergeConfirm()">确认并板</view>
                    </view>
                </view>
            </uni-popup>
        </view>
        
        <!-- 弹窗 -->
        <view>
            <uni-popup ref="agvStart" type="dialog">
                <view class="popup">
                    <!-- 标题 -->
                    <view class="title">组托</view>
                    <view class="popup-item">
                        <view class="popup-item-left">托盘码:</view>
                        <view class="popup-item-right"><input type="text" focus="true" v-model="barcode"></view>
                    </view>
                    
                    <view class="popup-item">
                        <view class="popup-item-left">满板:</view>
                        <view class="popup-item-right" style="border: none;">
                            <radio-group @change="isFullPlt">
                                <label>
                                    <radio :checked="ck1" style="transform: scale(0.7)"/><text>是</text>
                                </label>
                                <label>
                                    <radio :checked="ck2" style="margin-left: 50rpx;transform: scale(0.7);"/><text>否</text>
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    
                    <view class="btn">
                        <button class="btn-left" @click="agvStartClose()">取消</button>
                        <button class="btn-right" @click="agvStartConfirm()" :disabled="agvStartDis">组托</button>
                    </view>
                </view>
            </uni-popup>
        </view>
    </view>
</template>
 
<script>
    // todo: 购物车优化,存储购物车内容,退出页面再进后购物车还在
    export default {
        data() {
            return {
                orderCarList: [],
                count: 0,
                index: 0,
                barcode: '',
                agvDevp: '',
                agvStartDis: false,
                ck1: false,
                ck2: true,
                fullPlt: 'N',
                locNo: '',
                staNo: '',
                staNos: [100,102,104,200,202,204,300,302,304],
                detls: '',
                anfme: 0,
                maxAnfme: 0
            }
        },
        onShow() {
            let _this = this
            this.baseUrl = uni.getStorageSync('baseUrl');
            this.token = uni.getStorageSync('token');
            // const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
            const eventChannel = this.getOpenerEventChannel();
            // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
            eventChannel.on('locMasts', function(data) {
                _this.orderCarList = data.locMasts
            })
            eventChannel.on('detls', function(data) {
                _this.detls = data.detls
                _this.maxAnfme = data.detls.anfme - data.detls.workQty
            })
        },
        methods: {
            // 是否满板
            isFullPlt() {
                var temp = this.ck1
                this.ck1 = this.ck2
                this.ck2 = temp
                if (this.ck1) {
                    this.fullPlt = '1'
                } else {
                    this.fullPlt = '0'
                }
            },
            chageDetl(locMast) {
                // 库位状态为 F 可出库
                // 库位状态为 R,S,Q  不可操作
                // 库位状态为 P 并板组托操作
                let _this = this
                switch (locMast.locSts) {
                    case 'F':
                        this.locNo = locMast.locNo
                        if (locMast.fullPlt == 'Y') {
                            uni.showToast({ title: '当前库位已标记为满板', icon: 'error',position: 'top' })
                            return
                        }
                        this.$refs.stapop.open('center')
                        break;
                    case 'P':
                        this.locNo = locMast.locNo
                        this.barcode = locMast.barcode
                        this.$refs.merge.open('center')
                        break;
                }
                
                
            },
            mergeOutCancel() {
                this.$refs.stapop.close()
            },
            // 并板出库
            mergeOut() {
                // 选择出库站,提交出库库位号
                let _this = this
                uni.request({
                    url: _this.baseUrl + '/mobile/merge/out/auth',
                    data: {locNo: _this.locNo,
                        staNo: _this.staNo,},
                    method: 'GET',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        var res = result.data
                        _this.agvStartDis = false
                        if (res.code === 200) {
                            _this.$refs.stapop.close()
                            uni.showToast({ title: '出库成功', icon: "error", position: 'top' })
                            setTimeout(()=> {
                                _this.getOpenerEventChannel().emit('acceptDataFromOpenedPage', {data: 1});
                                uni.navigateBack({
                                    delta:2
                                })
                            },1000)
                        } else if (res.code == 403) {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                            setTimeout(() => { uni.reLaunch({ url: '../../login/login' }); }, 1000);
                        } else {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                        }
                    },
                    fail(res) {
                        _this.agvStartDis = false
                    }
                });
            },
            mergeCancel() {
                this.$refs.merge.close()
            },
            // 并板组托
            mergeConfirm() {
                let _this = this
                let combMats = []
                _this.detls['locNo'] = _this.locNo
                _this.detls.anfme = _this.anfme
                combMats.push(_this.detls)
                uni.request({
                    url: _this.baseUrl + '/mobile/merge/comb2/auth',
                    data: JSON.stringify({
                        barcode: _this.barcode,
                        isFull: _this.fullPlt,
                        combMats: combMats
                    }),
                    method: 'POST',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        var res = result.data
                        _this.agvStartDis = false
                        if (res.code === 200) {
                            _this.$refs.merge.close()
                            uni.showToast({ title: res.msg, icon: "success", position: 'top' })
                            setTimeout(()=> {
                                _this.getOpenerEventChannel().emit('acceptDataFromOpenedPage', {data: 1});
                                uni.navigateBack({
                                    delta:2
                                })
                            },1000)
                        } else if (res.code == 403) {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                            setTimeout(() => { uni.reLaunch({ url: '../../login/login' }); }, 1000);
                        } else {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                        }
                    },
                    fail(res) {
                        _this.agvStartDis = false
                    }
                });
            },
            // 修改数量
            changeCount() {
                if (this.count > this.orderCarList[this.index].anfme) {
                    uni.showToast({ title: '数量不合法!', icon: "none", position: 'top' })
                    return
                }
                this.orderCarList[this.index].pakinQty = this.count
                this.$forceUpdate() // 强制刷新
                this.$refs.chageDetl.close()
            },
            // 移除物料
            remove() {
                this.orderCarList.splice(this.index, 1)
                this.$refs.chageDetl.close()
            },
            changeValue(value) {
                this.count = value
            },
            changeValue2(value) {
                this.anfme = value
            },
            agvStart() {
                this.$refs.agvStart.open()
            },
            agvStartClose() {
                this.barcode = ''
                this.agvDevp = ''
                this.$refs.agvStart.close()
            },
            agvStartConfirm() {
                this.barcode = this.barcode.replace(/\s+/g, '')
                let _this = this
                if (_this.barcode === '') {
                    uni.showToast({ title: '托盘码为空!', icon: "error", position: 'top' })
                    return;
                }
                if (_this.orderCarList.length === 0) {
                    uni.showToast({ title: '组托列表为空!', icon: "error", position: 'top' })
                    return;
                }
                for (let k of _this.orderCarList) {
                    if (k.pakinQty == 0) {
                        uni.showToast({ title: `${k.matnr}数量不能为 0 !`, icon: "error", position: 'top' })
                        return;
                    } 
                }
                let combMat = { orderNo:'', barcode: '', locNo: '', combMats: [] }
                let combMats = []
                // for (let item of _this.orderCarList) {
                //     combMat.orderNo = item.orderNo
                //     combMat.barcode = _this.barcode
                //     combMat.locNo = _this.agvDevp
                //     combMat.combMats = []
                //     let combM = {csocode: item.threeCode,isoseq: item.deadTime,matnr: item.matnr,batch: item.batch,anfme: item.pakinQty,maktx: item.maktx,specs: item.specs,processSts: item.processSts}
                //     combMat.combMats.push(combM)
                //     combMats.push({...combMat})
                // }
                for    (let detl of _this.orderCarList) {
                    detl.anfme = detl.pakinQty
                    combMats.push(detl)
                }
                this.comb(combMats)
                
            },
            comb(combMats) {
                let _this = this;
                this.agvStartDis = true
                uni.request({
                    url: _this.baseUrl + '/mobile/comb/auth3',
                    data: JSON.stringify({
                        barcode: _this.barcode,
                        isFull: _this.fullPlt,
                        combMats: combMats
                    }),
                    method: 'POST',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        var res = result.data
                        _this.agvStartDis = false
                        if (res.code === 200) {
                            _this.orderCarList = []
                            _this.$refs.agvStart.close()
                            uni.showToast({ title: '启动成功!', icon: "success", position: 'top' })
                            setTimeout(()=> {
                                _this.getOpenerEventChannel().emit('acceptDataFromOpenedPage', {data: 1});
                                uni.navigateBack({})
                            },1000)
                        } else if (res.code == 403) {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                            setTimeout(() => { uni.reLaunch({ url: '../../login/login' }); }, 1000);
                        } else {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                        }
                    },
                    fail(res) {
                        _this.agvStartDis = false
                    }
                });
            },
        }
    }
</script>
 
<style>
    @import url('../../static/css/order.css');
    .shop-car {
        background-color: #2299ff;
        color: #fff;
    }
    .detl-threeCode {
        font-size: 28px;
        font-weight: bold;
    }
    .popup {
        width: 80vw;
        min-height: 100rpx;
        background-color: #FFF;
        border-radius: 25rpx;
        position: relative;
    }
    .title {
        height: 100rpx;
        line-height: 100rpx;
        width: 100%;
        color: #606266;
        text-align: center;
        font-size: 16px;
    }
    .popup-item {
        height: 80rpx;
        line-height: 80rpx;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .popup-item-left {
        width: 20vw;
        padding-right: 20rpx;
        text-align: right;
        color: #606266;
    }
    .popup-item-right {
        display: flex;
        align-items: center;
        width: 50vw;
        height: 50rpx;
        padding: 2px 5px;
        border: 1px solid #E4E7ED;
        border-radius: 5rpx;
    }
    .popup-item-right input{
        color: #606266;
    }
    .btn {
        display: flex;
        height: 90rpx;
        margin-top: 20rpx;
        border-top: 1px solid #DCDFE6;
        justify-content: center;
        align-items: center;
    }
    .btn-left {
        display: flex;
        flex: 1;
        height: 100%;
        justify-content: center;
        align-items: center;
        color: #e2231a;
        border-right: 1px solid #DCDFE6;
    }
    .btn-right {
        display: flex;
        flex: 1;
        height: 100%;
        justify-content: center;
        align-items: center;
        color: #409EFF;
    }
</style>