小小儁爺
2025-06-13 889d80d88abd7b4a60846678624f4b976c15f820
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
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
<template>
  <div>
    <div class="body" style="padding-top: 10px;" :style="{height:mainHeight+'px'}">
 
      <div style="position: absolute;right:36px;z-index: 2;top: 13px">
        <el-button
          v-if="activeName==='生产列表'&&tableData.length>0"
          v-waves
          icon="el-icon-thumb"
          type="primary"
          :disabled="radioSelected===''"
          @click="report()"
        >报工
        </el-button>
        <el-button
          v-if="activeName==='外协发料'&&tableData.length>0"
          v-waves
          type="primary"
          icon="el-icon-thumb"
          :disabled="radioSelected===''"
          @click="sendOut()"
        >发料
        </el-button>
        <el-button
          v-if="activeName==='外协收料'&&tableData.length>0"
          v-waves
          type="primary"
          icon="el-icon-thumb"
          :disabled="radioSelected===''"
          @click="takeIn()"
        >收料
        </el-button>
        <el-button
          v-if="activeName==='不良待处理'&&tableData.length>0"
          v-waves
          type="primary"
          icon="el-icon-thumb"
          :disabled="radioSelected===''"
          @click="handleBad()"
        >处理
        </el-button>
      </div>
 
      <div v-if="form.wocode" style="position: absolute;left: 460px;z-index: 2;top: 23px;font-weight: bolder">
        当前工单号为:{{ form.wocode }}
      </div>
 
      <el-tabs
        ref="elTabs"
        v-model="activeName"
        type="border-card"
        @tab-click="tabClick"
      >
 
        <el-tab-pane
          v-for="item in elTabsArr"
          :key="item.code"
          :label="item.name"
          :name="item.name"
        >
 
          <div class="bodyTopFormGroup">
            <el-form
              ref="form"
              :model="form"
              label-width="100px"
              inline
              style="display: flex;"
            >
              <div class="elForm">
 
                <el-form-item label="工单号" style=" display: flex;">
                  <el-input
                    v-model="workOrderCurrentValue"
                    :name="'produceCode'+item.code"
                    placeholder="请扫描或输入"
                    style="width: 300px"
 
                    @keyup.enter.native="val=>enterNative(val,'produceCode' + item.code)"
                  />
                </el-form-item>
                <el-form-item label="产品编码" style=" display: flex;">
                  <el-input
                    v-model="form.partcode"
                    placeholder="请输入"
                    style="width: 200px"
 
                    @keyup.enter.native="val=>enterNative(val,'produceCode' + item.code)"
                  />
                </el-form-item>
                <el-form-item label="产品名称" style=" display: flex;">
                  <el-input
                    v-model="form.partname"
                    placeholder="请输入"
 
                    style="width: 200px"
                    @keyup.enter.native="val=>enterNative(val,'produceCode' + item.code)"
                  />
                </el-form-item>
                <el-form-item label="车间名称" style=" display: flex;">
                  <el-select
                    v-model="form.wkshopcode"
                    filterable
                    :popper-append-to-body="false"
                    style="width: 200px"
 
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in wkshopcodeArr"
                      :key="item.torg_code"
                      :label="item.torg_name"
                      :value="item.torg_code"
                    />
                  </el-select>
                </el-form-item>
 
                <!--                <el-form-item label="规格型号" style=" display: flex;">-->
                <!--                  <el-input v-model="form.partspec" placeholder="请输入" style="width: 200px" />-->
                <!--                </el-form-item>-->
 
              </div>
              <div
                class="bodySearchReset"
                :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
              >
                <el-button v-waves type="primary" icon="el-icon-search" @click="search">查询</el-button>
                <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
              </div>
            </el-form>
            <div
              class="bodyTopFormExpand"
              style="height:5px"
            >
              <!--          <svg-icon-->
              <!--            v-show="mouseHoverType==='mouseout'"-->
              <!--            style="cursor: pointer"-->
              <!--            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
              <!--            @mouseenter="mouseHoverType=$event.type"-->
              <!--          />-->
              <!--          <svg-icon-->
              <!--            v-show="mouseHoverType==='mouseenter'"-->
              <!--            style="cursor: pointer"-->
              <!--            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
              <!--            @click="isExpandForm=!isExpandForm"-->
              <!--            @mouseout="mouseHoverType=$event.type"-->
              <!--          />-->
            </div>
          </div>
 
          <div class="elTableDiv">
            <el-table
              ref="tableDataRef"
              :key="'tableDataRef'+item.code"
              class="tableFixed"
              :data="tableData"
              :height="tableHeight+50"
              border
              row-class-name="custom-row"
              :style="{width: 100+'%',height:tableHeight+'px'}"
              highlight-current-row
              :header-cell-style="headerCellStyle()"
              :cell-style="cellStyle()"
              @sort-change="sortChange"
              @row-click="rowClick"
            >
              <el-table-column
                width="50"
                fixed
              >
                <template slot-scope="{row}">
                  <el-radio
                    v-model="radioSelected"
                    :label="row.id"
                    style="color: transparent;padding-left: 10px;"
                  />
                </template>
              </el-table-column>
              <el-table-column
                prop="rowNum"
                width="50"
                label="序号"
                fixed
              />
              <el-table-column
                v-if="activeName!=='不良待处理'"
                prop="status"
                show-tooltip-when-overflow
                label="状态"
                sortable="custom"
                width="80"
              >
                <template slot-scope="{row}">
                  <div v-if="row.status==='NEW'">新订单</div>
                  <div v-if="row.status==='ALLO'">已派发</div>
                  <div v-if="row.status==='START'">开工</div>
                  <div v-if="row.status==='CLOSED'">完工</div>
                  <div v-if="row.status==='NOSCHED'">待排程</div>
                  <div v-if="row.status==='SCHED'">已排程</div>
                </template>
              </el-table-column>
              <el-table-column
                prop="wo_code"
                label="工单号"
                min-width="160"
                show-tooltip-when-overflow
                sortable="custom"
              />
              <el-table-column
                prop="partcode"
                label="产品编码"
                min-width="110"
                sortable="custom"
                show-tooltip-when-overflow
              />
              <el-table-column
                prop="partname"
                min-width="110"
                show-tooltip-when-overflow
                label="产品名称"
                sortable="custom"
              />
              <el-table-column
                prop="partspec"
                min-width="110"
                show-tooltip-when-overflow
                label="规格型号"
                sortable="custom"
              >
                <template slot-scope="{row}">
                  {{ row.partspec ? row.partspec : '/' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="wkshp_name"
                min-width="110"
                show-tooltip-when-overflow
                label="车间名称"
                sortable="custom"
              />
              <el-table-column
                prop="stepname"
                label="工序名称"
                show-tooltip-when-overflow
                width="120"
                sortable="custom"
              />
              <el-table-column
                prop="plan_qty"
                label="任务数量"
                width="110"
                sortable="custom"
                show-tooltip-when-overflow
              />
              <el-table-column
                v-if="activeName==='外协发料'||activeName==='外协收料'"
                prop="fqty"
                show-tooltip-when-overflow
                label="已发料数量"
                sortable="custom"
                width="120"
              />
              <el-table-column
                prop="good_qty"
                show-tooltip-when-overflow
                :label="activeName==='外协发料'||activeName==='外协收料'?'已收料数量':'合格数量'"
                sortable="custom"
                width="120"
              />
              <el-table-column
                prop="ng_qty"
                label="不良数量"
                show-tooltip-when-overflow
                width="120"
                sortable="custom"
              />
              <el-table-column
                prop="laborbad_qty"
                label="工废数量"
                width="120"
                show-tooltip-when-overflow
                sortable="custom"
              />
              <el-table-column
                prop="materielbad_qty"
                label="料废数量"
                width="120"
                show-tooltip-when-overflow
                sortable="custom"
              />
 
              <el-table-column
                label="操作"
                width="120"
                fixed="right"
              >
                <template slot-scope="{row}">
                  <div class="operationClass">
                    <el-button v-if="activeName==='生产列表'" v-waves icon="el-icon-thumb" type="text" @click="report(row)">
                      报工
                    </el-button>
                    <el-button
                      v-if="activeName==='外协发料'"
                      v-waves
                      icon="el-icon-thumb"
                      type="text"
                      @click="sendOut(row)"
                    >发料
                    </el-button>
                    <el-button v-if="activeName==='外协收料'" v-waves icon="el-icon-thumb" type="text" @click="takeIn(row)">
                      收料
                    </el-button>
                    <el-button
                      v-if="activeName==='不良待处理'"
                      v-waves
                      icon="el-icon-thumb"
                      type="text"
                      @click="handleBad(row)"
                    >处理
                    </el-button>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!--分页-->
          <pagination
            :total="total"
            :page.sync="form.page"
            :limit.sync="form.rows"
            align="right"
            layout="total,prev, pager, next,sizes"
            popper-class="select_bottom"
            @pagination="search"
          />
        </el-tab-pane>
 
      </el-tabs>
 
    </div>
 
    <!--    开报工、外协、不良处理-->
    <el-dialog
      v-el-drag-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="1160px"
      :close-on-click-modal="false"
      :top="activeName==='生产列表'||activeName==='外协收料'? '6vh':'15vh'"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="110px">
        <!--        <el-divider v-if="activeName==='生产列表'||activeName==='外协收料'||activeName==='不良待处理'" content-position="left">基本信息</el-divider>-->
        <el-divider v-if="activeName==='生产列表'" content-position="left">报工信息</el-divider>
        <el-divider v-if="activeName==='外协收料'" content-position="left">收料信息</el-divider>
        <el-divider v-if="activeName==='不良待处理'" content-position="left">待处理信息</el-divider>
        <el-form-item label="工单编号" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.wo_code }}</div>
        </el-form-item>
        <el-form-item label="产品编码" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.partnumber }}</div>
        </el-form-item>
        <el-form-item label="产品名称" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.partname }}</div>
        </el-form-item>
        <el-form-item label="规格型号" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.partspec ? dialogForm.partspec : '/' }}</div>
        </el-form-item>
        <el-form-item label="当前工序" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.stepname }}</div>
        </el-form-item>
        <el-form-item label="下道工序" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.nextstepname ? dialogForm.nextstepname : '/' }}</div>
        </el-form-item>
        <el-form-item label="任务数量" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.planqty }}</div>
        </el-form-item>
 
        <el-form-item v-if="activeName==='不良待处理'" label="合格数量" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.noreportqty }}</div>
        </el-form-item>
        <el-form-item v-if="activeName==='不良待处理'" label="不良数量" class="dialogFormItem">
          <div class="dialogFormItemDiv">{{ dialogForm.noputqty }}</div>
        </el-form-item>
 
        <el-form-item
          v-if="activeName!=='不良待处理'"
          :label="activeName==='生产列表'? '未报/已报':(activeName==='外协发料'?'未发/已发':'未收/已收')"
          class="dialogFormItem"
        >
          <div class="dialogFormItemDiv">{{ dialogForm.noreportqty + '/' + dialogForm.reportqty }}</div>
        </el-form-item>
 
        <el-form-item v-if="activeName==='生产列表'||activeName==='外协收料'" label="不良数量" class="dialogFormItem">
          <div class="dialogFormItemDiv" style="color:red;">{{ dialogForm.noputqty }}</div>
        </el-form-item>
 
        <el-form-item v-if="activeName==='生产列表'" label="报工设备" class="dialogFormItem">
          <el-select
            v-model="dialogForm.eqpcode"
            style="width:200px"
            placeholder="请选择"
            filterable
            clearable
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in eqpArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
 
        <el-form-item v-if="activeName==='生产列表'" label="计件方式" class="dialogFormItem">
          <el-radio-group
            v-model="dialogForm.reckway"
            style="width: 200px;"
            @change="reckwayChange"
          >
            <el-radio label="person">个人</el-radio>
            <el-radio label="group">班组</el-radio>
          </el-radio-group>
        </el-form-item>
 
        <el-form-item
          v-if="activeName==='生产列表'"
          :prop="dialogForm.reckway==='group'?'usergroupcode':''"
          label="报工班组"
          class="dialogFormItem"
        >
          <el-select
            v-model="dialogForm.usergroupcode"
            style="width:200px"
            placeholder="请选择"
            filterable
            :disabled="dialogForm.reckway!=='group'"
            :popper-append-to-body="false"
            @change="usergroupChange"
          >
            <el-option
              v-for="item in usergroupArr"
              :key="item.usergroupcode"
              :label="item.usergroupname"
              :value="item.usergroupcode"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="activeName==='生产列表'" prop="reportuser" label="报工人员" class="dialogFormItem">
          <el-select
            v-model="dialogForm.reportuser"
            style="width:200px"
            placeholder="请选择"
            filterable
            multiple
            collapse-tags
            :multiple-limit="dialogForm.reckway==='group'?0:1"
            :disabled="dialogForm.reckway==='group'&&dialogForm.usergroupcode===''"
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in reportuserArr"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="activeName==='生产列表'" prop="startqty" label="合格数量" class="dialogFormItem">
          <el-input v-model="dialogForm.startqty" oninput="value=value.replace(/[^\d]/g,'')" style="width: 200px" />
        </el-form-item>
 
        <el-form-item v-if="activeName==='外协发料'||activeName==='外协收料'" prop="wxcode" label="外协供方" class="dialogFormItem">
          <el-select
            v-model="dialogForm.wxcode"
            style="width:200px"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in wxArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="activeName==='外协发料'" prop="outuser" label="发料人员" class="dialogFormItem">
          <el-select
            v-model="dialogForm.outuser"
            style="width:200px"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in reportuserArr"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="activeName==='外协发料'" prop="fqty" label="发料数量" class="dialogFormItem">
          <el-input v-model="dialogForm.fqty" oninput="value=value.replace(/[^\d]/g,'')" style="width: 200px" />
        </el-form-item>
 
        <el-form-item v-if="activeName==='外协收料'" prop="inuser" label="收料人员" class="dialogFormItem">
          <el-select
            v-model="dialogForm.inuser"
            style="width:200px"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in reportuserArr"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="activeName==='外协收料'" prop="sqty" label="收料数量" class="dialogFormItem">
          <el-input v-model="dialogForm.sqty" oninput="value=value.replace(/[^\d]/g,'')" style="width: 200px" />
        </el-form-item>
 
        <el-divider v-if="activeName==='生产列表'||activeName==='外协收料'" content-position="left">不良明细信息</el-divider>
        <el-button
          v-if="activeName==='生产列表'||activeName==='外协收料'"
          v-waves
          type="primary"
          icon="el-icon-circle-plus-outline"
          @click="addDefect"
        >新增
        </el-button>
        <el-table
          v-if="activeName==='生产列表'||activeName==='外协收料'"
          ref="defectTableDataRef"
          key="defectTableDataKey"
          :data="defectTableData"
          border
          row-class-name="custom-row"
          height="200"
          style="width: 100%;margin-top: 15px;"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            type="index"
            label="序号"
            align="center"
            width="50"
          />
          <el-table-column
            prop="stepcode"
            label="缺陷编码/名称"
            align="center"
            min-width="450"
          >
            <template slot-scope="{row}">
              <el-select
                v-model="row.code"
                style="width: 100%"
                placeholder="请选择"
                multiple
                filterable
              >
                <!--                collapse-tags-->
                <el-option
                  v-for="item in defectArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </template>
          </el-table-column>
 
          <el-table-column
            prop="badqty"
            label="不良数量"
            align="center"
          >
            <template slot-scope="{row}">
              <el-input
                v-model="row.badqty"
                placeholder="请输入数量"
                oninput="value=value.replace(/[^0-9]/g,'')"
                style="width: 100%"
                @click.stop=""
                @change="badqtyChange"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            width="50"
            align="center"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i
                    class="el-icon-delete"
                    :style="{color:$store.state.settings.theme}"
                    style="margin-left: 7px;"
                    @click="defectDel(row)"
                  />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
 
        <el-divider v-if="activeName==='外协收料'" content-position="left">可收料供应商</el-divider>
        <div
          v-for="(item,index) in dialogForm.list"
          v-if="item.fqty>0"
          :key="item.name"
          style="display: flex;line-height: 26px;height: 26px;margin-left:30px;align-items: center"
        >
          <div
            style="color: #fff;width: 22px;height: 22px;display: flex;justify-content: center;align-items: center;border-radius: 50%"
            :style="{backgroundColor:$store.state.settings.theme}"
          >{{ index + 1 }}
          </div>
          <div style="margin-left:30px;width: 160px;" class="ellipsis">
            {{ item.tp }}
          </div>
          <div style="margin-left:30px;">
            可收数量:{{ item.acceptQty }}
          </div>
        </div>
 
        <el-divider v-if="activeName==='不良待处理'" content-position="left">不良信息明细</el-divider>
        <el-table
          v-if="activeName==='不良待处理'"
          ref="badTableDataDataRef"
          key="badTableDataDataKey"
          :data="badTableData"
          border
          row-class-name="custom-row"
          height="300"
          style="width: 100%;margin-top: 15px;"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            type="index"
            label="序号"
            align="center"
            width="50"
          />
          <!--          <el-table-column-->
          <!--            prop="step_code"-->
          <!--            label="工序编码"-->
          <!--            show-tooltip-when-overflow-->
          <!--            align="center"-->
          <!--          />-->
          <el-table-column
            prop="stepname"
            label="工序名称"
            show-tooltip-when-overflow
            align="center"
          />
          <el-table-column
            prop="plan_qty"
            label="任务数量"
            show-tooltip-when-overflow
            align="center"
          />
          <el-table-column
            prop="report_qty"
            label="合格数量"
            show-tooltip-when-overflow
            align="center"
          />
          <el-table-column
            prop="ng_qty"
            label="不良数量"
            show-tooltip-when-overflow
            align="center"
          />
          <el-table-column
            prop="defect_name"
            label="不良原因"
            show-tooltip-when-overflow
            align="center"
          />
          <el-table-column
            prop="repair_qty"
            label="维修合格数量"
            align="center"
          >
            <template slot-scope="{row}">
              <el-input
                v-model="row.repair_qty"
                placeholder="请输入数量"
                oninput="value=value.replace(/[^0-9]/g,'')"
                style="width: 100%"
                @click.stop=""
              />
            </template>
          </el-table-column>
          <el-table-column
            prop="laborbad_qty"
            label="工废数量"
            align="center"
          >
            <template slot-scope="{row}">
              <el-input
                v-model="row.laborbad_qty"
                placeholder="请输入数量"
                oninput="value=value.replace(/[^0-9]/g,'')"
                style="width: 100%"
                @click.stop=""
              />
            </template>
          </el-table-column>
          <el-table-column
            prop="materielbad_qty"
            label="料废数量"
            align="center"
          >
            <template slot-scope="{row}">
              <el-input
                v-model="row.materielbad_qty"
                placeholder="请输入数量"
                oninput="value=value.replace(/[^0-9]/g,'')"
                style="width: 100%"
                @click.stop=""
              />
            </template>
          </el-table-column>
 
          <!--          <el-table-column-->
          <!--            prop="badqty"-->
          <!--            label="不良数量"-->
          <!--            show-tooltip-when-overflow-->
          <!--            align="center"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <el-input-->
          <!--                v-model="row.badqty"-->
          <!--                placeholder="请输入数量"-->
          <!--                oninput="value=value.replace(/[^0-9]/g,'')"-->
          <!--                style="width: 100%"-->
          <!--                @click.stop=""-->
          <!--                @change="badqtyChange"-->
          <!--              />-->
          <!--            </template>-->
          <!--          </el-table-column>-->
 
          <!--          <el-table-column-->
          <!--            label="操作"-->
          <!--            width="50"-->
          <!--            align="center"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div class="operationClass">-->
          <!--                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">-->
          <!--                  <i-->
          <!--                    class="el-icon-delete"-->
          <!--                    :style="{color:$store.state.settings.theme}"-->
          <!--                    style="margin-left: 7px;"-->
          <!--                    @click="defectDel(row)"-->
          <!--                  />-->
          <!--                </el-tooltip>-->
          <!--              </div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
 
        </el-table>
      </el-form>
 
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleCancel">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
 
    <!--    流转小标签打印-->
    <!--打印预览页面  小标签-->
    <el-dialog
      v-el-drag-dialog
      title="预览"
      :visible.sync="dialogVisible2"
      width="1140"
      top="10vh"
      :close-on-click-modal="false"
      @close="dialogVisible2Close"
    >
      <!-- 要打印的区域 -->
      <div id="printMe2" style="padding: 30px;">
        <div
          style="display: flex;width: 280px;height: 150px;border: 1px solid #000;text-align: center;font-size: 10px;"
        >
 
          <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
            <div
              style="display: flex;height: 90px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
            >
              <div id="qrCode2" ref="qrCodeDiv2" style="overflow-y: hidden;height:60px;position: absolute;left: 14px;" />
            </div>
            <div
              style="display: flex;height: 30px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
            >
              <div style="margin-left: 5px;width: 28px">数量:</div>
              {{ qrForm.startqty }}
            </div>
            <div style="display: flex;height: 30px;justify-content: flex-start;align-items: center">
              <div style="margin-left: 5px;width: 42px">处理人:</div>
              {{ qrForm.operator }}
            </div>
          </div>
 
          <div style="width:190px;display: flex;flex-direction: column">
            <div
              style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
            >
              <div style="width: 60px;margin-left: 5px;">工单编号:</div>
              <div>{{ qrForm.wo_code }}</div>
            </div>
            <div
              style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
            >
              <div style="width: 60px;margin-left: 5px;">产品编码:</div>
              <div>{{ qrForm.partcode }}</div>
            </div>
            <div
              style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
            >
              <div style="width:60px;margin-left: 5px;">产品名称:</div>
              <div>{{ qrForm.partname }}</div>
            </div>
            <div
              style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
            >
              <div style="width:60px;margin-left: 5px;">{{ qrForm.nextstepname?'下道工序':'产品规格' }}:</div>
              <div>{{ qrForm.nextstepname?qrForm.nextstepname:qrForm.partspec?qrForm.partspec:'/' }}</div>
            </div>
            <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
              <div style="width: 60px;margin-left: 5px;">处理时间:</div>
              <div>{{ qrForm.operatorTime }}</div>
            </div>
 
          </div>
 
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisible2 = false">取 消</el-button>
          <el-button v-waves v-print="printObj2" type="primary">确 定</el-button>
        </div>
      </span>
    </el-dialog>
 
  </div>
