333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
<template>
    <!-- 收货 -->
    <view class="overflow" style="padding-bottom:150px">
        <!-- 遮挡层 -->
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
        <!-- 收货 -->
        <view class="" v-if="renameFocus">
            <u-form labelPosition="left" label-width="160rpx" :model="warehouse" ref="warehouseRef">
                <u-row  class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                    <u-col span="12">
                        <u-form-item label-width="200rpx" label="托盘号:" required class="itemWB">
                            <u-input id="plateCodeRef" ref="plateCodeRef" :focus="curFoucus" v-model.trim="ewmPlateCode" @focus="ewmPlateCode = ''"
                                placeholder="请录入或扫码"  :clearable="false">
                            </u-input>
                        </u-form-item>
                    </u-col>
                </u-row>
                <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                    <u-col span="12">
                        <u-form-item label-width="200rpx" label="到货二维码:" required class="itemWB">
                            <u-input id="materialRef" ref="materialRef" :focus="curFoucus" v-model.trim="ewmMaterialCode" @focus="ewmMaterialCode = ''"
                                placeholder="请录入或扫码" @confirm="getMaterialDetails2" :clearable="false">
                            </u-input>
                        </u-form-item>
                    </u-col>
                </u-row>
 
                <u-row class="border_bottom margin_top10rpx padding10 bg_ffffff">
                    <u-col span="12" class="margin_top10rpx">
                        <u-form-item label-width="150rpx" label="移动类型:" prop="taskTypeName" required class="itemWB">
                            <u-input v-model="moveTypeName" @click="modalshow2 = true" type="select"
                                placeholder="选择移动类型" class="width">
                            </u-input>
                        </u-form-item>
                    </u-col>
                </u-row>
                <u-action-sheet :list="wolist2" v-model="modalshow2" @click="confirm2"></u-action-sheet>
 
            </u-form>
            <view v-show="tableData.length > 0">
                <u-swipe-action :show="item.show" :index="eindex" v-for="(item, eindex) in tableData" :key="eindex"
                    @click="longpredel" @open="open" @close='close' :options="options" class="margin_top10rpx">
                    <view class="item u-border-bottom ">
                        <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
                        <view class="title-wrap">
                            <view :key="eindex + 'tableData'" :class="item.cardNum ? 'bd-ffe6c9' : ''" v-if="item.edit"
                                class="title-wrap fontSize32rpx background_fff padding10">
                                <u-row>
                                    <u-col span="12" class="flex">
                                        <text
                                            class="flex justify-center align-center  circkle06">{{ eindex + 1 }}</text>
                                        <view class="color_f18202 padding_left10rpx"
                                            style="flex: 1;word-break: break-all;">
                                            {{ item.productCode }}
                                        </view>
                                    </u-col>
                                </u-row>
                                    <u-row class="padding_left30rpx">
                                    <u-col span="12">
                                        <text class="color_80">
                                            物料名称:{{ item.productName }}
                                        </text>
                                    </u-col>
                                </u-row>
                                <u-row class="padding_left30rpx">
                                    <u-col span="12">
                                        <text class="color_80">
                                            跟踪号:{{ item.extendField04 }}
                                        </text>
                                    </u-col>
                                </u-row>
                                <u-row class="padding_left30rpx">
                                    <u-col span="12" class="flex">
                                        <view class="color_80" style="width: 220rpx;">
                                            存储位置:
                                        </view>
 
                                        <input
                                            class=" width text-left fontSize32rpx padding_left10rpx border_bottom_f18202"
                                            v-model.trim="item.productBarCode" type="text" placeholder="请输入存储位置" />
                                    </u-col>
                                </u-row>
                        
                                <!--                 <u-row class="padding_left30rpx">
                                    <u-col span="7">
                                        <view class="color_80" >
                                            到货可收:{{ item.goodSurplusQuantity }}
                                        </view>
                                    </u-col>
                                    <u-col span="5">
                                        <view class="color_80">
                                            已收货数:{{ item.goodsQuantity }}
                                        </view>
                                    </u-col>
                                </u-row> -->
 
 
                                <u-row class="padding_left30rpx">
                                    <u-col span="9" class="flex">
                                        <view class=" color_80">
                                            限用日期:
                                        </view>
                                        <view>
                                            {{ item.limitDate }}
                                            <!--         <picker mode="date" :value="item.limitDate" :start="startDate"
                                                :end="endDate" @change="bindDateChange($event,item)">
                                                <view class="uni-input">{{ item.limitDate }}</view>
                                            </picker> -->
                                        </view>
                                    </u-col>
                                </u-row>
                                <u-row class="padding_left30rpx">
                                    <u-col span="7" class="color_80">
                                        <!--         到货单号:{{ item.deliveryNo }} -->
                                    </u-col>
                                    <u-col span="5" class="flex color_f18202">
                                        <view class="color_80">
                                            本次操作量:
                                        </view>
                                        {{item.receivedQuantity}}
                                        <!--     <input class="border_bottom_f18202 text-left color_f18202 fontSize32rpx inputGray"
                                            v-model="item.bigQty" type="number"  @focus='dc(item)'
                                            @blur="changeNum(item)" placeholder="0" /> -->
                                    </u-col>
                                </u-row>
                            </view>
                        </view>
                    </view>
                </u-swipe-action>
            </view>
            <u-popup v-model="detailshow" border-radius="14" @close="detailshow = false" mode="bottom">
                <h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
                <scroll-view scroll-y="true" style="height: 550rpx;">
                    <view class="line flex justify-between">
                        <text class="text-gray">采购单号</text>
                        <text>{{ materlist.poCode }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">采购项号</text>
                        <text>{{ materlist.itemNumber }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">物料名称</text>
                        <text>{{ materlist.productName }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">采购数量</text>
                        <text>{{ materlist.bigQty }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">已收货数量</text>
                        <text>{{ materlist.bigEnterQuantity }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">重量</text>
                        <text>{{ materlist.weight }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">物料规格</text>
                        <text>{{ materlist.productSpec }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">工厂</text>
                        <text>{{ materlist.extendField02 }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">销售项号</text>
                        <text>{{ materlist.specAlias }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">销售单号</text>
                        <text>{{ materlist.extendField07 }}</text>
                    </view>
 
                    <view class="line flex justify-between">
                        <text class="text-gray">容差率(%)</text>
                        <text>{{ materlist.overcharges }}</text>
                    </view>
 
                    <view class="line flex justify-between">
                        <text class="text-gray">单位转换值</text>
                        <text>{{ materlist.unitConvert }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">转换系数</text>
                        <text>{{ materlist.unEnterQuantity }}</text>
                    </view>
 
                    <view class="line flex justify-between">
                        <text class="text-gray">库存单位</text>
                        <text>{{ materlist.smallUnit }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">库存单位收货数量</text>
                        <text>{{ materlist.quantity }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">存储位置</text>
                        <text>{{ materlist.productBarCode }}</text>
                    </view>
                    <view class="line flex justify-between">
                        <text class="text-gray">采购单位</text>
                        <text>{{ materlist.bigUnit }}</text>
                    </view>
 
                </scroll-view>
            </u-popup>
 
        </view>
        <!-- 确认收货 -->
        <view class="margin_top10rpx" v-if="renameFocus==false">
            <scroll-view scroll-y="true" style="height: 40vh;">
                <view v-if="current == 0" v-for="(item, eindex) in lastlist" :key="eindex"
                    class="border_bottom margin_top10rpx padding10  background_fff fontSize32rpx">
                    <u-row class="padding10">
                        <u-col span="12" class="flex">
                            <text class="flex justify-center align-center  circkle06">{{ eindex + 1 }}</text>
                            <view class="color_f18202 padding_left10rpx">
                                {{ item.wareMaterialCode }}({{ item.batchNo }})
                            </view>
                        </u-col>
                    </u-row>
                    <u-row>
                        <u-col span="6">
                            <view class="color_80">
                                入库单号:{{ item.purchaseNo }}
                            </view>
                        </u-col>
                        <u-col span="6">
                            <view class="color_80">
                                到货总数:{{ item.deliveryQuantity }}
                            </view>
                        </u-col>
                    </u-row>
                    <u-row>
                        <u-col span="6">
                            <view class="color_80">
                                到货可收:{{ item.goodSurplusQuantity }}
                            </view>
                        </u-col>
                        <u-col span="6">
                            <view class="color_80">
                                已收货数:{{ item.goodsQuantity }}
                            </view>
                        </u-col>
                    </u-row>
                    <u-row>
                        <u-col span="6" class="color_80">
                            物流单号:{{item.logisticsOrderNo}}
                        </u-col>
                        <u-col span="6" class="color_80">
                            到货单号: <text class="color_f18202">{{ item.deliveryNo }} </text>
                        </u-col>
                    </u-row>
                    <u-row>
                        <u-col span="6" class="color_80">
                            箱号:{{item.boxNo}}
                        </u-col>
                        <u-col span="6" class="color_80">
                            标记号:{{ item.tagNo }}
                        </u-col>
                    </u-row>
                    <u-row>
                        <u-col span="6" class="color_80">
                        </u-col>
                        <u-col span="6" class="color_80">
                            本次收货: <text class="color_f18202">{{ item.uncollectedQuantity }} </text>
                        </u-col>
                    </u-row>
                </view>
            </scroll-view>
            <view class="fontSize32rpx ">
                <u-row class='padding15 background_fff' style='margin-bottom: 6rpx;'>
                    <u-col span="6" class="text-gray">
                    </u-col>
                    <u-col span="6" style="text-align: right;">
                        已收货数:<text class="font_weight_bold">{{ Number(collectedTotal || 0).toFixed(3) }}</text>
                    </u-col>
                </u-row>
                <u-row class='padding15 background_fff' style='margin-bottom: 6rpx;'>
                    <u-col span="6" class="text-gray">
                    </u-col>
                    <u-col span="6" style="text-align: right;">
                        本次收货数:<text class="font_weight_bold color_f18202">{{ Number(uncollectedTotal || 0).toFixed(3)
                        }}</text>
                    </u-col>
                </u-row>
            </view>
        </view>
        <button-modal v-if="renameFocus" :empTytowerShow='true' cleaningTitle="重置" garmenTitle='收货完成' @submit='save'
            @reset='rest(1)' />
    </view>
</template>
 
<script>
    import ButtonModal from '../../../components/buttonModal.vue'
    import ModalCode from '../../../components/ModalCode.vue'
    import tkiBarcode from '@/components/tki-barcode/tki-barcode'
    import {
        getPurchaseOrderDetail2,
        addDeliveryNew,
        createBatchNo,
        deletePicture,
        getSapSelect,
        addShouhuoJiaoYan,
        getPositions
    } from '@/src/api/orderpiece.js'
    import {
        translateapp,
        translateImg
    } from '@/utils/compress.js'
    import {
        getDate,
        getAttrValue
    } from '@/src/untils/tool.js'
 
    export default {
        data() {
            const currentDate = this.getDate({
                format: true
            })
            return {
                isShowPlateCode:true,//是否显示托盘号 
                curBatchNo: '', //后台生成的批次号 【Editby shaocx,2022-12-30】
                materialType: 1, //1订单件  5 免费件
                curFoucus: true, //自动聚焦 【Editby shaocx,2022-11-23】
                materialCode: '', //物料编号Z247M0081010
                renameFocus: true,
                listShow: false,
                detailshow: false,
                rescode: 0,
                resmessage: "",
                current: 0, //滑块默认值
                printNum: '', //打印数量
                focu: false,
                printflag: false, //打印/物料信息,true为物料信息
                fileList: [],
                fileListImgSrc: [], //上传图片列表
                lastlist: [],
                overlist: [], //收货列表
                lacklist: [], //缺料列表
                flag: true,
                image: '', //当前显示的图片地址
                action: this.$myHOST + '/sysFileInfo/uploadImages',
                tableData: [], //物料详情
                lists: [{
                    name: '收货(0)'
                }, {
                    name: ''
                }],
                list: [],
                arr: [],
                materlist: {}, //物料详情数据
                warehouse: {
                    poCode: "", //采购单号
                    itemNumber: "", //行号
                },
                moveType: "101",
                moveTypeName: "收货101",
                sapLocate: '',
                options: [{
                        text: '详情',
                        style: {
                            backgroundColor: '#fc9f35'
                        }
                    },
                    {
                        text: '删除',
                        style: {
                            backgroundColor: '#fc4b4b'
                        }
                    }
                ],
                DeliveryNoOld: false,
                operator: '',
                QuantityTotal: 0, //送货总数
                collectedTotal: 0, //已收货数
                uncollectedTotal: 0, //收货总数
                lackTotal: 0, //缺货总数
                code: '',
                addForm: { //打印记录
                    code: '',
                    name: '',
                    batchNo: '',
                    specificationModel: ''
                },
                contLabel: 1, //打印张数
                timer: null,
                ewmMaterialCode: '',
                ewmPlateCode:'',
                modalshow2: false,
                loading: false,
                timerLoad: null,
                wolist2: [{
                        id: '101',
                        text: '收货101'
                    },
                    {
                        value: '102',
                        text: '退货102'
                    }
                ],
                date: currentDate,
                isUseQrCode: true, //是否使用到货二维码
                qrCode_guid: "",
                isChecked: true,
                isChecked_PrintForOutStore: false, //出库口打印
                isOnShelve: false, //是否上架
                positionList: [],
                storage_Id: 87,
                creator:""
            };
        },
        components: {
            ButtonModal,
            ModalCode,
            tkiBarcode
            // bluet
        },
        //监听原生返回键
        // onBackPress(e) {
        //     // 此处一定要return为true,否则页面不会返回到指定路径
        //     if (this.warehouse.DeliveryNo == '') {
        //         return false //可返回
        //     } else {
        //         uni.showModal({
        //             title: '提示',
        //             content: '是否确认返回?',
        //             showCancel: true,
        //             cancelColor: '#333333',
        //             success: (res => {
        //                 if (res.confirm) {
        //                     uni.redirectTo({
        //                         url: '/pages/index/index'
        //                     })
        //                 } else if (res.cancel) {
 
        //                 }
        //             })
        //         });
        //         return true
        //     }
        // },
        mounted() {
            // this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
            // this.getVehicleType2() //SAP下拉
            let tokenInfouser = uni.getStorageSync('$tokenInfouser');
            if(!tokenInfouser){
                uni.navigateTo({
                    url: '../Login/login?id=1'
                })
            }
            
            let creator = uni.getStorageSync('creator') || ''
            if(creator){
                this.creator = JSON.parse(creator) || ''//修改人
            }
            
            this.isShowPlateCode = true;
            //alert(this.$route.query.type);
        },
        computed: {
            startDate() {
                return this.getDate('start');
            },
            endDate() {
                return this.getDate('end');
            }
        },
        methods: {
            // 更改日历
            bindDateChange: function(e, item) {
                item.limitDate = e.detail.value;
                this.$forceUpdate()
            },
            getDate(type) {
                const date = new Date();
                let year = date.getFullYear();
                let month = date.getMonth() + 1;
                let day = date.getDate();
                if (type === 'start') {
                    year = year - 60;
                } else if (type === 'end') {
                    year = year + 2;
                }
                month = month > 9 ? month : '0' + month;
                day = day > 9 ? day : '0' + day;
                return `${year}-${month}-${day}`;
            },
            init() {
                const arr = ['wareMaterialCode', '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
                }
 
                if (this.materlist.isFullBox) {
                    uni.showToast({
                        title: '必须输入箱号!',
                        icon: 'none'
                    })
                    return
                }
 
                this.print()
            },
 
            //编辑状态样式
            dc(e) {
                // e.cardNum = true
                e.uncollectedQuantity = ''
                this.$forceUpdate()
            },
            //物料查询
            getMaterialDetails2() {
                if (this.ewmMaterialCode == "") {
                    return
                }
                this.warehouse.poCode = getAttrValue(this.ewmMaterialCode, 1);
                this.warehouse.itemNumber = getAttrValue(this.ewmMaterialCode, 2);
                var qty = getAttrValue(this.ewmMaterialCode, 4) || "";
                var dateF = getAttrValue(this.ewmMaterialCode, 5) || "";
                this.qrCode_guid = getAttrValue(this.ewmMaterialCode, 6) || "";
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        let param = {
                            "itemNumber": this.warehouse.itemNumber, //行号
                            "poCode": this.warehouse.poCode, //PO号
                            // "poCode":"4507909712",
                            // "itemNumber":""
                        }
                        getPurchaseOrderDetail2(param).then((res) => {
                            if (res.data.result) { //200
                            
                                let dataAll = res.data.data;
                                if (dataAll.length == 0) {
                                    this.resmessage = '此物料不存在!'
                                    this.rescode = 400
                                    this.$refs.resmodal.show = true
                                    return
                                }
                                //-----------pc端代码
                                if (dataAll) {
                                    // 构建数据
                                    // this.currentRow = null
                                    // this.formData.positionName = null
                                    // this.formData.productModel = null
                                    // this.formData.scanQty = null
                                    this.tableData = dataAll.map(row => {
                                        row.finishedQuantity = 0
                                        row.sortIndex = 0
                                        row.scanWeight = 0
                                        // this.formData.trackingNumber = row.trackingNumber
                                        // this.formData.saleCode = row.saleCode
                                        //限用日期
                                        // if (this.isUseQrCode) {
                                        //     //        row.limitDate =this.UseQrCodeData.qrCode_limitDate;
                                        //     var str = this.UseQrCodeData.qrCode_limitDate;
                                        //     row.limitDate = str.substr(0, 4) + "-" + str.substr(4,
                                        //         2) + "-" + str.substr(6, 2);
                                        // } else {
                                        //     // row.limitDate = moment(new Date())
                                        //     // .add(1, 'years')
                                        //     // .format('YYYY-MM-DD')
                                        // }
 
                                        if (dateF && dateF.length == 8) {
                                            row.limitDate = dateF.substr(0, 4) + "-" + dateF
                                                .substr(4,
                                                    2) + "-" + dateF.substr(6, 2);
                                        } else {
                                            row.limitDate = ""
                                        }
 
                                        row.itemNumber = row.itemNumber
                                        row.unitConvert = row.unitConvert
                                        row.unEnterQuantity = row.unEnterQuantity
                                        if (!row.overcharges) {
                                            row.overcharges = null
                                        }
                                        row.itemNumber = parseInt(row.itemNumber)
 
                                        //本次操作量
                                        if (this.isUseQrCode) {
                                            row.receivedQuantity = qty
                                        } else {
                                            row.receivedQuantity = row.bigQty - row
                                                .bigEnterQuantity
                                        }
 
                                        row.extendField04 = row.extendField04
                                        row.extendField07 = row.extendField07
                                        row.weight = row.weight
                                        row.bigUnit = row.bigUnit
                                        //this.formData.totalWeight = Math.Round((row.receivedQuantity || 0) * row.weight)
                                        row.edit = 1 //控制是否显示
                                        return row
                                    })
 
 
                                    // if (!this.formData.isValidateProductCode) { //无用代码
                                    //   this.tableData.forEach(row => {
                                    //     row.finishedQuantity = Math.Round(row.unFinishedQuantity, 4)  //已收货数量
                                    //     row.scanWeight = row.totalWeight
                                    //     row.unFinishedQuantity = 0  
                                    //     row.bigUnit = row.bigUnit
                                    //     row.bigQty = row.bigUnEnterQuantity
                                    //   })
                                    // }
                                    // 直接上架选中时手工输入,未选中获取收货位
                                    if(res.data.statusCode){
                                        this.storage_Id = parseInt(res.data.statusCode);
                                    }
                                    if (!this.isOnShelve) {
                                        this.getPositionList()
                                    } else {
                                        //    this.focus('positionName')
                                    }
                                } else {
                                    //    this.focus('poCode')
                                }
 
 
                                //-----------pc端代码
 
 
                                // dataAll.forEach(item => {
                                //     item.edit = 1 //控制是否显示
                                //     item.quantity = qty;
                                //     if (dateF && dateF.length == 8) {
                                //         item.limitDate = dateF.substr(0, 4) + "-" + dateF.substr(4,
                                //             2) + "-" + dateF.substr(6, 2);
                                //     } else {
                                //         item.limitDate = ""
                                //     }
                                // })
 
                                this.tableData = dataAll;
                                
                                //相同采购单号 多个收货
                                // if (this.tableData.length > 0) {
                                //     //采购单号相同的物料
                                //     if (this.tableData[0].poCode == this.warehouse.poCode) {
                                //         let arrIndex = this.tableData.findIndex(v => v.itemNumber == this
                                //             .warehouse.itemNumber)
                                //         if (arrIndex == -1) {
                                //             this.tableData.unshift(dataAll[0])
                                //         } else {
                                //             this.tableData.unshift(...this.tableData.splice(arrIndex, 1))
                                //         }
                                //     } else {
                                //         //采购单号不同
                                //         this.tableData = dataAll;
                                //     }
                                // } else {
                                //     this.tableData = dataAll;
                                // }
                            } else {
                                this.resmessage = res.data.msg;
                                this.rescode = 400
                                this.$refs.resmodal.show = true
                            }
                            this.ewmMaterialCode = '';
                            this.autoFocusPdaInput(); //客户要求 扫码后 清空数值 自动聚焦focus
                        })
                    }
                })
            },
            //客户要求 扫码后 清空数值 自动聚焦focus
            autoFocusPdaInput(){
                //客户要求 扫码后 清空数值在聚焦
                // #ifdef H5
                try {
                    document.getElementById('materialRef').querySelector('input').focus()
                } catch (e) {}
                // #endif
                
                // #ifdef APP
                try{
                    this.curFoucus = false
                    this.timerPrint = setTimeout(()=>{
                        this.curFoucus = true
                        clearTimeout(this.timerPrint)
                        this.timerPrint = null
                    }, 2000)
                }catch(e){
                    //TODO handle the exception
                }
                // #endif
                //客户要求 扫码后 清空数值在聚焦
            },
            //删除详情
            longpredel(index, eindex) {
                this.tableData[index].cardNum = true
                this.printflag = false
                if (eindex == 1) {
                    this.tableData.splice(index, 1)
                } else {
                    this.materlist = this.tableData[index]
                    this.detailshow = true
                }
            },
            //卡片选中
            click(e) {
                e.cardNum = true
                this.$forceUpdate()
            },
            // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
            open(index) {
                // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
                // 原本为'false',再次设置为'false'会无效
                this.tableData[index].cardNum = true;
                this.tableData[index].show = true;
                this.tableData.map((val, idx) => {
                    if (index != idx) this.tableData[idx].show = false;
                })
                this.$forceUpdate()
            },
            close(index) {
                this.tableData[index].show = false;
                this.tableData[index].cardNum = false;
                this.$forceUpdate()
            },
            // tabs通知swiper切换
            tabsChange(index) {
                this.current = index;
            },
            //改变组盘数量
            changeNum(val) {
                val.cardNum = false
                if (!val.uncollectedQuantity) {
                    val.uncollectedQuantity = 0
                    this.rescode = 400
                    this.resmessage = '收货数量不能为空'
                    this.$refs.resmodal.show = true
                }
                val.uncollectedQuantity = Number(val.uncollectedQuantity).toFixed(3)
                if (Number(val.goodSurplusQuantity).toFixed(3) < Number(val.uncollectedQuantity)) {
                    this.rescode = 400
                    this.resmessage = '本次收货数量不能大于到货可收'
                    this.$refs.resmodal.show = true
                }
            },
 
            //下一步
            next() {
                this.lastlist = []
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        // if (this.warehouse.DeliveryNo == '') {
                        //     uni.showModal({
                        //         title: '提示',
                        //         content: `单号不能为空`,
                        //         showCancel: false
                        //     })
                        //     return
                        // }
                        if (this.sapLocate == '') {
                            uni.showToast({
                                title: '请选择或填写SAP位置!',
                                icon: 'none'
                            })
                            return
                        }
                        if (this.tableData.length <= 0) {
                            uni.showModal({
                                title: '提示',
                                content: `详情不能为空`,
                                showCancel: false
                            })
                            return
                        }
                        this.lastlist = this.tableData.filter(item => (Number(item.uncollectedQuantity) > 0))
                        if (this.lastlist.length <= 0) {
                            uni.showToast({
                                title: '未填写收货数量',
                                icon: 'none'
                            })
                            return
                        }
 
 
 
                        let params = this.lastlist.reduce((curr, item) => {
                            curr.push({
                                wareMaterialCode: item.wareMaterialCode,
                                uncollectedQuantity: item.uncollectedQuantity,
                                purchaseNo: item.purchaseNo,
                                ebelp: item.ebelp,
                                DeliveryNo: item.deliveryNo,
                                batchNo: item.batchNo,
                                sap_Location: this.sapLocate || item.sap_Location,
                                boxNo: item.boxNo || '',
                                ImageIds: "", //图片地址
                                logisticsOrderNo: this.warehouse.logisticsOrderNo,
                                tagNo: item.tagNo
                            })
                            return curr;
                        }, [])
                        this.collectedTotal = this.tableData.reduce((prev, next) => {
                            return prev + next.goodsQuantity;
                        }, 0)
                        // 本次收货数
                        this.uncollectedTotal = this.tableData.reduce((prev, next) => {
                            return Number(prev) + Number(next.uncollectedQuantity)
                        }, 0)
 
                        addShouhuoJiaoYan(params).then((res) => {
                            if (res.code == 200) {
                                if (res.data) {
                                    let ct = ''
                                    if (res.data != '成功') {
                                        ct = res.data
                                    }
                                    uni.showModal({
                                        title: '提示',
                                        content: `${ct} 确认下一步?`,
                                        showCancel: true,
                                        cancelColor: '#333333',
                                        success: (res => {
                                            if (res.confirm) {
                                                this.renameFocus = false;
                                                // 已收货数
 
                                            } else if (res.cancel) {
 
                                            }
                                        })
                                    });
                                } else {
                                    this.renameFocus = false
                                }
                            }
                        })
 
 
                    }
                });
            },
            //确认收货
            save() {
                if(this.isShowPlateCode && this.ewmPlateCode ==''){
                    uni.showToast({
                        title: '托盘号不能为空!',
                        icon: 'none'
                    })
                    return
                }
                if (this.tableData.length <= 0) {
                    uni.showToast({
                        title: '没有物料!',
                        icon: 'none'
                    })
                    return
                }
 
                //------------------ pc端代码 -----------------
                // if (this.multipleSelection.length !== 0) {
                //   this.tableData = this.multipleSelection
                // }
 
                let isBreak = 0
                let msgg = ''
                this.tableData.forEach(item => {
                    item.overcharges = item.overcharges == null ? 0 : item.overcharges;
                    let maxValues = this.moveType == '101' ? (1 + item.overcharges / 100) * item.bigQty -
                        item.bigEnterQuantity : item.bigEnterQuantity;
                    if (item.receivedQuantity > maxValues) {
                        msgg = msgg + '-' + item.itemNumber
                    }
                })
 
                if (msgg !== '') {
                    uni.showToast({
                        title: '采购项号' + msgg + '-操作数量超过上限',
                        icon: 'none'
                    })
                    return
                }
                var dataList = this.getCheckList(this.tableData);
 
                // 如果是退货的话
                if (this.moveType === '102') {
                    if (!dataList.length) {
                        uni.showToast({
                            title: '退货数量不可超过已收数量!',
                            icon: 'none'
                        })
                        return
                    }
                }
                const detailList = JSON.stringify(
                    dataList.map(m => {
                        return {
                            PoNumber: m.poCode, // 采购单号
                            PoItem: m.itemNumber, // 采购项号
                            MaterialCode: m.productCode,
                            Quantity: m.quantity, // 本次收货量
                            StorageLocation: m.productBarCode, // 存储位置
                            Plant: m.extendField02, // 工厂
                            MoveType: this.moveType
                        }
                    })
                )
                if (!dataList.length) {
                    uni.showToast({
                        title: '至少扫描一条!',
                        icon: 'none'
                    })
                    return
                }
                //    this.formData.positionName = dataList[0].positionName
 
                var orderListDetail = this.tableData.map(rowData => {
                    return {
                        orderList_Id: rowData.orderList_Id
                    }
                })
 
                //判断取值isChecked [EditBy shaocx,2022-06-21]
                let _printFlag = 1 // 0不打印 1:入库口打印机 2:出库口打印机
                if (this.isChecked) {
                    _printFlag = 1 //默认 入库口打印机
                    if (this.isChecked_PrintForOutStore) {
                        _printFlag = 2 //表示是 出库口打印机
                    }
                } else {
                    _printFlag = 0
                }
                //增加给后台传递的二维码GUID
                var _qrCode_guid = "";
                if (this.isUseQrCode) {
                    _qrCode_guid = this.qrCode_guid;
                }
                var _plateCode = "";
                _plateCode = this.ewmPlateCode;
 
                uni.showModal({
                    title: '提示',
                    content: '确认收货?',
                    showCancel: true,
                    cancelColor: '#333333',
                    success: (res => {
                        if (res.confirm) {
                            var params = {
                                creator:this.creator,
                                qrCode_guid: _qrCode_guid,
                                plateCode:_plateCode,
                                poCode: this.tableData[0].poCode,
                                // trackingNumber: this.formData.trackingNumber,
                                // saleCode: this.formData.saleCode,
                                // positionName: this.formData.positionName,
                                // totalWeight: this.formData.totalWeight,
                                // LightSortInfo_Id: null,
                                dataList: dataList,
                                //detailList: detailList,
                                moveType: this.moveType,
                                isAutoPrint: this.isChecked, //传递参数是否自动打印   
                                printFlag: _printFlag
                                // printQty: this.printQty,
                                // orderListDetail: orderListDetail
                            }
                            // 防止点击多次
                            if (this.loading) {
                                console.log('点击多次拦住')
                                uni.showLoading({
                                    title: '稍后再试...',
                                    mask: true
                                });
                                return
                            }
                            this.loading = true
                            addDeliveryNew(params).then((res) => {
                                if (res.data.result) { //200
                                    this.rescode = 200;
                                    this.resmessage = res.data.msg;
                                    this.$refs.resmodal.show = true
                                    this.rest(1)
                                } else {
                                    this.resmessage = res.data.msg;
                                    this.rescode = 400
                                    this.$refs.resmodal.show = true
                                }
                            }).finally(() => {
                                console.log("清除定时器")
                                this.timerLoad = setTimeout(() => { // 防止点击多次
                                    console.log("清除定时器成功")
                                    this.loading = false
                                    uni.hideLoading()
                                    clearTimeout(this.timerLoad)
                                    this.timerLoad = null
                                }, 6000);
                            })
                        }
                    })
                });
            },
            //清楚选中 重置
            rest(param) {
                this.warehouse.poCode = '';
                this.warehouse.itemNumber = '';
                this.ewmMaterialCode = '';
                this.qrCode_guid = "";
                this.tableData = [];
                if (param) {
                    this.curFoucus = true
                }
                this.materialCode = '';
            },
 
            // 获得仓库和货位信息
            getPositionList() {
                getPositions({
                    storage_Id: this.storage_Id,
                    positionType: 4 // 4=收货位
                }).then((res) => {
                    if (res.result) {
                        this.positionList = res.data
                        if (this.positionList.length) {
                            this.positionName = this.positionList[0].positionName
                            // 明细设置默认货位
                            this.tableData.forEach(row => {
                                row.positionName = this.positionName
                            })
                        }
                    } else {
                        this.positionList = []
                    }
                });
 
 
                // this.common.ajax(
                //     url,
                //     params,
                //     res => {
                //         if (res.result) {
                //             this.positionList = res.data
                //             if (this.positionList.length) {
                //                 this.formData.positionName = this.positionList[0].positionName
                //                 // 明细设置默认货位
                //                 this.tableData.forEach(row => {
                //                     row.positionName = this.formData.positionName
                //                 })
                //             }
                //         } else {
                //             this.positionList = []
                //         }
                //         // 条码框获得焦点
                //         // this.focus("productModel");
                //     },
                //     false
                // )
 
            },
 
            //pc端代码
            getCheckList(_tableData) {
                var dataList = _tableData
                    .filter(
                        rowData =>
                        rowData.receivedQuantity > 0 &&
                        rowData.receivedQuantity <= rowData.overcharges * rowData.bigQty + rowData.bigQty - rowData
                        .bigEnterQuantity
                    )
                    .map(rowData => {
                        return {
                            orderList_Id: rowData.orderList_Id,
                            positionName: rowData.positionName,
                            produceDate: rowData.produceDate,
                            limitDate: rowData.limitDate,
                            bigQty: rowData.quantity,
                            unitConvert: rowData.unitConvert,
                            quantity: rowData.receivedQuantity,
                            itemNumber: rowData.itemNumber,
                            receivedQuantity: rowData.receivedQuantity,
                            bigEnterQuantity: rowData.bigEnterQuantity,
                            productBarCode: rowData.productBarCode,
                            extendField02: rowData.extendField02,
                            poCode: rowData.poCode,
                            unEnterQuantity: rowData.unEnterQuantity == null ? 1 : rowData.unEnterQuantity,
                            productCode: rowData.productCode,
                            productName: rowData.productName,
                            extendField04: rowData.extendField04,
                            qrCode_guid: rowData.qrCode_guid //增加给后台传递的二维码GUID 【Editby shaocx,2023-11-5】
                        }
                    })
                // 如果是退货的话
                if (this.moveType === '102') {
                    // 本次操作数量小于等于已收数量,并且已收数量不能为0
                    dataList = _tableData
                        .filter(rowData => rowData.receivedQuantity <= rowData.bigEnterQuantity && rowData
                            .bigEnterQuantity > 0)
                        .map(rowData => {
                            return {
                                orderList_Id: rowData.orderList_Id,
                                positionName: rowData.positionName,
                                produceDate: rowData.produceDate,
                                limitDate: rowData.limitDate,
                                bigQty: rowData.quantity,
                                quantity: rowData.receivedQuantity,
                                itemNumber: rowData.itemNumber,
                                receivedQuantity: rowData.receivedQuantity,
                                productBarCode: rowData.productBarCode,
                                extendField02: rowData.extendField02,
                                poCode: rowData.poCode,
                                productCode: rowData.productCode,
                                productName: rowData.productName,
                                extendField04: rowData.extendField04
                            }
                        })
 
                    //if (!dataList.length) {
                    // this.$message.error('退货数量不可超过已收数量!')
                    // this.$refs.sound_error.play() // 播放声音
                    //return
                    // }
 
                }
                return dataList;
            },
            // 上一步
            reset() {
                this.renameFocus = true //页面清空
                this.curFoucus = false // 返回时 自动聚焦清空 单号
                this.DeliveryNoOld = true //禁用单号
                // this.fileList=[]
                // this.fileList1=[]
            },
            beforeDestroy() {
                // 销毁定时器
                if (this.timer) {
                    clearTimeout(this.timer)
                    this.timer = null
                }
 
            },
            // 根据字段 去重
            uniqueByKey(arr, key) {
                let hash = {};
                let result = arr.reduce((total, currentValue) => {
                    if (!hash[currentValue[key]]) { //如果当前元素的key值没有在hash对象里,则可放入最终结果数组
                        hash[currentValue[key]] = true; //把当前元素key值添加到hash对象
                        total.push(currentValue); //把当前元素放入结果数组
                    }
                    return total; //返回结果数组
                }, []);
                return result;
            },
            //类型聚焦事件
            containerFocus2() {
                uni.hideKeyboard()
                this.modalshow2 = true
            },
            //类型选择
            confirm2(index) {
                this.moveType = this.wolist2[index].id
                this.moveTypeName = this.wolist2[index].text
                this.$forceUpdate()
 
            },
            //库位编号
            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;
                        this.sapLocate = dataDst[0].text || ''
                    }
                })
            },
        }
    }
</script>
 
<style lang="scss">
 page {
         width: 100%;
         min-height: 100vh;
         background-color: #F2F2F2;
         box-sizing: border-box;
     }
</style>