#
zhou zhou
昨天 f23814fcf6199cfb2d8bbc121fdccab834b374a4
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
<template>
    <view class="has-foot">
        <form>
            <view class="flex padding-sm justify-center">
                <view class="text-orange text-center">请按下列步骤进行 “塑料粒子灌桶入库” </view>
            </view>
            <!-- step1:上新料 -->
            <view class="cu-form-group">
                <view class="title">1.新料(袋装)接驳站点:</view>
                <input placeholder="请扫描接驳站点条码" v-model="bagStaBarcode" ></input>
            </view>
            <view class="cu-bar btn-group top margin-top">
                <button class="cu-btn bg-blue shadow-blur" :disabled="repeatClick" @click="queryBagLocItem">1.呼叫新料(袋装)</button>
            </view>
            <!-- step2:上空桶 -->
            <view class="cu-form-group margin-top">
                <view class="title">2.空桶接驳站点:</view>
                <input placeholder="请扫描接驳站点条码" v-model="palletStaBarcode"></input>                
            </view>                
            <view class="cu-bar btn-group top margin-top">
                <button class="cu-btn text-blue line-blue shadow" :disabled="repeatClick" @click="callEmptyPallet">2.呼叫空桶</button>
            </view>
            <!-- step3:入库 -->
            <view class="cu-form-group margin-top">
                <view class="title">3.待入库物料编码:</view>
                <input placeholder="" v-model="matNr"></input>
                <text class='cuIcon-search text-blue' @click="search"></text>
            </view>
            <view class="flex solid-bottom padding-sm justify-between">                
                <text class="text-grey margin-left">{{ makTx }}</text>                
            </view>
            <view class="cu-form-group">
                <view class="title">&nbsp;&nbsp;&nbsp;待入库桶号:</view>
                <input placeholder="" v-model="palletBarcode"></input>
                <text class='cuIcon-search text-blue' @click="search"></text>
            </view>
            <view class="flex solid-bottom padding-sm justify-between">                
                <view class="text-grey margin-left" >&nbsp;待入库物料数量:1桶</view>
            </view>
            <view class="flex solid-bottom padding-sm justify-between">
                <view class="text-grey margin-left" >&nbsp;待入库库区:2#-1F 桶装新料储位</view>
            </view>
            <view class="cu-bar btn-group top margin-top">
                <button class="cu-btn bg-green shadow-blur" :disabled="repeatClick" @click="fullInStock">3.装桶完成,点击入库</button>
            </view>
        </form>
 
        <!-- 新料库存信息弹窗 -->
        <view class="cu-modal" :class="modalName=='bagModal'?'show':''" @click="closeModal">
            <view class="cu-dialog" @click.stop>
                <view class="cu-bar bg-white justify-between">
                    <view class="title text-bold">新料(袋装)库存信息</view>
                    <view class="content" @click="closeModal">
                        <text class="cuIcon-close text-grey"></text>
                    </view>
                </view>
                <view class="padding-lr" style="max-height: 70vh; overflow-y: auto;">
                    <block v-for="(item, index) in bagList" :key="index">
                        <view class="cu-list menu-avatar margin-bottom-sm">
                            <view class="cu-item flex align-start">
                                <view class="content flex-1 text-left">
                                    <text class="text-grey padding-right-xs">库位:{{item.locId}} </text>
                                    <text class="text-grey padding-right-xs">物料:{{item.makTx}} </text>
                                    <text class="text-grey padding-right-xs">托盘号:{{item.palletId}} </text>
                                    <text class="text-orange">数量:{{item.anfme}} </text>
                                </view>
                                <view class="action">
                                    <button class="cu-btn bg-blue shadow-blur sm" @click.stop="callBagByAGV(item)">上料</button>
                                </view>
                            </view>
                        </view>
                    </block>
                </view>
            </view>
        </view>
 
        <!-- <view class="cu-list det menu sm-border  padding">
            <block v-for="(item, index) in list" :key="index">
                <view class="cu-bar bg-white solid-bottom margin-top-sm">
                    <view class="action">
                        <view class="index">
                            {{index+1}}
                        </view>
                        <view class="text-blue">
                            {{`${item.maktx}`}}
                        </view>
                    </view>
                        <view class="action" >
                        <text @click="remove(index)" class="cuIcon-close text-red" style="font-size: 24px;"></text>
                    </view>
                </view>
 
                <view class="cu-item">
                    <view class="content">
                        <text class="text-black">ASN:</text>
                    </view>
                    <view class="action">
                        <text class="text-grey ">{{item.asnCode}}</text>
                    </view>
                </view>
                <view class="cu-item">
                    <view class="content">
                        <text class="text-black">批次:</text>
                    </view>
                    <view class="action">
                        <text class="text-grey ">{{item.batch}}</text>
                    </view>
                </view>
 
 
                <view class="cu-item">
                    <view class="content">
                        <text class="text-black">收货数量:</text>
                    </view>
                    <view class="action">
                        <text class="text-grey ">{{item.anfme}}</text>
                    </view>
                </view>
 
            </block>
        </view> -->
 
    </view>
