schangxiang@126.com
2024-12-20 01c3a4658026e9c3ed9daaf1f1b27da368ab11a9
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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
 
<template>
    <view class="overflow"  style="padding-bottom:100px">
        <!-- 顶部 -->
        <cu-custom bgColor="bg-white" :isBack="true">
            <block slot="backText"></block>
            <block slot="content">
                <text v-if="totalPages"> ({{pageNow}}页/共{{totalPages}}页/{{totalTs}}条) </text>    
                越库
            </block>
        </cu-custom>
        <!-- 操作人 -->
        <view class="flex justify-end align-center padding_right30rpx padding_top12rpx">
            <text class="fontSize12rpx" v-if="pramWl"> {{pramWl}} </text>
        </view>
        <!-- 遮挡层 -->
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
        <!-- 越库 -->
        <view class="" v-if="renameFocus">
            <u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
                <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                    <u-col span="10">
                        <u-form-item label="物料编号:"  style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                            <u-input v-model.trim="warehouse.WareMaterialCode" placeholder="请录入或扫码"
                            class="width padding_left25rpx"
                            @confirm="materialBlur(1,2)" >
                            </u-input>
                        </u-form-item>
                    </u-col>
                    <!-- <u-col span="2">
                        <u-icon class="iconfont icon-saoma fontSize60rpx" ></u-icon> 
                    </u-col> -->
                </u-row>
                
            </u-form>
            <view style="margin-bottom: 180rpx;" v-show="singlist.length > 0">
                <view v-for="(item, eindex) in singlist" :key="eindex" class="title-wrap">
                    <u-swipe-action :show="item.show" :index="eindex" @click="longpredel" @open="open" @close='close' :options="options">
                        <view class=" fontSize32rpx background_fff" :class="parseFloat(item.uncollectedQuantity) > 0 ? 'bg_item' : '' " style="width: 100vw;">
                            <u-row>
                                <u-col span="12" class="flex" style="align-items: flex-start;">
                                    <view style="background-color: #f18202;color: #fff;border-radius: 50%;width: 20px;height: 20px;line-height: 20px;text-align: center;">
                                        {{eindex+1}}
                                    </view>
                                    <view class="color_f18202 padding_left10rpx" style="flex: 1;word-break: break-all;">
                                        {{item.wareMaterialCode}} 
                                        <!-- -- 是否检验:  <text style="color: #000;font-weight: bold;">{{item.isCheck ? '是' : '否'}}</text> -->
                                    </view>
                                    <view>
                                        <text @click.prevent.stop="showDetail(item,eindex)" class="detail_btn">查看越库</text>
                                    </view>
                                </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="6">
                                    <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                        是否可越库:{{item.isYueku}}
                                    </view>
                                </u-col>
                                <u-col span="6">
                                    <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                        数量:{{item.quantity}}
                                    </view>
                                    </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="10">
                                    <view class="flex" style="padding: 5px 0 0px 10px;color: #808080;">
                                        <span style="width: 55px">批次:</span>    
                                        <input
                                            class="width text-left boxIput"
                                            v-model="item.barNo"    :class="!item.isBatchMge?'':'border_bottom_f18202'"  :disabled="!item.isBatchMge" type="text" placeholder="请输入批次" />    
                                    </view>
                                </u-col>
                            </u-row>
                        </view>
                    </u-swipe-action>
 
                    <view class="background_fff qhd_wp"  v-show="item.childen" v-for="(itemIn, eindexIn) in item.SortingOrderDetailsList" :key="eindexIn">
                        <u-row>
                            <u-col span="12">
                                <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                    取货波次号:{{ itemIn.orderNo }}
                                </view>
                                <view class="detailBtn" @click.stop="showdetailProp(item,itemIn)">打印详情</view>
                            </u-col>
                        <!--     <u-col span="12">
                                <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                    单号:{{ itemIn.deliveryNo }}
                                </view>
                            </u-col> -->
                        </u-row>
                        <u-row>
                            <u-col span="6">
                                <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                    单号:{{ itemIn.deliveryNo }}
                                </view>
                            </u-col>
                            <u-col span="6">
                                <view class="text-right" style="padding: 5px 0 0px 10px;color: #808080;">
                                    批次号:{{ itemIn.batchNo }}
                                </view>
                            </u-col>
                        </u-row>
                        <u-row>
                            <u-col span="6">
                                <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                    工序:{{ itemIn.process }}
                                </view>
                            </u-col>
                            <u-col span="6">
                                <view class="text-right" style="padding: 5px 0 0px 10px;color: #808080;">
                                    机床号:{{ itemIn.equipment }}
                                </view>
                            </u-col>
                        </u-row>
                        <u-row>
                            <u-col span="6">
                                <view class="" style="padding: 5px 0 0px 10px;color: #808080;">
                                    缺料数量:{{ itemIn.quantity }}
                                </view>
                            </u-col>    
                            <u-col span="6">
                                <input
                                    class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx"
                                    v-model.trim="itemIn.uncollectedQuantity" type="number"
                                    @blur="changeNumIn(itemIn,item)"  placeholder="请输入越库数量" />
                            </u-col>
                        </u-row>
                    </view>
                </view>
 
                <view v-if="singlist.length <= 0" style="text-align: center">---无数据---</view>
 
            </view>
            <u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom">
                <!-- <view class="pop "> -->
                <h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
                <!-- <view class="line flex justify-between">
                    <text class="text-gray">打印张数</text>
                    <text>
                        <u-input v-model.trim="contLabel"   placeholder="请输入打印张数"
                                 class="width"
                                 @focus="contLabel=''"
                                style="font-size: 36rpx;text-align: right;">
                            </u-input>
                    </text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">打印越库数量</text>
                    <text>
                        <u-input v-model.trim="ermNum"   placeholder="请输入打印越库数量"
                                 class="width"
                                 @focus="ermNum=''"
                                style="font-size: 36rpx;text-align: right;">
                            </u-input>
                    </text>
                </view> -->
                <view class="line flex justify-between">
                    <text class="text-gray">本次越库数量</text>
                    <text>{{materlist.uncollectedQuantity}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">物料编号</text>
                    <text>{{materlist.wareMaterialCode}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">发货单号</text>
                    <text>{{materlist.deliveryNo}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">批次</text>
                    <text>{{materlist.barNo}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">行号</text>
                    <text>{{materlist.lineNumber}}</text>
                </view>
 
                <view class="margin_top140rpx">
                    <button-modal :cleaningShow='true' allTitle='蓝牙打印' cleaningTitle='斑马打印' @allsubmit="init(1)" @submit='init(2)'/>
                </view>
            </u-popup>
            <button-modal :empTytowerShow='true' cleaningTitle="重置" garmenTitle='下一步' @submit='next' @reset='rest' />
        </view>
 
        <view v-if="totalPages&&pageNow==totalPages&&renameFocus" style="text-align: center">---已经到底了---</view>
 
        <!-- 确认越库 -->
        <view v-if="!renameFocus">
            <scroll-view scroll-y="true" style="height: calc(100vh - 200px);">
                <view v-if="current==0" v-for="(item,eindex) in lastlist" :key="eindex" style="background-color: #fff;margin-top: 6rpx;" class="title-wrap">
                    <u-row class="padding15" v-if="item.total>0">
                        <u-col span="12" class="flex" style="align-items: flex-start;">
                            <view style="background-color: #f18202;color: #fff;border-radius: 50%;width: 20px;height: 20px;line-height: 20px;text-align: center;">
                                {{eindex+1}}
                            </view>
                            <view class="color_f18202 padding_left10rpx" style="flex: 1;word-break: break-all;">
                                {{item.wareMaterialCode}}  -- {{item.barNo}} 
                            </view>
                        </u-col>
                    </u-row>
                    <!-- 取货单列表 -->
                    <view class="background_fff qhd_wp"  v-show="item.SortingOrderDetailsList.length>0&&itemIn.uncollectedQuantity>0" v-for="(itemIn, eindexIn) in item.SortingOrderDetailsList" :key="eindexIn">
                        <u-row>
                            <u-col span="12">
                                <view class="color_80">
                                    取货波次号:{{ itemIn.orderNo }}
                                </view>
                            </u-col>
                        </u-row>
                        <u-row>
                            <u-col span="12">
                                <view class="color_80">
                                    单号:{{ itemIn.deliveryNo }}
                                </view>
                            </u-col>    
                        </u-row>
                        <u-row>
                            <u-col span="6">
                                <view class="color_80" >
                                    工序:{{ itemIn.process }}
                                </view>
                            </u-col>    
                            <u-col span="6" class="color_80 text-right" >
                                机床号:{{ itemIn.equipment }}
                            </u-col>
                        </u-row>
                        <u-row>
                            <u-col span="6">
                                <view class="color_80">
                                    缺料数量:{{ itemIn.quantity }}
                                </view>
                            </u-col>    
                            <u-col span="6" class="color_f18202 text-right">
                                本次越库数量:{{itemIn.uncollectedQuantity  }}
                            </u-col>
                        </u-row>
                    </view>
 
                </view>
    
                <!-- </view> -->
            </scroll-view>
            <view class="fontSize32rpx ">
                <u-row class='padding15 background_fff' style='margin-bottom: 6rpx;'>
                    <u-col span="12" class="font_weight_bold color_f18202" style="text-align: right;">
                        本次越库数: {{uncollectedTotal}}
                    </u-col>
                </u-row>
            </view>
            <button-modal :empTytowerShow='true' cleaningTitle="上一步" garmenTitle='越库完成' @submit='submit'
                @reset='reset(1)' />
        </view>
        <u-action-sheet :list="wolist2" v-model="modalshow2" @click="confirm2"></u-action-sheet>
    </view>
</template>
 
<script>
    import ButtonModal from '@/components/buttonModal.vue'
    import ModalCode from '@/components/ModalCode.vue'
    import tkiBarcode from '@/components/tki-barcode/tki-barcode'
    import bluet from '@/components/blue.vue'
    import {getMoveWarehouseGroup,addconfirmMove,getMoveOrderDetail,getSapSelect} from '@/api/takeMaterial/orderpiece.js'
    import {translateapp} from '@/utils/compress.js'
    import {deletePicture} from '@/api/deliver.js'
    import printComp from '@/mixins/printLabelSingle.js'
    import printShengChanComp from '@/mixins/printShengChanLabel.js'
    import printBanma from '@/mixins/printBanma.js'
    import {getAttrValue} from '../../utils/tool.js'
 
    export default {
        mixins: [printComp,printBanma,printShengChanComp],
        data() {
            return {
                materialCode: '', //物料编号
                renameFocus: true,
                detailshow: false,
                rescode: 0,
                autoFoucs:true,
                resmessage: "",
                current: 0, //滑块默认值
                fileList: [],
                lastlist: [],
                overlist: [], //越库列表
                lacklist: [], //缺料列表
                image: '', //当前显示的图片地址
                action: this.$myHOST + '/sysFileInfo/uploadImages',
                singlist: [
                
                ], //物料详情
                lists: [{
                    name: '越库(0)'
                }, {
                    name: '缺料'
                }],
                list: [],
                arr: [],
                materlist: {}, //物料详情数据
                warehouse: {
                    PurchaseNo: '',
                    WareMaterialCode:'',//物料编码
                    PageSize: 10000,
                    PageNo: 1
                },
                warehouseRules: {
                    PurchaseNo: [{
                        required: true,
                        message: '单号不能为空',
                        trigger: 'blur'
                    }]
                },
                options: [
                    // {
                    //     text: '详情',
                    //     style: {
                    //         backgroundColor: '#fc9f35'
                    //     }
                    // },
                    {
                        text: '删除',
                        style: {
                            backgroundColor: '#fc4b4b'
                        }
                    }
                ],
                operator: '',
                QuantityTotal: 0, //送货总数
                collectedTotal: 0, //已越库数
                uncollectedTotal: 0, //越库总数
                lackTotal: 0, //缺货总数
                code: '',
                addForm: { //打印记录
                    code: '',
                    name: '',
                    batchNo: '',
                    specificationModel: ''
                },
                lotNo: '',
                contLabel:1, //打印张数
                ermNum:'',
                detailshow: false,
                timer:null,
                printflag:false,
                sapLocate:'',
                modalshow2: false,
                wolist2: [],
 
                currentPage: 1, //页数
                pageNow:'', //接口返回的页数
                totalPages: '', //页数
                totalTs:'', //接口返回的总条数
                pramWl:''
            };
        },
        components: {
            ButtonModal,
            ModalCode,
            tkiBarcode,
            bluet
        },
        onLoad(option) {
            // this.lotNo =  "WH" + new Date(this.getCurrentDate().formate).getTime();
            if(option.ids) {
                this.pramWl = option.ids
                this.currentPage = 1
            }
            this.materialBlur(1)
        },
        onReady() {
            // this.$refs.warehouseRef.setRules(this.warehouseRules)
        },
        mounted() {
            this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
            // this.getVehicleType2() //SAP下拉
        },
        onPullDownRefresh() {
            this.$nextTick(function () {
                uni.stopPullDownRefresh(); //停止当前页面下拉刷新
            });
        },
        //上拉加载
        onReachBottom() {
            let _self = this;
            if (this.totalPages && this.pageNow >= this.totalPages) { //无数据 不再请求
                console.log("到底了")
                return
            }
            uni.showNavigationBarLoading();
            this.$nextTick(function () {
                _self.currentPage++;
                _self.materialBlur();
                uni.hideNavigationBarLoading();
            });
        },
        methods: {
            showDetail(item,eindex){
            
                // if(item.WareMaterialCode==''){
                //     return
                // }
                item.childen = !item.childen
                if(item.childen){
                    item.uncollectedQuantity = 1
                }else{
                    item.uncollectedQuantity = 0
                }
                if(this.singlist[eindex].SortingOrderDetailsList.length>0){
                    return
                }
                getMoveOrderDetail({
                'WareMaterialCode':item.wareMaterialCode
                }).then((res) => {
                    if(res.code==200){
                        if (Array.isArray(res.data) && res.data.length >= 0) {
                            if (res.data.length == 0) {
                                uni.showToast({
                                    title:'暂无取货数据',
                                    icon:'none',
                                    duration: 2000
                                })
                                return
                            }
                            res.data.map(item => {
                                item.uncollectedQuantity = 0;
                                return item;
                            })
                            this.singlist[eindex].SortingOrderDetailsList = res.data
                        }
                    }
                })
            },
            //获取print date print time
            getCurrentDate() {
                let date = new Date();
                let year = date.getFullYear(); //年
                let month = date.getMonth() + 1; //月
                month = month >= 10 ? month : '0' + month;
                let day = date.getDate(); //日
                day = day >= 10 ? day : '0' + day;
                let hour = date.getHours() //时
                hour = hour >= 10 ? hour : '0' + hour;
                let min = date.getMinutes(); //分
                min = min >= 10 ? min : '0' + min;
                let second = date.getSeconds(); //秒
                second = second >= 10 ? second : '0' + second;
                return {
                    date: `${day}.${month}.${year}`,
                    time: `${hour}:${min}:${second}`,
                    formate:`${year}/${month}/${day}`
                }
                
            },
            //打印
            init(param) {
                const arr = ['wareMaterialCode','barNo','uncollectedQuantity'];
                const arrzw = ['物料编号','批次','实际越库数']
                let isAllow = ''
                Object.keys(this.materlist).forEach(item => {
                    if(arr.includes(item)) {
                        if(!this.materlist[item]) {
                            isAllow =  arr.indexOf(item)
                            return 
                        }
                    }
                })
                if(isAllow!=''){
                    this.detailshow = false
                    this.rescode = 400
                    this.resmessage = `${arrzw[isAllow]}为空,不能继续打印`
                    this.$refs.resmodal.show = true
                    return
                }
                // if(!this.contLabel || !this.ermNum){
                //     uni.showToast({
                //         title: '数量不能为空且大于0',
                //         icon: 'none'
                //     })
                //     return
                // }
                this.ermNum = this.materlist.uncollectedQuantity;
                this.materlist.quantity = this.materlist.uncollectedQuantity;
                this.materlist.quantityLable = this.materlist.uncollectedQuantity;
                this.contLabel = 1;
                this.materlist.batchNo = this.materlist.barNo;
                if(param==1){ //蓝牙
                    if(this.materlist.orderType == 15){ //生产订单
                        this.arrPt = [this.materlist]
                        this.printShengChanComp('','DO')
                    }else{
                        this.printComp('','DO')
                    }
                }else{ //斑马
                    if(this.materlist.orderType == 15){ //生产订单
                        this.printBanma('',2)
                    }else{
                        this.printBanma('',3)
                    }
                }
            },
            //物料查询
            materialBlur(isFirstPage,enterType) {
                // this.$refs.warehouseRef.validate(valid => {
                    // if (valid) {
 
                        if(enterType ==2 && this.warehouse.WareMaterialCode!='' && this.warehouse.WareMaterialCode.length>50){
                            this.warehouse.WareMaterialCode = getAttrValue(this.warehouse.WareMaterialCode, 'PARTSNUMBER')
                        }
 
                        let params = {
                            PageNo: this.currentPage,
                            PageSize:10,
                            WareMaterialCode: this.warehouse.WareMaterialCode,
                        }
                        if (isFirstPage) {
                            params.PageNo = 1;
                            params.PageSize = 10;
                            this.currentPage = 1;
                            this.singlist = [];
                        }
                        // 带参数
                        if(this.pramWl){
                            params.WareMaterialCode = this.pramWl
                        }
                        console.log("查询")
                        if (this.totalPages && params.PageNo > this.totalPages) { // 无数据 不再请求
                            console.log("无数据 不再请求")
                            return
                        }
                        getMoveWarehouseGroup(params).then((res) => {
                            if(res.code==200){
                                if (Array.isArray(res.data.rows) && res.data.rows.length >= 1) {
                                    res.data.rows.map(item => {
                                        item.uncollectedQuantity = '';
                                        item.children = false;
                                        item.SortingOrderDetailsList=[];
                                        return item;
                                    })
 
                                    if (this.currentPage != 1) {
                                        this.singlist = this.singlist.concat(res.data.rows);
                                    } else {
                                        this.singlist = res.data.rows;
                                    }
                                    this.totalPages = res.data.totalPage
                                    this.pageNow = res.data.pageNo
                                    this.totalTs = res.data.totalRows
 
                                } else {
                                    // this.resmessage = '暂无数据'
                                    // this.rescode = 400
                                    // this.$refs.resmodal.show = true
                                    // this.totalPages = 0
                                }
                            }
                        })
                    // }
                // })
            },
            //删除详情
            longpredel(index, eindex) {
                if (eindex == 0) {
                    this.singlist.splice(index, 1)
                } else {
                    this.materlist = this.singlist[index]
                    this.detailshow = true
                }
            },
            showdetailProp(item,itemIn){
                this.detailshow = true
                this.materlist = {
                    ...item,
                    ...itemIn
                }
            },
            //卡片选中
            click(e) {
                e.cardNum = true
                this.$forceUpdate()
            },
            // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
            open(index) {
                // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
                // 原本为'false',再次设置为'false'会无效
                this.singlist[index].cardNum = true;
                this.singlist[index].show = true;
                this.singlist.map((val, idx) => {
                    if (index != idx) this.singlist[idx].show = false;
                })
                this.$forceUpdate()
            },
            close(index) {
                this.singlist[index].show = false;
                this.singlist[index].cardNum = false;
                this.$forceUpdate()
            },
            // tabs通知swiper切换
            tabsChange(index) {
                this.current = index;
            },
            //改变越库数量
            changeNum(val) {
                // val.cardNum = false
                // if(!val.uncollectedQuantity) {
                //     this.rescode = 400
                //     this.resmessage = '越库数量不能为空且大于0'
                //     this.$refs.resmodal.show = true
                // }
                // // val.uncollectedQuantity  = Number(val.uncollectedQuantity.toString().match(/^\d+(?:\.\d{0,2})?/)) //保留2位小数
                // let num1 = Number(Number(val.deliveryQuantity) -  Number(val.goodsQuantity)).toFixed(3) //必须保留3位小数 -否则会造成剩余物料是小数的时候,无法越库
                // if (Number(val.uncollectedQuantity).toFixed(3) > Number(num1) ) {
                //     val.uncollectedQuantity = 0;
                //     this.rescode = 400
                //     this.resmessage = '越库数'+val.uncollectedQuantity+'不能大于采购总数'+val.deliveryQuantity+'减已越库数'+val.goodsQuantity;
                //     this.$refs.resmodal.show = true
                // }
 
                // if (val.uncollectedQuantity && val.uncollectedQuantity >= 0) {
                //     val.edit = true
                //     this.$forceUpdate()
                // }
 
            },
            
            changeNumIn(val,valParent) {
                // if(val.uncollectedQuantity==='' || val.uncollectedQuantity<0) {
                //     this.rescode = 400
                //     this.resmessage = '越库数量不能为空'
                //     this.$refs.resmodal.show = true
                // }
                val.uncollectedQuantity  = Number(val.uncollectedQuantity.toString().match(/^\d+(?:\.\d{0,3})?/)) //保留2位小数
 
                if (val.uncollectedQuantity > val.quantity) {
                    val.uncollectedQuantity = 0;
                    this.rescode = 400
                    this.resmessage = '不能大于缺料数'
                    this.$refs.resmodal.show = true
                    return
                }
                // valParent.uncollectedQuantity = val.uncollectedQuantity
                // if(val.uncollectedQuantity > valParent.uncollectedQuantity){
                //     val.uncollectedQuantity = 0;
                //     this.rescode = 400
                //     this.resmessage = '不能大于越库数'
                //     this.$refs.resmodal.show = true
                // }
            },
            upload() {
                this.fileList = []
                uni.chooseImage({
                    sourceType: ["camera", "album"],
                    sizeType: "original",
                    count: 1,
                    success: (res) => {
                        this.image = res.tempFilePaths[0]
                        console.log(res.tempFilePaths)
                        translateapp(res.tempFilePaths[0], 80, imgUrl => {
                            //打印压缩后返回的图片url
                                console.log(imgUrl);    
                            //  res.tempFilePaths.forEach(item => this.fileList.push({
                            //     uri: item
                            // }))    
                            let imgArr = [imgUrl]
                            imgArr.forEach(item => this.fileList.push({
                                uri: item
                            }))    
                            console.log(this.fileList)
                            uni.uploadFile({
                                url: this.action,
                                files: this.fileList,
                                fileType: 'image',
                                success: (res) => {
                                    if(res.statusCode==200){
                                        const result = JSON.parse(res.data)
                                        console.log(result.data);
                                        this.fileList.push(result.data)
                                    }else{
                                        this.$u.toast('图片上传失败')
                                        this.fileList = []
                                        this.image = ''
                                    }
                                }
                            })
                        })
                    }
                })
            },
            delimage() {
                if(this.fileList.length<=0){
                    return
                }
                console.log( this.fileList[1])
                deletePicture({
                    'filepath':this.fileList[1]
                }).then(res => {
                    if(res.code == 200) {
                        this.image = ''
                        this.$u.toast('移除图片成功')
                        this.fileList = []
                    }else {
                        this.rescode = 400
                        this.resmessage = `删除图片失败`
                        this.$refs.resmodal.show = true
                    }
                })
            },
            imgClick(url) {
                if(this.image!==''){
                    var imgArr = [];
                    imgArr.push(url)
                    //预览图片
                    uni.previewImage({
                        urls: imgArr,
                        current: imgArr[0]
                    });
                }
            },
            //监听原生返回键
            onBackPress(e) {
                this.delimage()
            },
            //下一步
            next() {
                // const index = this.singlist.findIndex(item => item.uncollectedQuantity == '' || parseFloat(item.uncollectedQuantity) <= 0 || item.uncollectedQuantity == undefined);
                // if(index > -1) {
                //     uni.showModal({
                //         title: '提示',
                //         content: `${this.singlist[index].wareMaterialCode}未填写越库数量`,
                //         showCancel: false
                //     })
                //     return
                // }
                // 过滤为 0 
 
 
                // isBatchMge为true: 批次管理的物料 必须输入
                // let arrMge = this.singlist.filter((v)=>(v.isBatchMge == 1 && v.barNo==''|| v.isBatchMge == 1 && v.barNo==null)).filter((v2)=>(v2.uncollectedQuantity>0))
                // if(arrMge.length>0){
                //     uni.showToast({
                //         title: `${arrMge[0].wareMaterialCode}请填写空的批次`,
                //         icon:'none'
                //     })        
                //     return
                // }
 
 
            
 
 
                // this.lacklist = this.singlist.reduce((curr,item) => {
                //     if(item.deliveryQuantity - item.uncollectedQuantity - item.goodsQuantity > 0) {
                //         curr.push(item)
                //     }
                //     return curr;
                // },[])
                
                this.renameFocus = false
                // this.QuantityTotal = this.singlist.reduce((prev, next) => {
                //     let num  = Number(prev) + Number(next.deliveryQuantity)
                //     return Number(num).toFixed(3)
                // }, 0)
                
                // this.collectedTotal = this.singlist.reduce((prev,next) => {
                //     let num = Number(prev) + Number(next.goodsQuantity);
                //     return  Number(num).toFixed(3)
                // },0)
 
 
                this.uncollectedTotal = 0
                this.singlist.forEach((item,index) => {
                    item.total = 0
                    if(item.SortingOrderDetailsList.length>0){
                        item.SortingOrderDetailsList.forEach((item2,index2) => {
                            if(item2.uncollectedQuantity>0){
                                item.total += item2.uncollectedQuantity;
                                this.uncollectedTotal += item2.uncollectedQuantity;
                            }
                        })
                    }
                })
 
                this.lastlist =  this.singlist.filter(v=>v.total>0);
 
                this.uncollectedTotal = Number(this.uncollectedTotal).toFixed(3)
 
                // this.lackTotal = this.singlist.reduce((prev, next) => {
                //     let num = Number(prev) +Number(next.quantity) - Number(next
                //         .uncollectedQuantity)
                //     return Number(num).toFixed(3)
                // }, 0)
                this.lists[0].name = `越库(${this.lastlist.length})`
                this.lists[1].name = `缺料(${this.lacklist.length})`
            },
            //确认越库
            submit() {
                if(this.uncollectedTotal<=0){
                    uni.showToast({
                        title:'越库总数大于0',
                        icon:'none',
                        duration: 2000
                    })
                    return
                }
                let SortingOrderDetailsList = []
                 this.lastlist.forEach((item,index) => {
                    item.SortingOrderDetailsList.forEach((itemIN,indexIN) => {
                        let {quantity,uncollectedQuantity,batchNo,...rest} = itemIN
                        if(Number(uncollectedQuantity ) >0){
                            SortingOrderDetailsList.push({
                                'quantity':uncollectedQuantity,
                                'batchNo':item.barNo || item.batchNo,
                                ...rest
                            })
                        }
                    })
                })
                uni.showModal({
                    title: '提示',
                    content: '是否确认越库?',
                    showCancel: true,
                    cancelColor: '#333333',
                    success: (res => {
                        if (res.confirm) {
                            addconfirmMove(SortingOrderDetailsList).then((res) => {
                                this.rescode = res.code
                                this.resmessage = res.message
                                this.$refs.resmodal.show = true
                                if (res.code == 200) {
                                    this.renameFocus = true
                                    this.rest()
                                }
                            })
 
                        } else if (res.cancel) {
                        }
                    })
                });
                
            },
            //清楚选中
            rest(parm) {
                this.warehouse.WareMaterialCode = '';
                this.singlist = [];
                this.pramWl =''
                this.materialBlur(1)
            },
            reset(back) {
                if(back){
                    this.autoFoucs = false
                }
                this.renameFocus = true
            },
            //打印
            onPrint() {
                let _this = this
                if (!uni.getStorageSync("deviceId")) {
                    uni.showToast({
                        title: '请连接打印机',
                        icon: 'error',
                        duration: 2000
                    })
                    return
                }
                this.writeBLECharacteristicValue()
            },
            beforeDestroy() {
                // 销毁定时器
                if(this.timer){
                    clearTimeout(this.timer)
                    this.timer = null
                }
                
            },
            //类型聚焦事件
            containerFocus2() {
                uni.hideKeyboard()
                this.modalshow2 = true
            },
            getVehicleType2() {
                getSapSelect().then((res) => {
                    if(res.code==200){
                        const dataT = res.data
                        if (dataT && dataT.length == 0) {
                            this.wolist2 = []
                            return
                        }
                        let dataDst = []
                        dataT.forEach(item => {
                            dataDst.push({
                                'text':item,
                                'id':item
                            })
                        })
                        this.wolist2 = dataDst;
                    }
                })
            },
            //类型选择
            confirm2(index) {
                // this.warehouse.containerCode = this.wolist2[index].text;
                // this.warehouse.containerCode = this.wolist2[index].id;
                console.log( this.wolist2[index].text);
                this.sapLocate = this.wolist2[index].text;
                this.singlist.forEach((item)=>{
                    item.sap_Location =  this.wolist2[index].text;
                })
                console.log(this.singlist);
                this.$forceUpdate();
 
            }
        }
    }
</script>
 
<style lang="scss">
.title-wrap{
    margin-bottom: 15rpx;
    border-bottom: 1px solid #f18202;
    border-top: 1px solid #f18202;
    padding: 3px;
}
.bg_item {
    background: #FFEBCD !important;
}
.qhd_wp{
    border-top: 1px solid #f18202;
    position: relative;
}
.detail_btn{
    text-align: right;
    padding: 10px;
}
.detailBtn{
    position: absolute;
    right: 15rpx;
    top: 15rpx;
}
</style>