#
zhou zhou
9 天以前 b13760a228deb5957f1c029689c2a28676bce94f
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
<template>
    <view class="page-container">
        <!-- 表单区域 -->
        <view class="form-section">
            <view class="form-item">
                <view class="form-label">
                    <uni-icons type="scan" size="18" color="#667eea"></uni-icons>
                    <text class="label-text">托盘码</text>
                </view>
                <view class="form-input-wrap">
                    <input class="form-input" type="text" placeholder="扫码 / 输入托盘码" v-model="barcode" 
                        :focus="barcodeFocus" @input="barcodeInput()" />
                    <uni-icons v-if="barcode" type="clear" size="18" color="#c0c4cc" @click="clearBarcode"></uni-icons>
                </view>
            </view>
            <view class="form-item">
                <view class="form-label">
                    <uni-icons type="location" size="18" color="#667eea"></uni-icons>
                    <text class="label-text">暂存位</text>
                </view>
                <view class="form-input-wrap">
                    <input class="form-input" type="text" placeholder="扫码 / 输入暂存位" v-model="sourceSite" />
                    <uni-icons v-if="sourceSite" type="clear" size="18" color="#c0c4cc" @click="sourceSite=''"></uni-icons>
                </view>
            </view>
            <!-- <view class="form-item">
                <view class="form-label">
                    <uni-icons type="navigate" size="18" color="#667eea"></uni-icons>
                    <text class="label-text">目标站点</text>
                </view>
                <view class="form-input-wrap">
                    <picker class="picker-full" :range="targetSiteList" range-key="label" @change="onTargetSiteChange">
                        <view class="picker-value">
                            <text>{{selectedTargetSite.label || '请选择目标站点'}}</text>
                            <view><uni-icons type="bottom" size="14" color="#909399"></uni-icons></view>                            
                        </view>
                    </picker>
                </view>
            </view> -->
        </view>
        
        <!-- 列表头部 -->
        <view class="list-header" v-if="showDetl">
            <view class="header-left">
                <text class="header-title">商品列表</text>
                <view class="count-badge" v-if="dataList.length > 0">
                    <text class="count-text">{{dataList.length}}</text>
                </view>
            </view>
        </view>
        
        <!-- 商品列表 -->
        <view class="list-container" v-if="showDetl">
            <view class="mat-card" v-for="(item, i) in dataList" :key="i">
                <!-- 卡片头部 -->
                <view class="card-top">
                    <view class="card-index">{{i + 1}}</view>
                    <view class="mat-code-wrap">
                        <text class="mat-code">{{item.matnr}}</text>
                    </view>
                    <!-- <view class="qty-badge">
                        <text class="qty-text">{{item.anfme}}</text>
                    </view> -->
                </view>
                
                <!-- 卡片内容 -->
                <view class="card-content">
                    <view class="info-row">
                        <view class="info-col">
                            <text class="info-label">品名</text>
                            <text class="info-value">{{item.maktx || '-'}}</text>
                        </view>
                    </view>
                    <view class="info-row">
                        <view class="info-col half">
                            <text class="info-label">规格</text>
                            <text class="info-value">{{item.specs || '-'}}</text>
                        </view>
                        <view class="info-col half">
                            <text class="info-label">批号</text>
                            <text class="info-value highlight">{{item.batch || '-'}}</text>
                        </view>
                    </view>
                    <view class="info-row">
                        <view class="info-col half">
                            <text class="info-label">数量</text>
                            <text class="info-value qty">{{item.anfme}}</text>
                        </view>
                    </view>
                </view>
                
                <!-- 卡片操作 -->
                <view class="card-actions">
                    <view class="action-btn edit-btn" @click="revise(item, i)">
                        <uni-icons type="compose" size="18" color="#667eea"></uni-icons>
                        <text class="action-text">修改</text>
                    </view>
                    <view class="action-btn delete-btn" @click="remove(item, i, 'warn')">
                        <uni-icons type="trash" size="18" color="#f56c6c"></uni-icons>
                        <text class="action-text delete-text">移除</text>
                    </view>
                </view>
            </view>
            
            <!-- 空状态 -->
            <view class="empty-state" v-if="dataList.length === 0">
                <uni-icons type="cart" size="60" color="#CCCCCC"></uni-icons>
                <text class="empty-text">暂无商品</text>
                <text class="empty-hint">请扫描物料码添加商品</text>
            </view>
            
            <!-- 底部占位 -->
            <view class="bottom-placeholder"></view>
        </view>
        
        <!-- 底部操作按钮 -->
        <view class="bottom-bar">
            <view class="btn-reset" @click="reset('warn')">
                <uni-icons type="refresh" size="18" color="#909399"></uni-icons>
                <text class="btn-text">重置</text>
            </view>
            <view class="btn-submit" :class="{'btn-disabled': isSubmitting || barcode === ''}" @click="combConfirm('warn')">
                <uni-icons type="checkbox" size="18" color="#ffffff"></uni-icons>
                <text class="btn-text">确认呼叫</text>
            </view>
        </view>
        
        <!-- 弹窗区域 -->
        <!-- 修改数量 -->
        <uni-popup ref="revise" type="dialog">
            <view class="popup-card">
                <view class="popup-header">
                    <text class="popup-title">修改信息</text>
                </view>
                <view class="popup-body">
                    <view class="popup-row">
                        <text class="popup-label">编码</text>
                        <view class="popup-value disabled">{{editMatnr}}</view>
                    </view>
                    <view class="popup-row">
                        <text class="popup-label">批号</text>
                        <input class="popup-value input" type="text" v-model="batch" placeholder="输入批号" />
                    </view>
                    <view class="popup-row">
                        <text class="popup-label">数量</text>
                        <view class="popup-value number">
                            <uni-number-box :value="count" :step='0.01' :max="9999999" color="#747474" @change="changeValue" />
                        </view>
                    </view>
                </view>
                <view class="popup-footer">
                    <view class="popup-btn cancel" @click="reviseClose">取消</view>
                    <view class="popup-btn confirm" @click="reviseConfirm()">确认</view>
                </view>
            </view>
        </uni-popup>
        
        <!-- 移除确认 -->
        <uni-popup ref="alertDialog" type="dialog">
            <uni-popup-dialog :type="msgType" confirmText="移除" :title="title" :content="content"
                @confirm="removeConfirm()" @close="removeClose"></uni-popup-dialog>
        </uni-popup>
        
        <!-- 提示信息弹窗 -->
        <uni-popup ref="message" type="message">
            <uni-popup-message :type="msgType1" :message="messageText" :duration="2000"></uni-popup-message>
        </uni-popup>
        
        <!-- 确认组托 -->
        <uni-popup ref="combConfirm" type="dialog">
            <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
                @confirm="comb" @close="combClose"></uni-popup-dialog>
        </uni-popup>
        
        <!-- 确认重置 -->
        <uni-popup ref="resetConfirm" type="dialog">
            <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
                @confirm="resetConfirm" @close="resetClose"></uni-popup-dialog>
        </uni-popup>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                showDetl:false,
                baseUrl: '',
                token: '',
                barcode: '',
                dataList: [],
                count: 0,
                rowNum: '',
                matnr: '',
                editMatnr: '',
                batch: '',
                weight: '',
                msgType1: 'success',
                msgType: 'success',
                messageText: '',
                title: '',
                content: '',
                barcodeFocus: true,
                matFocus: false,
                matData: '',
                removeNum: 0,
                ck1: true,
                ck2: false,
                isFull: true,
                isSubmitting: false,
                sourceSite:'',
                targetSiteList: [
                    { label: '101', value: '101' },
                    { label: '102', value: '102' }
                ],
                selectedTargetSite: { label: '101', value: '101' },
                type : 1
            }
        },
        onLoad() {
 
        },
        onShow() {
            this.baseUrl = uni.getStorageSync('baseUrl');
            this.token = uni.getStorageSync('token');
        },
        methods: {
            onTargetSiteChange(e) {
                const index = e.detail.value;
                this.selectedTargetSite = this.targetSiteList[index];
            },
            clearBarcode() {
                this.barcode = '';
                this.barcodeFocus = false;
                setTimeout(() => {
                    this.barcodeFocus = true;
                }, 100);
            },
            clearMatnr() {
                this.matnr = '';
                this.matFocus = false;
                setTimeout(() => {
                    this.matFocus = true;
                }, 100);
            },
            isFrozen() {
                this.isFull = !this.isFull
                console.log(this.isFull);
            },
            messageToggle(type) {
                this.msgType1 = type
                this.$refs.message.open()
            },
            // barcode input 事件
            barcodeInput() {
                // 不设置定时器 会出现扫入的字符串不全
                setTimeout(() => {
                    var len = this.barcode.length
                    if (len >= 9 && len <=8) {
                        uni.showToast({
                            title: '托盘码有误请重试',
                            icon: "none",
                            position: 'top'
                        });
                        this.barcodeFocuss()
                        return;
                    }
                    this.focuss()
                }, 200)
            },
            // 托盘码有误重置
            barcodeFocuss() {
                let that = this;
                that.barcodeFocus = false;
                setTimeout(() => {
                    that.barcode = '';
                    that.barcodeFocus = true;
                }, 100);
            },
            // 商品光标清空重置
            focuss() {
                this.focus = false;
                setTimeout(() => {
                    this.matnr = '';
                    this.matFocus = true;
                }, 100);
            },
            // 搜索物料
            findMat() {
                let that = this
                
                uni.request({
                    url: that.baseUrl + '/mat/auth',
                    data: {
                        matnr: that.matnr
                    },
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        result = result.data
                        if (result.code === 200 && result.data) {
                            that.matData = result.data
                            that.matnr = ''
                            that.matData['batch'] = ''
                            uni.navigateTo({
                                url: "../mat/matSelected",
                                // 通过eventChannel向被打开页面传送数据
                                success: function(res) {
                                    res.eventChannel.emit('mat', {
                                        data: result.data
                                    })
                                },
                                // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                                events: {
                                    matList: function(data) {
                                        that.checkMat(data.data)
                                        that.focuss()
                                    },
                                },
                            });
                        } else if (result.code == 403) {
                            uni.showToast({
                                title: result.msg,
                                icon: "none",
                                position: 'top'
                            })
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../login/login'
                                });
                            }, 1000);
                        } else {
                            uni.showToast({
                                title: result.msg,
                                icon: "none",
                                position: 'top'
                            })
                        }
 
                    }
                });
 
            },
            selectMat() {
                let that = this
                uni.navigateTo({
                    url: "../mat/matQuery",
                    success: function(res) {
                        // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                        res.eventChannel.emit('commonUrl', {
                            commonUrl: ''
                        })
                    },
                    events: {
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据  另外一个页面传过来的
                        acceptDataFromOpenedPage: function(data) {
                            that.matnr = data.data
                            that.findMat(that.matnr)
                        },
                    },
 
 
                });
                that.matnr = ''
            },
            checkMat(mat) {
                var len = this.dataList.length
                var add = true ,sameItem = false
                for (var i = 0; i < len; i++) {
                    if (mat.matnr == this.dataList[i].matnr) {
                        for (var j = 0; j < len; j++) {
                            if (mat.batch == this.dataList[j].batch) {
                                sameItem = true
                            }
                        }
                        // 相同物料 不同批号  新加列表
                        if (mat.batch != this.dataList[i].batch) {
                            this.$forceUpdate() // 强制刷新
                            if (sameItem) {
                                add = false
                            } else {
                                add = true
                            }
                            
                        } else {
                            // 相同物料相同批号 数量累加
                            this.dataList[i].anfme += mat.anfme
                            this.$forceUpdate() // 强制刷新
                            add = false
                        }
                    }
                }
                if (add) {
                    this.dataList.unshift(mat)
                }
            },
            // 修改批号
            revise(item, i) {
                this.editMatnr = this.dataList[i].matnr
                this.count = this.dataList[i].anfme
                this.batch = this.dataList[i].batch
                this.weight = this.dataList[i].weight
                this.rowNum = i
                this.eject()
            },
            eject(type) {
                this.type = type
                this.$refs.revise.open(type)
            },
            // 列表移除按钮
            remove(item, i, type) {
                this.removeNum  = i
                this.msgType = type
                this.title = '确认移除'
                this.content = '是否移除该商品?'
                this.$refs.alertDialog.open(i)
            },
            // 确认移除
            removeConfirm() {
                this.messageText = "移除成功"
                this.messageToggle('success')
                this.dataList.splice(this.removeNum, 1)
            },
            // 取消移除
            removeClose() {
                this.$refs.alertDialog.close()
            },
            reviseConfirm() {
                this.dataList[this.rowNum].anfme = this.count
                this.dataList[this.rowNum].batch = this.batch
                this.dataList[this.rowNum].weight = this.weight
                this.editMatnr = ''
                this.messageText = "修改成功"
                this.messageToggle('success')
                this.$refs.revise.close()
            },
            reviseClose() {
                this.$refs.revise.close()
            },
            changeValue(value) {
                this.count = value
            },
            combConfirm(type) {
                if (this.isSubmitting || this.barcode === '' || this.sourceSite === '') return;
                this.msgType = type
                this.title = '确认呼叫'
                this.content = '确认呼叫?'
                this.$refs.combConfirm.open()
            },
            combClose() {
                this.$refs.combConfirm.close()
            },
            comb() {
                uni.vibrateShort();
                let that = this;
                that.isSubmitting = true;                
                uni.request({
                    url: that.baseUrl + '/mobile/agv/start',
                    data: JSON.stringify({
                        type : that.type,
                        barcode: that.barcode,
                        sourceSite:that.sourceSite
                    }),
                    method: 'POST',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        var res = result.data
                        if (res.code === 200) {
                            that.resst();
                            that.messageText = "呼叫成功"
                            that.messageToggle('success')
                        } else if (res.code == 403) {
                            that.messageText = res.msg
                            that.messageToggle('error')
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../login/login'
                                });
                            }, 1000);
                        } else {
                            that.messageText = res.msg
                            that.messageToggle('error')
                        }
                    },
                    fail: () => {
                        that.messageText = "网络请求超时"
                        that.messageToggle('error')
                    },
                    complete: () => {
                        that.isSubmitting = false;
                    }
                });
            },
            reset(type) {
                this.msgType = type
                this.title = '确认重置'
                this.content = '是否清空所有数据?'
                this.$refs.resetConfirm.open()
            },
            // 确认重置
            resetConfirm() {
                this.dataList = []
                this.barcode = ''
                this.messageText = "重置完成"
                this.messageToggle('success')
            },
            // 取消重置
            resetClose() {
 
            },
            // 清空
            resst() {
                // this.dataList = []
                this.barcode = ''
                this.sourceSite = ''
                this.barcodeFocuss()
            },
        }
    }
</script>
 
<style>
    /* 引入公共样式 */
    @import url('../../static/css/common.css');
    /* @import url('../../static/css/wms.css/wms.css'); */
</style>