</template>
 
<script>
    import {
        request
    } from '../../common/request.js'
    import {
        mapState,
        mapMutations,
        mapActions,
        mapGetters
    } from 'vuex';
    export default {
        data() {
            return {
                // barcode: '',
                areaName: '',
                locCode: '',
                container: '',
                list: [],
                bagList: [],
                range: [],
                curCode: '',
                whAreaId:'',
                repeatClick: false,
                palletBarcode: '',
                palletTypeId: '',
                palletTypeRange: [],
                bagStaBarcode: '',
                modalName: '',
                palletStaBarcode: '',
                matNr: '',
                makTx: '',
                transferStationNo: '',
            }
        },
        computed: {
            ...mapState('user', ['dynamicFields']),
        },
        mounted() {
            this.getRece()
            this.getPalletType()
            this.whAreaId = uni.getStorageSync('whAreaId')
        },
        methods: {    
            selChange(val) {
                uni.setStorageSync('whAreaId', val)
            },
            async search() {
                let that = this
                const {
                    code,
                    data,
                    msg
                } = await request('/staBind/list', {
                    sta: this.barcode
                })
                if (code === 200) {    
                    if(data.list.length >0){
                        that.container = data.barcode                        
                        that.list = data.list
                    }
                    that.range = data.warehouseAreasList.map(item => ({
                        value: item.id,
                        text: item.name
                    }));
                    that.whAreaId = data.area
                } else {
                    uni.showToast({
                        title: msg,
                        icon: "none",
                    })
                }
            },
 
            remove(index) {
                this.list.splice(index, 1);
            },
            clear() {
                this.list = []                
                this.container = ''
                this.barcode = ''
            },
 
            open() {
                this.$refs.popup.open()
            },
 
            close() {
                this.$refs.popup.close()
            },
 
            popupSubmit() {
                this.$refs.popup.close()
            },
            itemChange(el) {
                this.curCode = el
            },
            
            // 选择新料(袋装)库存,送至灌桶站点
            async queryBagLocItem() {
                if(this.bagStaBarcode === '' || this.bagStaBarcode === null){
                    uni.showToast({
                        title: "新料 (袋装) 接驳站点不能为空!!!",
                        icon: "none",
                    })
                    return ;
                }
                this.repeatClick = true
                try{
                    const { code, data, msg } = await request('/inventory/details', {
                        wareHouseAreaId: '2--1-5'    // TODO:固定待后续替换
                    })                    
                    if (code === 200) {
                        if(data && data.length > 0){
                            // 展示查询到的数据
                            this.bagList = data                            
                            // 打开弹窗
                            this.modalName = 'bagModal'
                        } else {
                            uni.showToast({
                                title: '未查到新料(袋装)库存',
                                icon: 'none'
                            })
                        }
                    } else {
                        uni.showToast({
                            title: msg,
                            icon: 'none',
                        })
                    }
                } catch (error) {
                    console.error('请求错误:', error)
                    uni.showToast({
                        title: '查询失败:' + (error.message || '未知错误'),
                        icon: 'none'
                    })
                }finally{
                    this.repeatClick = false
                }
            },
            
            // 关闭弹窗
            closeModal() {
                this.modalName = null
            },
            
            // 为新料(袋装)上料呼叫 AGV
            async callBagByAGV(item) {
                console.log('AGV上料:新料(袋装), 数据:', item)
                if(this.item === '' || this.item === null){
                    uni.showToast({
                        title: "请先选择库位出库",
                        icon: "none",
                    })
                    return ;
                }
                this.repeatClick = true
                try{
                    const { code, data, msg } = await request('/check/non/order', {
                        transferStationNo: this.transferStationNo || this.bagStaBarcode,
                        locNo: item.locId
                    })
                    if (code === 200) {
                        uni.showToast({
                            title: '新料(袋装)上料中',
                            icon: 'success'
                        })
                        // 更新物料编码、物料名称
                        this.matNr = item.matNr || '',
                        this.makTx = '待入库物料名称:' + (item.makTx || '')
                        this.closeModal()
                        // // 从列表中移除该项
                        // const index = this.bagList.findIndex(i => i.palletId === item.palletId)
                        // if (index > -1) {
                        //     this.bagList.splice(index, 1)
                        // }
                        // // 如果列表为空,关闭弹窗
                        // if (this.bagList.length === 0) {
                        //     this.closeModal()
                        // }
                    } else {
                        uni.showToast({
                            title: msg,
                            icon: 'none'
                        })
                    }
                } catch (error) {
                    console.error('AGV 呼叫失败:', error)
                    uni.showToast({
                        title: 'AGV 呼叫失败',
                        icon: 'none'
                    })
                } finally {
                    this.repeatClick = false
                }
            },
                    
            // 呼叫空桶
            async callEmptyPalletFromBag() {
                // 使用袋装接驳站点信息调用空托出库接口
                if(this.palletTypeId === '' || this.palletTypeId === null){
                    uni.showToast({
                        title: "请先选择容器类型",
                        icon: "none",
                    })
                    return ;
                }
                this.repeatClick = true
                try{
                    const { code, data, msg } = await request(
                        '/callForEmptyContainers',
                        {
                            staNo: this.bagBarcode,
                            type: this.palletTypeId
                        }
                    )
                    if (code === 200) {
                        uni.showToast({
                            title: '呼叫空托盘中,请稍作等待'
                        })
                        this.bagBarcode = ''
                    } else {
                        uni.showToast({
                            title: msg,
                            icon: 'none',
                            position: 'top'
                        })
                    }
                }finally{
                    this.repeatClick = false
                }
            },
            
            // 满桶入库            
            async fullInStock() {
                console.log('满桶入库:新料(袋装), 数据:', item)
                if(this.item === '' || this.item === null){
                    uni.showToast({
                        title: "请先选择库位出库",
                        icon: "none",
                    })
                    return ;
                }
                this.repeatClick = true
                try{
                    const { code, data, msg } = await request('/AGV/task/start', {
                        staNo: this.bagBarcode,                        
                        palletBarcode: item.palletId
                    })
                    if (code === 200) {
                        uni.showToast({
                            title: '新料(袋装)上料中',
                            icon: 'success'
                        })
                        // 更新物料编码、物料名称
                        this.matNr = item.matnrCode || ''
                        this.makTx = '&nbsp;待入库物料名称:' + (item.makTx || '')
                                    
                        // 从列表中移除该项
                        const index = this.bagList.findIndex(i => i.palletId === item.palletId)
                        if (index > -1) {
                            this.bagList.splice(index, 1)
                        }
                        // 如果列表为空,关闭弹窗
                        if (this.bagList.length === 0) {
                            this.closeModal()
                        }
                    } else {
                        uni.showToast({
                            title: msg,
                            icon: 'none'
                        })
                    }
                } catch (error) {
                    console.error('AGV 呼叫失败:', error)
                    uni.showToast({
                        title: 'AGV 呼叫失败',
                        icon: 'none'
                    })
                } finally {
                    this.repeatClick = false
                }
            },
            
            async callEmptyPallet() {
                if(this.staBarcode === '' || this.palletBarcode === null){
                    uni.showToast({
                        title: "接驳站点不能为空",
                        icon: "none",
                    })
                    return ;
                }
                if(this.palletTypeId === '' || this.palletTypeId === null){
                    uni.showToast({
                        title: "请选择容器类型",
                        icon: "none",
                    })
                    return ;
                }
                this.repeatClick = true
                try{
                    const { code, data, msg } = await request(
                        '/callForEmptyContainers',
                        {
                            staNo: this.palletBarcode,
                            type: this.palletTypeId
                        }
                    )
                    if (code === 200) {
                        uni.showToast({
                            title: '呼叫空托盘中,请稍作等待'
                        })
                        this.palletBarcode = ''
                    } else {
                        uni.showToast({
                            title: msg,
                            icon: 'none',
                            position: 'top'
                        })
                    }
                }finally{
                    this.repeatClick = false
                }
            },
                    
            async getPalletType() {
                const { code, data, msg } = await request(
                    '/info/palletType/list',
                    {},
                    'get'
                )
                if (code === 200) {
                    this.palletTypeRange = data.map((item) => ({
                        value: item.value,
                        text:
                            item.group === null
                                ? item.label
                                : item.group + '-- ' + item.label
                    }))
                }
            },
                    
            palletTypeChange(val) {
                uni.setStorageSync('palletTypeId', val.value)
            },
 
            async confirm() {                
                if(this.barcode === '' || this.barcode ===null){
                    uni.showToast({
                        title: "接驳站点不能为空",
                        icon: "none",
                    })
                    return ;
                }
                if(this.whAreaId === '' || this.whAreaId ===null){
                    uni.showToast({
                        title: "目标库区不能为空",
                        icon: "none",
                    })
                    return ;
                } 
                this.repeatClick = true
                const {
                    code,
                    data,
                    msg
                } = await request('/AGV/task/start',{                        
                        sta: this.barcode,
                        area: this.whAreaId
                    }
                )
                if (code === 200) {
                    uni.showToast({
                        title: '启动成功'
                    })
                    this.clear()
                } else {
                    uni.showToast({
                        title: msg,
                        icon: "none",
                    })
                }
                this.repeatClick = false
            },
            
            async getRece() {                
                const {
                    code,
                    data,
                    msg
                } = await request('/areas/receipt', {}, 'get')
                if (code === 200) {
                    this.range = data.map(item => ({
                        value: item.id,
                        text: item.warehouseId$ + "-- " + item.name
                    }));
                }
            },
        }
    }
</script>
 
<style>
    .index {
        border: 1px solid #e54d42;
        color: #e54d42;
        border-radius: 50%;
        display: block;
        width: 50rpx;
        height: 50rpx;
        line-height: 48rpx;
        text-align: center;
        margin-right: 20rpx;
        font-size: 30rpx;
    }
 
    .text-blue {
        color: #0081ff !important;
 
    }
 
    .item {
        position: relative;
        display: flex;
        min-height: 80upx;
        align-items: center;
    }
 
    .uni-file-picker {
        width: 100%;
        margin-bottom: 10px;
    }
 
    .uni-select__selector {
        z-index: 999;
    }
 
    .tj {
        height: auto;
        padding: 6px 8px;
        display: inline-block;
        border-radius: 6px;
    }
 
    .item {
        display: flex;
        justify-content: center;
    }
 
    .item .cu-btn {
        font-size: 26upx;
    }
</style>