小小儁爺
2025-11-19 4898649f875644baced2ccf15929e7e0dbf7851b
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
<template>
    <view>
        <page-nav title="生产报工"></page-nav>
 
 
        <view v-show="topContent.length===0">
            <div class="sacnBody">
                <div class="scanImg" @click="topScanClick"></div>
                <div class="scanText">请扫描任务条码</div>
            </div>
        </view>
 
        <view v-show="topContent.length!==0">
            <view class="mainContent" :style="{maxHeight:'1260rpx',overflow: 'scroll'}">
 
                <!-- 报工信息 -->
                <u-gap height="5" bgColor="#eff0f1"></u-gap>
                <view class="head" style="padding-bottom: 10rpx;">
                    <view class="head_block">
                        <view class="head_left">
                            <view class="head_bar"></view>
                            <view class="head_title">
                                报工信息
                            </view>
                        </view>
 
                    </view>
                    <view class="marginTop20 marginLeft20 marginRight20 flex_between">
                        <u-radio-group class="flex_column">
 
                            <view class="marginBottom20 " v-for="(item,index) in topContent" :key="item.wo_code">
 
                                <view class="flex_between">
                                    <view style="display: flex;">
                                        <view class="flex_column titleFont">
                                            <view>工单编号:</view>
                                            <view>产品编码:</view>
                                            <view>产品名称:</view>
                                            <view>产品规格:</view>
                                            <view>当前工序:</view>
                                            <view>任务数量:</view>
                                            <view>未报/已报:</view>
                                            <view>下道工序:</view>
                                        </view>
                                        <view class="flex_column contentFont">
                                            <view>{{item.wo_code}}</view>
                                            <view>{{item.partnumber}}</view>
                                            <view>{{item.partname}}</view>
                                            <view>{{item.partspec.toString().length===0?'/':item.partspec}}</view>
                                            <view>{{item.stepname}}</view>
                                            <view>{{item.planqty}}</view>
                                            <view>{{item.noreportqty}}/{{item.reportqty}}</view>
                                            <view>{{item.nextstepname?item.nextstepname:'/'}}</view>
                                        </view>
                                    </view>
 
 
                                </view>
 
                            </view>
 
                        </u-radio-group>
                    </view>
                </view>
 
                <!-- 报工操作 -->
                <u-gap height="10" bgColor="#eff0f1"></u-gap>
                <view class="head  marginLeft10 marginRight10" style="padding-bottom: 20rpx;">
                    <view class="head_block">
                        <view class="head_left">
                            <view class="head_bar"></view>
                            <view class="head_title">
                                报工操作
                            </view>
                        </view>
 
                    </view>
                    <view class="flex_column">
 
                        <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                            <view style="display: flex;" class="titleFont">
                                <view style="color: red;margin-right: 6rpx;">*</view> 计件方式:
                            </view>
                            <u-radio-group v-model="reckway" @change='radioGroupChange'>
                                <u-radio shape="circle" label="班组" name="班组" labelSize="16"></u-radio>
                                <u-radio shape="circle" label="个人" style="margin-left: 20rpx;" name="个人" labelSize="16">
                                </u-radio>
                            </u-radio-group>
                        </view>
 
 
                        <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;"
                            v-if="reckway==='班组'">
                            <view style="display: flex;" class="titleFont">
                                <view style="color: red;margin-right: 6rpx;">*</view> 生产班组:
                            </view>
                            <view @click='userGroupSheetClick' class="custominputClass">
                                <view v-show='userGroupSheetValue===""' style="color: rgb(192, 196, 204);">请选择</view>
                                <view v-show='userGroupSheetValue!==""' class="ellipsis" style="width: 390rpx;">
                                    {{userGroupSheetValue}}
                                </view>
                                <u-icon :name="!userGroupSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                            </view>
                        </view>
 
 
                        <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                            <!-- v-if="reckway==='个人'" -->
                            <view style="display: flex;" class="titleFont">
                                <view style="color: red;margin-right: 6rpx;">*</view> 报工人员:
                            </view>
                            <view @click='operSheetClick' class="custominputClass">
                                <view v-show='operSheetValue===""' style="color: rgb(192, 196, 204);">请选择</view>
                                <view v-show='operSheetValue!==""' class="ellipsis" style="width: 390rpx;">
                                    {{operSheetValue}}
                                </view>
 
                                <u-icon :name="!operSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                            </view>
                        </view>
 
 
                        <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                            <view style="display: flex;" class="titleFont">
                                <view style="color: #fff;margin-right: 6rpx;">*</view> 设备名称:
                            </view>
                            <view @click='epqSheetClick' class="custominputClass">
 
                                <view v-show='eqpSheetValue===""' style="color: rgb(192, 196, 204);">请选择</view>
                                <view v-show='eqpSheetValue!==""' class="ellipsis" style="width: 390rpx;">
                                    {{eqpSheetValue}}
                                </view>
 
                                <u-icon :name="!eqpSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                            </view>
                        </view>
 
 
                        <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                            <view style="color: red;margin-right: 6rpx;">*</view> 报工数量:
                            <view class='inputClass'>
                                <u--input placeholder="请输入" :adjustPosition='false' border="surround" type='number'
                                    v-model="reportqty">
                                </u--input>
                            </view>
                        </view>
 
                    </view>
                </view>
 
 
                <u-gap height="10" bgColor="#eff0f1"></u-gap>
 
 
                <view class="head  marginLeft10 marginRight10" style="padding-bottom: 20rpx;">
                    <view class="head_block">
                        <view class="head_left">
                            <view class="head_bar"></view>
                            <view class="head_title">
                                不良统计
                            </view>
                        </view>
 
                    </view>
                    <view class="flex_column ">
 
 
                        <u-button type="primary" :plain="true" icon='plus-circle' text="添加"
                            style="width: 90%;margin: 20rpx auto;" @click="add"></u-button>
 
 
                        <view v-for='(item,index) in ngqtyArr' class="badSheetClass" :key="item.uid">
 
                            <view class="badNumber">{{index+1}}</view>
                            <u-icon name="trash" size="20" class="trash" v-if="ngqtyArr.length!==1"
                                @click="trashDelete(index)" color="rgb(0, 102, 255)"></u-icon>
 
                            <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                                <view style="color: #fff;margin-right: 6rpx;">*</view> 不良数量:
                                <view class='inputClass'>
                                    <u--input placeholder="请输入" border="surround" :adjustPosition='false' type='number'
                                        v-model="item.ngqty"></u--input>
                                </view>
 
                            </view>
                            <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                                <view style="display: flex;" class="titleFont">
                                    <view style="color: #fff;margin-right: 6rpx;">*</view> 不良原因:
                                </view>
                                <view @click='badSheetClick(item)' class="custominputClass">
                                    <view v-show='item.badSheetValue.length===0' style="color: rgb(192, 196, 204);">请选择
                                    </view>
                                    <view v-show='item.badSheetValue.length!==0' class="ellipsis"
                                        style="width: 390rpx;">
                                        {{item.badSheetValue}}
                                    </view>
                                    <u-icon :name="item.arrowDown?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                                </view>
                            </view>
 
                            <u-divider></u-divider>
 
 
                        </view>
 
                    </view>
                </view>
 
 
 
 
            </view>
 
 
 
 
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
 
 
 
 
            <u-button size="large" :loading="isDisabledSubmitButton" loadingText="正在提交,请稍等..." type="primary"
                @click="submit" text="报工">
            </u-button>
 
 
            <!-- 生产班组 -->
            <u-picker v-if="topContent.length!==0" :show="userGroupSheetShow" :columns="userGroupColumns"
                :itemHeight='55' :closeOnClickOverlay='true' @close='userGroupSheetShow=false'
                @confirm='userGroupPickerConfirm' @cancel='userGroupSheetShow=false'>
            </u-picker>
 
            <!--  设备名称 -->
            <u-picker v-if="topContent.length!==0" :show="eqpSheetShow" :columns="eqpColumns" :itemHeight='55'
                :closeOnClickOverlay='true' @close='eqpSheetShow=false' @confirm='eqpPickerConfirm'
                @cancel='eqpSheetShow=false'>
            </u-picker>
 
 
 
            <!-- 不良原因 -->
            <u-action-sheet v-if="topContent.length!==0" :actions="badSelectArr" :safeAreaInsetBottom='true'
                :closeOnClickOverlay="true" :closeOnClickAction="true" @close="badSelectClose" :show="badSheetShow"
                @select='badSheetSelect'>
                <view style="min-height: 100rpx;">
                    <u-checkbox-group @change="checkboxChange" size='20px' v-model="checkBoxValue" iconPlacement="right"
                        placement="column">
                        <view v-for="(item,index) in badSelectArr">
                            <u-checkbox activeColor="rgb(0, 102, 255)" labelSize='18' :key="item.code+index"
                                :name='item.name' :label="item.name">
                            </u-checkbox>
                        </view>
                    </u-checkbox-group>
                </view>
            </u-action-sheet>
 
 
            <!--  报工人员 -->
            <u-action-sheet v-if="topContent.length!==0" :actions="userSelectArrAll" :safeAreaInsetBottom='true'
                :closeOnClickOverlay="true" :closeOnClickAction="true" @close="userSheetShow=false"
                :show="userSheetShow" @select='userSheetSelect'>
                <view style="min-height: 100rpx;padding: 20rpx 20rpx 30rpx 20rpx;">
                    <u-checkbox-group @change="userCheckboxChange" size='20px' v-model="userCheckBoxValue"
                        iconPlacement="right" placement="column">
                        <view v-for="(item,index) in userSelectArrAll">
                            <u-checkbox activeColor="rgb(0, 102, 255)" labelSize='18' :key="item.code+index"
                                :name='item.name' :label="item.name">
                            </u-checkbox>
                        </view>
                    </u-checkbox-group>
                </view>
            </u-action-sheet>
 
            <!-- 报工人员 -->
            <u-picker v-if="topContent.length!==0" :show="operSheetShow" :columns="operColumns" :itemHeight='55'
                :closeOnClickOverlay='true' @close='operSheetShow=false' @confirm='operPickerConfirm'
                @cancel='operSheetShow=false'>
            </u-picker>
 
 
 
 
 
        </view>
 
 
        <!--     <view v-show="topContent.length!==0" style="position: absolute; bottom: 210rpx;right: 20rpx;">
            <div class="scanImg2" @click="topScanClick"></div>
            </div>
        </view> -->
 
        <!-- 悬浮球 -->
        <!--     <view
            v-show="topContent.length!==0&&!userGroupSheetShow&&!eqpSheetShow&&!operSheetShow&&!badSheetShow"
            @click="topScanClick">
            <drag-ball :x='$DeviceInformation.screenWidth*0.8' :y="$DeviceInformation.screenHeight*0.7"></drag-ball>
        </view> -->
 
        <!-- <scan-code></scan-code> -->
    </view>