</template>
 
<script>
import Pagination from '@/components/Pagination'
import $ from 'jquery'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import {
  EditOrderNgStepSeave,
  MesOrderNgStepSearch,
  MesOrderNgSubStepSearch,
  MesOrderStepSearch, MesOrderStepStart,
  MesOrderWxStepSearch, SavaMesOrderStepIn, SavaMesOrderStepOut, SavaMesOrderStepReport
} from '@/api/WorkOrder'
import {
  CustomerPermissions,
  DefectPermissions,
  EqpPermissions,
  GroupsPermissions,
  GroupsPersonPermissions,
  PersonPermissions, PrentOrganizationNoCompany
} from '@/api/GeneralBasicData'
import { nanoid } from 'nanoid'
import { LabelBarCode } from '@/api/systemSetting'
import { getCookie } from '@/utils/auth'
import { handleDatetime2 } from '@/utils/global'
import QRCode from 'qrcodejs2'
export default {
  name: 'StepReport',
  components: {
    Pagination
  },
  directives: { elDragDialog, waves },
  data() {
    return {
      mainHeight: 0,
      tableHeight: 0,
      form: {
        wkshopcode: '',
        wocode: '', // 工单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      wkshopcodeArr: [],
      total: 10,
      tableData: [],
      activeName: '生产列表',
      elTabsArr: [
        { code: 'ZZ', name: '生产列表' },
        { code: 'OUT', name: '外协发料' },
        { code: 'IN', name: '外协收料' },
        { code: 'BAD', name: '不良待处理' }
      ],
 
      radioSelected: '', // 多选框选中值
 
      dialogVisible: false,
      dialogTitle: '', // 对话框小标题
 
      dialogForm: {
        'wo_code': '',
        'partnumber': '',
        'partname': '',
        'partspec': '',
        'seq': '',
        'stepcode': '',
        'stepname': '',
        'stepprice': '', // 工序单价
        'nextstepcode': '',
        'nextstepname': '',
        'nextstepprice': '',
        'stepdesc': '',
        'planqty': 0,
        'startqty': 0, //
        'noreportqty': 0, // 未报数量
        'reportqty': 0, // 已报数量
        'noputqty': 0, // 不良数量
        'wkshopcode': '',
        'wkshopname': '',
        'eqpcode': '',
        'eqpname': '',
 
        remarks: '', // 备注
        inbarcode: '', // 入库条码
        defectlist: '', // 不良汇总
        reckway: 'person', // 计件方式(班组:group、个人:person)
        usergroupcode: '', // 班组编码
        reportuser: [], // 报工人员
 
        wxcode: '',
        outuser: '',
        fqty: '',
        inuser: '',
        sqty: '',
        list: ''
 
      },
      dialogFormRules: {
        eqpcode: [
          { required: true, message: '请选择报工设备', trigger: ['blur', 'change'] }
        ],
        usergroupcode: [
          { required: true, message: '请选择报工班组', trigger: ['blur', 'change'] }
        ],
        reportuser: [
          { required: true, message: '请选择报工人员', trigger: ['blur', 'change'] }
        ],
        startqty: [
          { required: true, message: '请输入合格数量', trigger: ['blur', 'change'] }
        ],
        wxcode: [
          { required: true, message: '请选择外协供方', trigger: ['blur', 'change'] }
        ],
        outuser: [
          { required: true, message: '请选择发料人员', trigger: ['blur', 'change'] }
        ],
        inuser: [
          { required: true, message: '请选择收料人员', trigger: ['blur', 'change'] }
        ],
        fqty: [
          { required: true, message: '请输入发料数量', trigger: ['blur', 'change'] }
        ],
        sqty: [
          { required: true, message: '请输入收料数量', trigger: ['blur', 'change'] }
        ]
 
      },
      reckwayArr: [// 报工类型
        { code: 'group', name: '班组' },
        { code: 'person', name: '个人' }
      ],
      reportuserArr: [], // 报工人员
      usergroupArr: [], // 报工班组
      eqpArr: [], // 报工设备
      defectArr: [], // 不良缺陷
      wxArr: [], // 往来单位下拉
 
      defectTableData: [],
      badTableData: [],
      workOrderCurrentValue: '',
 
      dialogVisible2: false, //
      qrForm: { // 打印内容
        qrvalue: '',
        startqty: '',
        wo_code: '',
        partcode: '',
        partname: '',
        partspec: '',
        nextstepname: '',
        operator: '', // 操作人
        operatorTime: ''// 操作时间
      },
      printObj2: {
        id: 'printMe2',
        popTitle: '打印模板',
        preview: false,
        extraHead: '<meta http-equiv="Content-Language" content="zh-cn"/>',
        closeCallback(vue) { // 关闭打印的回调事件(无法确定点击的是确认还是取消)
          console.log('11212', vue)
          // vue.dialogVisible = false
          vue.dialogVisible2 = false
          vue.dialogVisible = false
        },
        beforeOpenCallback(vue) {
          vue.printLoading = true
          console.log('打开之前')
        },
        openCallback(vue) {
          vue.printLoading = false
          console.log('执行了打印')
        }
      },
      xx: ''
    }
  },
  activated() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  created() {
 
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
 
    this.tabClick()
 
    this.getAllSelectArr()
  },
  methods: {
 
    async getAllSelectArr() {
      const { data: res1 } = await GroupsPermissions()// 班组
      this.usergroupArr = res1
 
      const { data: res2 } = await PersonPermissions() // 人员
      this.reportuserArr = res2
 
      const { data: res3 } = await DefectPermissions() // 缺陷
      this.defectArr = res3
 
      const { data: res4 } = await EqpPermissions() // 设备
      this.eqpArr = res4
 
      const { data: res5 } = await CustomerPermissions() // 往来单位
      this.wxArr = res5
 
      const { data: res6 } = await PrentOrganizationNoCompany()// 无公司的组织下拉
      this.wkshopcodeArr = res6
    },
    tabClick() {
      let belong
      switch (this.activeName) {
        case '生产列表':
          belong = 'produceCodeZZ'
          this.dialogTitle = '报工'
          break
        case '外协发料':
          belong = 'produceCodeOUT'
          this.dialogTitle = '发料'
          break
        case '外协收料':
          belong = 'produceCodeIN'
          this.dialogTitle = '收料'
          break
        case '不良待处理':
          belong = 'produceCodeBAD'
          this.dialogTitle = '不良处理'
          break
      }
      this.enterNative(this.form.wocode, belong)
 
      this.radioSelected = ''
    },
    enterNative(val, belong) {
      if (belong === 'produceCodeZZ') {
        this.$nextTick(() => {
          $('input[name=\'produceCodeZZ\']')[0].focus()
        })
      }
      if (belong === 'produceCodeOUT') {
        this.$nextTick(() => {
          $('input[name=\'produceCodeOUT\']')[0].focus()
        })
      }
      if (belong === 'produceCodeIN') {
        this.$nextTick(() => {
          $('input[name=\'produceCodeIN\']')[0].focus()
        })
      }
      if (belong === 'produceCodeBAD') {
        this.$nextTick(() => {
          $('input[name=\'produceCodeBAD\']')[0].focus()
        })
      }
      this.search()
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.search()
    },
    // 查询
    async search() {
      this.form.wocode = this.workOrderCurrentValue
      this.workOrderCurrentValue = ''
      if (this.activeName === '生产列表') {
        const res = await MesOrderStepSearch(this.form)
        this.tableData = res.data
        this.total = res.count
      }
      if (this.activeName === '外协发料' || this.activeName === '外协收料') {
        const res = await MesOrderWxStepSearch(this.form)
        this.tableData = res.data
        this.total = res.count
      }
 
      if (this.activeName === '不良待处理') {
        const res = await MesOrderNgStepSearch(this.form)
        this.tableData = res.data
        this.total = res.count
      }
    },
    // 报工
    report(row) {
      if (row) {
        this.getMesOrderStepStart('ZZ', '', row.wo_code, row.stepcode)
      } else {
        const temp = this.tableData.find(i => i.id === this.radioSelected)
        this.getMesOrderStepStart('ZZ', '', temp.wo_code, temp.stepcode)
      }
    },
    // 发料
    sendOut(row) {
      if (row) {
        this.getMesOrderStepStart('WX', 'OUT', row.wo_code, row.stepcode)
      } else {
        const temp = this.tableData.find(i => i.id === this.radioSelected)
        this.getMesOrderStepStart('WX', 'OUT', temp.wo_code, temp.stepcode)
      }
    },
    // 收料
    takeIn(row) {
      if (row) {
        this.getMesOrderStepStart('WX', 'IN', row.wo_code, row.stepcode)
      } else {
        const temp = this.tableData.find(i => i.id === this.radioSelected)
        this.getMesOrderStepStart('WX', 'IN', temp.wo_code, temp.stepcode)
      }
    },
    // 不良处理    生产开报工扫码获取工单对应工序任务(不良明细)
    async handleBad(row) {
      const data = {
        wocode: row ? row.wo_code : this.tableData.find(i => i.id === this.radioSelected).wo_code,
        stepcode: row ? row.stepcode : this.tableData.find(i => i.id === this.radioSelected).stepcode
      }
      let res = await MesOrderNgSubStepSearch(data)
      if (res.code === '200') {
        res = res.data
        this.dialogForm.wo_code = res.data1.wo_code
        this.dialogForm.partnumber = res.data1.partnumber
        this.dialogForm.partname = res.data1.partname
        this.dialogForm.partspec = res.data1.partspec
        this.dialogForm.seq = res.data1.seq
        this.dialogForm.stepcode = res.data1.stepcode
        this.dialogForm.stepname = res.data1.stepname
        this.dialogForm.stepprice = res.data1.stepprice
        this.dialogForm.nextstepcode = res.data1.nextstepcode
        this.dialogForm.nextstepname = res.data1.nextstepname
        this.dialogForm.nextstepprice = res.data1.nextstepprice
        this.dialogForm.stepdesc = res.data1.stepdesc
        this.dialogForm.planqty = res.data1.planqty
        this.dialogForm.startqty = res.data1.startqty
        this.dialogForm.noreportqty = res.data1.noreportqty // 合格数量
        this.dialogForm.reportqty = res.data1.reportqty
        this.dialogForm.noputqty = res.data1.noputqty // 不良数量
        this.dialogForm.wkshopcode = res.data1.wkshopcode
        this.dialogForm.wkshopname = res.data1.wkshopname
        this.dialogForm.eqpcode = res.data1.eqpcode
        this.dialogForm.eqpname = res.data1.eqpname
 
        res.data2.forEach(item => {
          item.repair_qty = 0
          item.laborbad_qty = 0
          item.materielbad_qty = 0
        })
 
        this.badTableData = res.data2
 
        this.dialogVisible = true
      }
    },
    // 生产开报工:报工/外协(发料/收料)时条件判断及数据返回接口
    async getMesOrderStepStart(OperType, SelectType, wocode, stepcode) {
      const data = {
        OperType, SelectType, wocode, stepcode
      }
      let res = await MesOrderStepStart(data)
      if (res.code === '200') {
        res = res.data
        this.dialogForm.wo_code = res.wo_code
        this.dialogForm.partnumber = res.partnumber
        this.dialogForm.partname = res.partname
        this.dialogForm.partspec = res.partspec
        this.dialogForm.seq = res.seq
        this.dialogForm.stepcode = res.stepcode
        this.dialogForm.stepname = res.stepname
        this.dialogForm.stepprice = res.stepprice
        this.dialogForm.nextstepcode = res.nextstepcode
        this.dialogForm.nextstepname = res.nextstepname
        this.dialogForm.nextstepprice = res.nextstepprice
        this.dialogForm.stepdesc = res.stepdesc
        this.dialogForm.planqty = res.planqty
        this.dialogForm.startqty = res.startqty
        this.dialogForm.noreportqty = res.noreportqty// 未报数量
        this.dialogForm.reportqty = res.reportqty // 已报数量
        this.dialogForm.noputqty = res.noputqty
        this.dialogForm.wkshopcode = res.wkshopcode
        this.dialogForm.wkshopname = res.wkshopname
        this.dialogForm.eqpcode = res.eqpcode
        this.dialogForm.eqpname = res.eqpname
 
        if (this.activeName === '外协收料') {
          this.dialogForm.list = []
          res.list.forEach(i => {
            i.acceptQty = parseFloat(i.fqty) - parseFloat(i.sqty) - parseFloat(i.ng_qty) - parseFloat(i.laborbad_qty) - parseFloat(i.materielbad_qty)
            if (i.acceptQty > 0) {
              this.dialogForm.list.push(i)
            }
          })
        }
 
        // this.dialogForm.list = res.list
 
        this.dialogVisible = true
      }
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm = {
        'wo_code': '',
        'partnumber': '',
        'partname': '',
        'partspec': '',
        'seq': '',
        'stepcode': '',
        'stepname': '',
        'stepprice': '', // 工序单价
        'nextstepcode': '',
        'nextstepname': '',
        'nextstepprice': '',
        'stepdesc': '',
        'planqty': 0,
        'startqty': 0, //
        'noreportqty': 0, // 未报数量
        'reportqty': 0, // 已报数量
        'noputqty': 0, // 不良数量
        'wkshopcode': '',
        'wkshopname': '',
        'eqpcode': '',
        'eqpname': '',
 
        wxcode: '',
        outuser: '',
        fqty: '',
        inuser: '',
        sqty: '',
        list: '',
 
        remarks: '', // 备注
        inbarcode: '', // 入库条码
        defectlist: '', // 不良汇总
        reckway: 'person', // 计件方式(班组:group、个人:person)
        usergroupcode: '', // 班组编码
        reportuser: [] // 报工人员
 
      }
 
      this.defectTableData = []
      this.badTableData = []
 
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
      this.tabClick()
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(async valid => {
        if (valid) {
          if (this.activeName === '生产列表') {
            if (this.defectTableData.find(i => i.code.length === 0)) {
              return this.$message.info('缺陷编码/名称不能为空!')
            }
            if (this.defectTableData.find(i => i.badqty.toString().trim() === '' || parseFloat(i.badqty) === 0)) {
              return this.$message.info('不良数量不能为空或为零!')
            }
 
            if (parseFloat(this.dialogForm.noreportqty) < parseFloat(this.dialogForm.startqty) + parseFloat(this.dialogForm.noputqty)) {
              return this.$message.info('合格数量加不良数量不能大于了未报数量!')
            }
 
            if (parseFloat(this.dialogForm.startqty) === 0 && this.defectTableData.length === 0) {
              return this.$message.info('合格数量不能为零!')
            }
 
            let inbarcode = ''
            if (this.tableData.find(i => i.id === this.radioSelected).isend === 'Y') {
              const data1 = {
                rightcode: getCookie('ruleCode'),
                partcode: this.dialogForm.partnumber,
                qty: this.dialogForm.startqty,
                onelabqty: this.dialogForm.startqty
              }
 
              const res1 = await LabelBarCode(data1)
              inbarcode = res1.data[0].labcode
            }
 
            const defectlist = []
            this.defectTableData.forEach(i => {
              defectlist.push({
                defect_code: i.code.join(','),
                badqty: i.badqty
              })
            })
            const data = {
              mesordercode: this.dialogForm.wo_code,
              partcode: this.dialogForm.partnumber,
              stepseq: this.dialogForm.seq,
              stepcode: this.dialogForm.stepcode,
              stepprice: this.dialogForm.stepprice,
              eqpcode: this.dialogForm.eqpcode,
              inbarcode,
              reckway: this.dialogForm.reckway,
              usergroupcode: this.dialogForm.usergroupcode,
              reportuser: this.dialogForm.reportuser.join(','),
              taskqty: this.dialogForm.planqty,
              // startqty: this.dialogForm.startqty,
              // reportqty: this.dialogForm.reportqty,
 
              startqty: this.dialogForm.startqty,
              reportqty: this.dialogForm.startqty, // 报工数量
 
              defectlist,
              remarks: ''
            }
            // console.log(JSON.parse(JSON.stringify(this.defectTableData)))
            // console.log(JSON.parse(JSON.stringify(data)))
 
            this.$store.state.app.buttonIsDisabled = true
            const res = await SavaMesOrderStepReport(data)
            if (res.code === '200') {
              this.$notify.success('报工成功!')
              // await this.search()
              await this.tabClick()
              this.$store.state.app.buttonIsDisabled = false
              this.dialogVisible = false
 
              // 自制报工打印标签口子已开好
              // if (JSON.parse(localStorage.getItem('mesSetting')).every) {
              //   this.dialogVisible2 = true
              //   this.ZZprint2(localStorage.getItem('username'))
              // }
            } else {
              this.$store.state.app.buttonIsDisabled = false
              this.$notify.error('报工失败!')
            }
          }
 
          if (this.activeName === '外协发料') {
            if (parseFloat(this.dialogForm.fqty) < 1) {
              return this.$message.info('发料数量不能为零!')
            }
            if (parseFloat(this.dialogForm.fqty) > parseFloat(this.dialogForm.noreportqty)) {
              return this.$message.info('发料数量不能大于未发数量!')
            }
            const data = {
              mesordercode: this.dialogForm.wo_code,
              partcode: this.dialogForm.partnumber,
              stepseq: this.dialogForm.seq,
              stepcode: this.dialogForm.stepcode,
 
              wxcode: this.dialogForm.wxcode,
              outuser: this.dialogForm.outuser,
              taskqty: this.dialogForm.planqty,
              fqty: this.dialogForm.fqty
            }
            // console.log(JSON.stringify(data))
 
            this.$store.state.app.buttonIsDisabled = true
            const res = await SavaMesOrderStepOut(data)
            if (res.code === '200') {
              this.$notify.success('发料成功!')
              // await this.search()
              await this.tabClick()
              this.$store.state.app.buttonIsDisabled = false
              this.dialogVisible = false
            } else {
              this.$store.state.app.buttonIsDisabled = false
              this.$notify.error('发料失败!')
            }
          }
 
          if (this.activeName === '外协收料') {
            if (this.defectTableData.find(i => i.code.length === 0)) {
              return this.$message.info('缺陷编码/名称不能为空!')
            }
            if (this.defectTableData.find(i => i.badqty.toString().trim() === '' || parseFloat(i.badqty) === 0)) {
              return this.$message.info('不良数量不能为空或为零!')
            }
 
            if (parseFloat(this.dialogForm.noreportqty) < parseFloat(this.dialogForm.sqty) + parseFloat(this.dialogForm.noputqty)) {
              return this.$message.info('收料数量加不良数量不能大于了可收数量!')
            }
 
            if (this.dialogForm.list.find(i => i.Name === this.dialogForm.wxcode)) {
              if (this.dialogForm.list.find(i => i.Name === this.dialogForm.wxcode).acceptQty < parseFloat(this.dialogForm.sqty) + parseFloat(this.dialogForm.noputqty)) {
                return this.$message.info('收料数量加不良数量不能大于该供应商可收数量!')
              }
            } else {
              return this.$message.info('此供应商无可收数量!')
            }
 
            let inbarcode = ''
            if (this.tableData.find(i => i.id === this.radioSelected).isend === 'Y') {
              const data1 = {
                rightcode: getCookie('ruleCode'),
                partcode: this.dialogForm.partnumber,
                qty: this.dialogForm.startqty,
                onelabqty: this.dialogForm.startqty
              }
 
              const res1 = await LabelBarCode(data1)
              inbarcode = res1.data[0].labcode
            }
            const defectlist = []
            this.defectTableData.forEach(i => {
              defectlist.push({
                defect_code: i.code.join(','),
                badqty: i.badqty
              })
            })
 
            const data = {
              mesordercode: this.dialogForm.wo_code,
              partcode: this.dialogForm.partnumber,
              stepseq: this.dialogForm.seq,
              stepcode: this.dialogForm.stepcode,
 
              wxcode: this.dialogForm.wxcode,
              inbarcode,
              inuser: this.dialogForm.inuser,
              taskqty: this.dialogForm.planqty,
              sqty: this.dialogForm.sqty,
              defectlist,
              remarks: ''
            }
            // console.log(JSON.parse(JSON.stringify(data)), 1)
            this.$store.state.app.buttonIsDisabled = true
            const res = await SavaMesOrderStepIn(data)
            if (res.code === '200') {
              this.$notify.success('收料成功!')
              // await this.search()
              await this.tabClick()
              this.$store.state.app.buttonIsDisabled = false
              this.dialogVisible = false
            } else {
              this.$store.state.app.buttonIsDisabled = false
              this.$notify.error('收料失败!')
            }
          }
 
          if (this.activeName === '不良待处理') {
            let flag = false
            this.badTableData.forEach(i => {
              if (parseFloat(i.repair_qty) + parseFloat(i.laborbad_qty) + parseFloat(i.materielbad_qty) > parseFloat(i.ng_qty)) {
                flag = true
              }
            })
            if (flag) {
              return this.$message.info('维修合格数量+工废数量+料废数量不能大于不良数量!')
            }
            this.$store.state.app.buttonIsDisabled = true
            const res = await EditOrderNgStepSeave({ Data: this.badTableData })
            if (res.code === '200') {
              this.$notify.success('提交成功!')
              // await this.search()
              await this.tabClick()
              this.$store.state.app.buttonIsDisabled = false
              this.dialogVisible = false
            } else {
              this.$store.state.app.buttonIsDisabled = false
              this.$notify.error('提交失败!')
            }
          }
        }
      })
    },
 
    dialogVisible2Close() {
      this.qrForm.qrvalue = ''
      this.qrForm.startqty = ''
      this.qrForm.wo_code = ''
      this.qrForm.partcode = ''
      this.qrForm.partname = ''
      this.qrForm.partspec = ''
      this.qrForm.nextstepname = ''
      this.qrForm.operator = ''
      this.qrForm.operatorTime = ''
      // this.$refs.qrCodeDiv2 = ''
    },
 
    ZZprint2(username) {
      if (this.dialogForm.nextstepcode !== '') {
        this.qrForm.qrvalue = this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode
      } else {
        this.qrForm.qrvalue = this.dialogForm.inbarcode
      }
 
      this.qrForm.startqty = this.dialogForm.startqty
      this.qrForm.wo_code = this.dialogForm.wo_code
      this.qrForm.partcode = this.dialogForm.partnumber
      this.qrForm.partname = this.dialogForm.partname
      this.qrForm.nextstepname = this.dialogForm.nextstepname
      this.qrForm.operator = username
      this.qrForm.operatorTime = handleDatetime2(new Date())
      this.$nextTick(() => {
        this.bindQRCode(this.qrForm.qrvalue)
      })
    },
    // 生成二维码
    bindQRCode(text) {
      new QRCode(this.$refs.qrCodeDiv2, {
        text: text,
        // width: 50,
        width: 60,
        // height: 50,
        height: 60,
        colorDark: '#000', // 二维码颜色
        colorLight: '#ffffff', // 二维码背景色
        correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
      })
    },
    // 缺陷新增
    addDefect() {
      if (this.defectTableData.find(i => i.code.length === 0)) {
        return this.$message.info('缺陷编码/名称不能为空!')
      }
      if (this.defectTableData.find(i => i.badqty.toString().trim() === '' || parseFloat(i.badqty) === 0)) {
        return this.$message.info('不良数量不能为空或为零!')
      }
 
      this.defectTableData.push({
        uuid: nanoid(), code: [], badqty: ''
      })
    },
    // 缺陷删除
    defectDel(row) {
      this.defectTableData = this.defectTableData.filter(i => i.uuid !== row.uuid)
 
      this.dialogForm.noputqty = 0
      this.defectTableData.forEach(i => {
        this.dialogForm.noputqty += parseFloat(i.badqty)
      })
    },
    badqtyChange(val) {
      this.dialogForm.noputqty = 0
      this.defectTableData.forEach(i => {
        this.dialogForm.noputqty += parseFloat(i.badqty)
      })
    },
    reckwayChange(val) {
      // console.log(val)
      this.dialogForm.usergroupcode = ''
      this.dialogForm.reportuser = []
    },
    async usergroupChange(val) {
      const { data: res } = await GroupsPersonPermissions({ groupcode: val })
      this.dialogForm.reportuser = res[0].usercode_list ? res[0].usercode_list.split(',') : []
    },
    rowClick(row, event, column) {
      this.radioSelected = row.id
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 275
        // this.$refs.tableDataRef.doLayout()
      })
    },
    reset() {
      this.form.wkshopcode = ''
      this.form.wocode = ''
      this.form.workOrderCurrentValue = ''
      this.form.partcode = ''
      this.form.partname = ''
      this.form.partspec = ''
      this.search()
    },
 
    headerCellStyle() {
      return this.$headerCellStyle
    },
    cellStyle() {
      return this.$cellStyle
    }
  }
}
</script>
<style lang="scss" scoped>
 
::v-deep .elTableDiv .el-radio__label {
  display: none !important;
}
 
.dialogFormItem {
  margin: 0 10px 0 0;
}
 
.dialogFormItemDiv {
  width: 200px;
}
 
::v-deep .el-select__caret {
  display: flex;
  align-items: center;
  justify-content: center;
}
 
::v-deep .el-dialog .el-form-item__label {
  font-weight: lighter !important;
}
 
::v-deep .el-dialog .el-divider__text {
  font-weight: bolder !important;
}
 
</style>