</template>
 
 
<script>
    import {
        MesOrderStepStart,
        PersonPermissions,
        EqpPermissionsPlus,
        GroupsPermissions,
        GroupsPersonPermissions,
        DefectPermissions,
        SavaMesOrderStepReport,
        LabelBarCode
    } from '../../config/api.js';
    // import scanCode from '@/components/scan-code/scan-code.vue'
    export default {
        // components: {
        // scanCode
        // },
        onLoad(option) {
            if (option.orderstep) {
                this.fromType = '1'
                this.getMesOrderStepStart(option.orderstep)
            } else {
                this.fromType = '2'
            }
 
            // const _this = this
            // uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
            // uni.$on('scancodedate', function(content) {
            //     console.log("扫描到的内容为:", content)
            //     // _this.getMesOrderStepStart(content)
 
            //     if (_this.topContent.find(i => i.wo_code + ';' + i.stepcode === content)) {
            //         _this.$u.toast('此条码已扫描,已在列表中!')
            //     } else {
            //         _this.getMesOrderStepStart(content)
            //     }
            // })
        },
 
        onPullDownRefresh() {
            setTimeout(() => {
                this.init(() => {
                    uni.stopPullDownRefresh();
                })
            }, 1000);
        },
 
        data() {
            return {
                topRightMessageCount: 0,
                isDisabledSubmitButton: false,
 
                formData: {},
 
                reckway: '个人', //计件方式    group代表是班组   person 代表是个人
                userGroupSheetValue: '', //生产班组下拉选中的值
                eqpSheetValue: '', //设备名称下拉选中的值
                userGroupSheetList: [], //生产班组下拉数组
                eqpSheetList: [], //设备名称下拉数组
                userGroupSheetShow: false, //上拉列表是否展开
                eqpSheetShow: false,
                topContent: [
                    //     {
                    //     nextstepcode: "GX005",
                    //     nextstepname: "入库",
                    //     noputqty: 0,
                    //     noreportqty: 100,
                    //     partname: "8504光机",
                    //     partnumber: "302",
                    //     partspec: "/",
                    //     planqty: 100,
                    //     reportqty: 0,
                    //     seq: "1",
                    //     startqty: 100,
                    //     stepcode: "GX001",
                    //     stepdesc: "",
                    //     stepname: "领料",
                    //     wo_code: "MO-2022-11-0035_1",
                    // },
                ],
 
                reportqty: '', //报工数量
 
                ngqty: '', //不良数量
 
                ngqtyArr: [{
                        uid: new Date().getTime(),
                        ngqty: '',
                        badSheetValue: '',
                        arrowDown: true //向下箭头
                    },
                    // {
                    //     ngqty: '',
                    //     badSheetValue: '',
                    //     arrowDown: true //向下箭头
                    // },
                ], //不良数量、不良原因数组
 
 
 
 
                badSelectArr: [], //不良原因下拉数组
                badSheetValue: '', //不良原因选中值
                badSheetShow: false,
                checkBoxValue: [], //不良原因显示值
                operSheetValue: '', //操作人员选中值
                operSheetShow: false,
                operSheetList: [], //操作人员数组
                userArr: [], //报工人员信息数组
 
 
                userSelectValue: '', //下拉选项值
                userSelectArrAll: [], //所有人员下拉数组
                userSelectArr: [
                    // {
                    //     value: '1001',
                    //     text: '小美1'
                    // },
                ], //人员下拉数组
                userGroupColumns: [], //
                eqpColumns: [], //
                operColumns: [], //
                isAsyncChange: false,
 
                userCheckBoxValue: [],
                userSheetShow: false,
 
                fromType: '1', //来源于哪里   是页面1还是2
            }
        },
        created() {
 
        },
        mounted() {
            this.init()
 
            // this.getMesOrderStepStart('MO-2024-01-0004_1;102')
 
            this.getSellectAllApi()
        },
        methods: {
            init() {
                uni.stopPullDownRefresh();
            },
            async getSellectAllApi() {
                await this.getGroupsPermissions() //获取生产班组
                await this.getEqpPermissionsPlus() //获取设备名称
                await this.getDefectPermissions() //获取缺陷下拉
                await this.getPersonPermissions() //获取操作人员
            },
 
 
            //获取生产班组
            async getGroupsPermissions(wkshopcode) {
 
                const res = await GroupsPermissions()
                if (res.code === '200') {
                    // 数组对象  替换对象键名
                    this.userGroupSheetList = res.data.map(({
                        usergroupcode,
                        usergroupname
                    }) => ({
                        code: usergroupcode,
                        name: usergroupname
                    }))
 
                    this.userGroupColumns = [this.userGroupSheetList.map(i => i.name)]
                }
            },
            // 获取设备名称
            async getEqpPermissionsPlus() {
                const res = await EqpPermissionsPlus()
                if (res.code === '200') {
                    this.eqpSheetList = res.data
                    this.eqpColumns = [this.eqpSheetList.map(i => i.name)]
                }
            },
            // 获取不良原因
            async getDefectPermissions(orderstepqrcode) {
                const res = await DefectPermissions()
                if (res.code === '200') {
                    this.badSelectArr = res.data
                }
            },
            // 获取报工人员
            async getPersonPermissions() {
                const res = await PersonPermissions()
                if (res.code === '200') {
                    // this.operSheetList = res.data
                    this.operSheetList = res.data.map(({
                        usercode,
                        username,
                        payrate
                    }) => ({
                        code: usercode,
                        name: username,
                        payrate: payrate
                    }))
                    this.operColumns = [this.operSheetList.map(i => i.name)]
                    this.userSelectArrAll = this.operSheetList
                }
            },
            // 根据生产班组获取人员
            async getGroupsPersonPermissions(groupcode) {
 
                const res = await GroupsPersonPermissions({
                    groupcode
                })
                if (res.code === '200') {
                    this.userCheckBoxValue = []
 
                    if (res.data[0].usercode_list && res.data[0].usercode_list.length > 0) {
                        this.userSelectArrAll.forEach(i => {
 
                            if (res.data[0].usercode_list.split(',').includes(i.code)) {
                                this.userCheckBoxValue.push(i.name)
                            }
 
                        })
 
                    }
 
                    this.operSheetValue = this.userCheckBoxValue.join(',')
 
 
                }
            },
 
 
 
            userSheetSelect() {
 
            },
            userCheckboxChange(val) {
                this.userCheckBoxValue = val.join(',')
            },
 
            //获取开工信息
            async getMesOrderStepStart(orderstepqrcode) {
                const data = {
                    OperType: 'ZZ',
                    SelectType: '',
                    wocode: orderstepqrcode ? orderstepqrcode.split(';')[0] : '',
                    stepcode: orderstepqrcode ? orderstepqrcode.split(';')[1] : ''
 
                }
                const res = await MesOrderStepStart(this.global.formatData(data))
                if (res.code === '200' && res.count === 1) {
                    this.formData = res.data
                    this.topContent.unshift(res.data)
                } else if (res.code === '200' && res.count !== 1) {
                    this.$u.toast('此工序已报工!')
                }
 
            },
            // 扫码事件
            topScanClick() {
                let that = this;
 
                uni.scanCode({
                    onlyFromCamera: true,
                    // scanType: ['barCode', 'qrCode'],
                    scanType: ['qrCode'],
                    success: function(res) {
                        console.log('条码类型:' + res.scanType);
                        console.log('条码内容:' + res.result);
 
                        if (that.topContent.find(i => i.wo_code + ';' + i.stepcode === res.result)) {
                            that.$u.toast('此条码已扫描,已在列表中!')
                        } else {
                            that.getMesOrderStepStart(res.result)
                        }
 
                    },
                    complete: function(res) {
 
                    },
                    fail: function(res) {
                        console.log('条码类型:' + res.scanType);
                        console.log('条码内容:' + res.result);
                    }
 
                });
            },
 
            async submit() {
                // 下午写生产报工提交
 
                if (this.reckway === '班组' && this.userGroupSheetValue === "") {
                    return uni.$u.toast('生产班组不能为空!')
                }
                if (this.reckway === '个人' && this.operSheetValue === "") {
                    return uni.$u.toast('报工人员不能为空!')
                }
                // if (this.eqpSheetValue === "") {
                //     return uni.$u.toast('设备名称不能为空!')
                // }
                if (this.reportqty === "") {
                    return uni.$u.toast('报工数量不能为空!')
                }
 
                if (this.reckway === '班组' && this.operSheetValue.length === 0) {
                    return uni.$u.toast('报工人员信息不能为空!')
                }
 
                let badcode = []
 
                if (this.badSheetValue.length > 0) {
                    this.badSelectArr.forEach(i => {
                        if (this.badSheetValue.split(',').includes(i.name)) {
                            badcode.push(i.code)
                        }
                    })
                }
 
                let reportuser = []
 
                if (this.operSheetValue.length > 0) {
                    this.userSelectArrAll.forEach(i => {
                        if (this.operSheetValue.split(',').includes(i.name)) {
                            reportuser.push(i.code)
                        }
                    })
                }
 
                // 不良原因
                const defectlist = []
                //不良数量
                let ngqtyNumber = 0
 
                this.ngqtyArr.forEach(i => {
                    if (i.badSheetValue.toString().length > 0) {
                        let codeArr = []
                        ngqtyNumber += parseFloat(i.ngqty)
                        i.badSheetValue.split(',').forEach(j => {
                            codeArr.push(this.badSelectArr.find(i => i.name === j).code)
                        })
                        defectlist.push({
                            badqty: i.ngqty,
                            defect_code: codeArr.join(',')
                        })
                    }
                })
 
 
                if (parseFloat(this.reportqty) + parseFloat(ngqtyNumber) > parseFloat(this.topContent[0]
                        .noreportqty)) {
                    return uni.$u.toast('报工数量加不良数量不能大于未报数量!')
                }
 
 
 
 
                const D = {
                    rightcode: '0601',
                    partcode: this.topContent[0].partnumber,
                    qty: parseFloat(this.reportqty),
                    onelabqty: parseFloat(this.reportqty)
                }
                const {
                    data: R
                } = await LabelBarCode(D)
 
 
                const data = {
                    mesordercode: this.topContent[0].wo_code,
                    partcode: this.topContent[0].partnumber,
                    stepseq: this.topContent[0].seq,
                    stepcode: this.topContent[0].stepcode,
                    stepprice: this.topContent[0].stepprice,
 
                    eqpcode: this.eqpSheetValue ? this.eqpSheetList.find(i => i.name === this.eqpSheetValue).code :
                        '',
 
                    reckway: this.reckway === '班组' ? 'group' : 'person',
 
                    usergroupcode: this.userGroupSheetValue ? this.userGroupSheetList.find(i => i.name === this
                        .userGroupSheetValue).code : '', // 班组编码
                    reportuser: this.reckway === '班组' ? reportuser.join(',') : this.userSelectArrAll.find(i => i
                        .name === this.operSheetValue).code,
                    payrate: this.reckway === '班组' ? reportuser.join(',') : this.userSelectArrAll.find(i => i
                        .name === this.operSheetValue).payrate,
                    taskqty: this.topContent[0].planqty,
                    startqty: parseFloat(this.reportqty),
                    reportqty: parseFloat(this.reportqty),
                    inbarcode: R[0].labcode, //入库条码
                    defectlist,
                    // defectlist: badcode.length > 0 ? [{
                    //     defect_code: badcode.join(','),
                    //     badqty: this.ngqty
                    // }] : [],
                    remarks: ''
                }
 
                // console.log(JSON.parse(JSON.stringify(data)), 7777)
                this.isDisabledSubmitButton = true
                const res = await SavaMesOrderStepReport(data)
                if (res.code === '200') {
                    uni.$u.toast('报工成功!')
                    this.topContent = []
                    this.formData = {}
                    this.reportqty = ''
                    // this.ngqty = ''
                    this.reckway = '个人'
                    this.userGroupSheetValue = ''
                    this.eqpSheetValue = ''
 
 
                    this.ngqtyArr = [{
                        uid: new Date().getTime(),
                        ngqty: '',
                        badSheetValue: '',
                        arrowDown: true //向下箭头
                    }]
 
                    // this.userGroupSheetList = []
                    // this.eqpSheetList = []
                    // this.badSelectArr = []
                    this.badSheetValue = []
                    this.checkBoxValue = []
                    this.operSheetValue = ''
                    // this.operSheetList = []
                    // this.userArr = []
                    this.userSelectValue = ''
                    // this.userSelectArrAll = []
                    // this.userSelectArr = []
                    // this.userGroupColumns = []
                    // this.eqpColumns = []
                    // this.operColumns = []
 
                    this.userCheckBoxValue = []
                    this.userSheetShow = false
 
 
                    if (this.fromType === '1') {
                        let pages = getCurrentPages(); // 页面集合
                        let beforePage = pages[pages.length - 2]; //上一个页面
                        beforePage.$vm.getProductionScheduleKanban()
 
                        uni.navigateBack()
                    }
 
 
                    this.isDisabledSubmitButton = false
                }
 
 
 
 
 
            },
            userGroupSheetSelect(val) {
                this.userGroupSheetValue = val.name
                this.userGroupSheetShow = false
            },
            userGroupSheetClick() {
                this.userGroupSheetShow = true
            },
            eqpSheetSelect(val) {
                this.eqpSheetValue = val.name
                this.eqpSheetShow = false
            },
            epqSheetClick() {
                this.eqpSheetShow = true
            },
            badSheetSelect(val) {
                // console.log(val,9999999)
            },
            badSheetClick(item) {
                if (!item.ngqty) {
                    return uni.$u.toast('请先填写不良数量!')
                }
                item.arrowDown = !item.arrowDown
 
                this.checkBoxValue = item.badSheetValue.split(',')
                this.badSheetShow = true
            },
 
            badSelectClose() {
                let index = this.ngqtyArr.findIndex(i => !i.arrowDown)
 
                this.ngqtyArr[index].badSheetValue = this.checkBoxValue.join(',')
                this.ngqtyArr[index].arrowDown = true
 
                this.checkBoxValue = []
                this.badSheetShow = false
            },
 
            checkboxChange(val) {
                this.badSheetValue = val.join(',')
            },
            operSheetClick() {
                if (this.reckway === '个人') {
                    this.operSheetShow = true
                }
 
                if (this.reckway === '班组') {
                    this.userSheetShow = true
                }
            },
            //单选框值改变时
            radioGroupChange(val) {
                this.userGroupSheetValue = ''
                this.operSheetValue = ''
            },
 
            // 添加
            add() {
 
                if (this.ngqtyArr.find(i => i.badSheetValue === '')) {
                    return uni.$u.toast('请先完善前面不良选项!')
                }
 
                this.ngqtyArr.unshift({
                    uid: new Date().getTime(),
                    ngqty: '',
                    badSheetValue: '',
                    arrowDown: true //向下箭头
                })
 
            },
 
            //删除
            trashDelete(index) {
                console.log(index)
                this.ngqtyArr.splice(index, 1)
 
            },
 
 
            userChange(val) {
                this.userSelectValue = val
            },
            userGroupPickerConfirm(val) {
                console.log(val, 11)
                this.getGroupsPersonPermissions(this.userGroupSheetList.find(i => i.name === val.value[0]).code)
                this.userGroupSheetValue = val.value[0]
                this.userGroupSheetShow = false
            },
            eqpPickerConfirm(val) {
                this.eqpSheetValue = val.value[0]
                this.eqpSheetShow = false
            },
            operPickerConfirm(val) {
                this.operSheetValue = val.value[0]
                this.operSheetShow = false
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    @import url('@/style/global.css');
 
    ::v-deep .uicon-arrow-left>span {
        display: block;
    }
 
    .custominputClass {
        width: 412rpx;
        display: flex;
        justify-content: space-between;
        border: 3rpx #eff0f1 solid;
        border-radius: 10rpx;
        padding: 0 16rpx;
 
    }
 
    .ellipsis {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }
 
    .scanImg2 {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin: auto;
        background: url('@/static/img/scan.png') no-repeat;
        box-shadow: #436df5 0px 0px 20px;
        background-size: 100% 100%;
    }
 
    ::v-deep .addClass .uicon-plus-circle {
        font-size: 50rpx !important;
        margin-right: 20rpx !important;
    }
 
    ::v-deep .addClass .u-button__text {
        font-size: 46rpx !important;
    }
 
 
    ::v-deep .u-modal__content {
        padding-bottom: 260rpx;
        margin-bottom: 100rpx;
    }
 
    ::v-deep .u-action-sheet {
        max-height: 600rpx !important;
        overflow: auto !important;
    }
 
    ::v-deep .u-checkbox-label--right {
        padding: 30rpx;
        border-bottom: 1rpx solid #eee;
    }
 
 
 
    .badSheetClass {
        position: relative;
    }
 
    .badNumber {
        position: absolute;
        top: 20rpx;
        left: 20rpx;
        font-size: 26rpx;
        color: rgb(0, 102, 255)
    }
 
    .trash {
        position: absolute;
        top: 20rpx;
        right: 30rpx;
        font-size: 26rpx;
    }
</style>