loulijun2021
2022-08-09 04c5571156dc904de0ab2478a6b73b304bc16c4c
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
<template>
  <div>
    <div class="body" style="padding-top: 10px;" :style="{height:mainHeight+'px'}">
      <el-tabs ref="elTabs" v-model="activeName" type="border-card" @tab-click="tabClick">
        <el-tab-pane label="生产列表">
          <div style="margin-left: 10px;margin-top:10px;display: flex;justify-content: space-between">
            <div style="display: flex;align-items: center">
              <div style="width: 90px">扫描条码:</div>
              <!--              oninput="value=value.replace(/[^0-9a-zA-Z;_]/g,'')"-->
 
              <el-input
                v-model="form.orderstepqrcode"
                name="produceCode"
                style="width: 300px"
                @keyup.enter.native="val=>enterNative(val,'produceCode')"
              />
            </div>
            <div v-if="false" style="display: flex;padding-right: 10px">
              <el-button @click="ZZstart">
                <svg-icon icon-class="start_time" style="margin-right: 2px" />
                开始
              </el-button>
              <el-button @click="ZZreport">
                <svg-icon icon-class="report_work" style="margin-right: 2px" />
                报工
              </el-button>
            </div>
          </div>
          <el-divider />
          <div class="elTableDiv">
            <el-table
              :data="tableData"
              :height="isIpad? (tableHeight+50):tableHeight"
              border
              :row-class-name="tableRowClassName"
              :style="{width: 100+'%',height:tableHeight+'px',}"
              highlight-current-row
              :header-cell-style="this.$headerCellStyle"
              :cell-style="this.$cellStyle"
              @sort-change="sortChange"
            >
              <!--              <el-table-column-->
              <!--                width="50"-->
              <!--                fixed-->
              <!--              >-->
              <!--                <template slot-scope="{row}">-->
              <!--                  <el-radio-->
              <!--                    v-model="radioSelected"-->
              <!--                    :label="row.wo"-->
              <!--                    style="color: #fff;padding-left: 10px; margin-right: -25px;"-->
              <!--                    @change.native="getCurrentRow(row.wo)"-->
              <!--                  />-->
              <!--                </template>-->
              <!--              </el-table-column>-->
              <el-table-column
                prop="RowNum"
                width="50"
                label="序号"
                fixed
              />
              <el-table-column
                prop="status"
                label="状态"
                sortable="custom"
                width="110"
              >
                <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>
                </template>
              </el-table-column>
              <el-table-column
                prop="wo_code"
                label="工单号"
                min-width="160"
                sortable="custom"
              />
              <el-table-column
                prop="partcode"
                label="产品编码"
                min-width="110"
                sortable="custom"
              />
              <el-table-column
                prop="partname"
                min-width="110"
                label="产品名称"
                sortable="custom"
              />
              <el-table-column
                prop="stepname"
                label="工序"
                min-width="80"
                sortable="custom"
              />
              <el-table-column
                prop="descr"
                label="工序描述"
                min-width="150"
                sortable="custom"
              />
              <el-table-column
                prop="plan_qty"
                label="任务数量"
                width="110"
                sortable="custom"
              />
              <el-table-column
                prop="good_qty"
                label="已报工数量(良品)"
                sortable="custom"
                width="160"
              />
              <el-table-column
                prop="ng_qty"
                label="不良数量"
                width="150"
 
                sortable="custom"
              />
              <el-table-column
                prop="plan_startdate"
                label="计划开工日期"
                width="185"
                sortable="custom"
                fixed="right"
              />
              <!--              <el-table-column-->
              <!--                label="操作"-->
              <!--                width="150"-->
              <!--                fixed="right"-->
              <!--              >-->
              <!--                <template slot-scope="{row}">-->
              <!--                  <div class="operationClass">-->
              <!--                    <el-button type="text" @click="edit('edit',row)">编辑</el-button>-->
              <!--                    <el-button type="text" @click="del(row)">删除</el-button>-->
              <!--                  </div>-->
              <!--                </template>-->
              <!--              </el-table-column>-->
            </el-table>
          </div>
          <!--分页-->
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="form.page"
            :limit.sync="form.rows"
            align="right"
            layout="total,prev, pager, next,sizes"
            popper-class="select_bottom"
            @pagination="getMesOrderStepSearch"
          />
        </el-tab-pane>
        <el-tab-pane label="外协列表">
          <div style="margin-left: 10px;margin-top:10px;display: flex;justify-content: space-between">
            <div style="display: flex;align-items: center">
              <div style="width: 90px;">外协类型:</div>
              <el-select
                v-model="WXSelected"
                filterable
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in WXSelectArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
              <div style="width: 90px;margin-left: 20px">扫描条码:</div>
              <el-input
                v-model="WXform.orderstepqrcode"
                name="WXproduceCode"
                style="width: 300px"
                @keyup.enter.native="val=>enterNative(val,'WXproduceCode')"
              />
            </div>
            <div v-if="false" style="display: flex;padding-right: 10px">
              <el-button @click="WXsend">
                <svg-icon icon-class="start_time" style="margin-right: 2px" />
                发料
              </el-button>
              <el-button @click="WXback">
                <svg-icon icon-class="report_work" style="margin-right: 2px" />
                收料
              </el-button>
            </div>
          </div>
          <el-divider />
          <div class="elTableDiv">
            <el-table
              :data="WXtableData"
              :height="isIpad? (tableHeight+50):tableHeight"
              border
              :row-class-name="tableRowClassName"
              :style="{width: 100+'%',height:tableHeight+'px',}"
              highlight-current-row
              :header-cell-style="this.$headerCellStyle"
              :cell-style="this.$cellStyle"
              @sort-change="WXsortChange"
            >
              <!--              <el-table-column-->
              <!--                width="50"-->
              <!--                fixed-->
              <!--              >-->
              <!--                <template slot-scope="{row}">-->
              <!--                  <el-radio-->
              <!--                    v-model="radioSelected"-->
              <!--                    :label="row.wo_code"-->
              <!--                    style="color: #fff;padding-left: 10px; margin-right: -25px;"-->
              <!--                    @change.native="getWXCurrentRow(row.wo_code)"-->
              <!--                  />-->
              <!--                </template>-->
              <!--              </el-table-column>-->
              <el-table-column
                prop="RowNum"
                width="50"
                label="序号"
                fixed
              />
              <el-table-column
                prop="status"
                label="状态"
                sortable="custom"
                width="110"
              >
                <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>
                </template>
              </el-table-column>
              <el-table-column
                prop="wo_code"
                label="工单号"
                min-width="160"
                sortable="custom"
              />
              <el-table-column
                prop="partcode"
                label="产品编码"
                min-width="110"
                sortable="custom"
              />
              <el-table-column
                prop="partname"
                label="产品名称"
                min-width="110"
                sortable="custom"
              />
              <el-table-column
                prop="stepname"
                label="工序"
                min-width="80"
                sortable="custom"
              />
              <el-table-column
                prop="descr"
                label="工序描述"
                min-width="150"
                sortable="custom"
              />
              <el-table-column
                prop="plan_qty"
                label="任务数量"
                width="110"
                sortable="custom"
              />
              <el-table-column
                prop="good_qty"
                label="已收料数量(良品)"
                sortable="custom"
                width="160"
              />
              <el-table-column
                prop="ng_qty"
                label="不良数量"
                width="150"
                sortable="custom"
              />
              <el-table-column
                prop="plan_startdate"
                label="计划开工日期"
                width="185"
                sortable="custom"
                fixed="right"
              />
              <!--              <el-table-column-->
              <!--                label="操作"-->
              <!--                width="150"-->
              <!--                fixed="right"-->
              <!--              >-->
              <!--                <template slot-scope="{row}">-->
              <!--                  <div class="operationClass">-->
              <!--                    <el-button type="text" @click="edit('edit',row)">编辑</el-button>-->
              <!--                    <el-button type="text" @click="del(row)">删除</el-button>-->
              <!--                  </div>-->
              <!--                </template>-->
              <!--              </el-table-column>-->
            </el-table>
          </div>
          <!--分页-->
          <pagination
            v-show="WXtotal>0"
            :total="WXtotal"
            :page.sync="WXform.page"
            :limit.sync="WXform.rows"
            align="right"
            layout="total,prev, pager, next,sizes"
            popper-class="select_bottom"
            @pagination="getMesOrderStepSearch"
          />
        </el-tab-pane>
      </el-tabs>
 
    </div>
 
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="850px"
      class="dialogVisible"
      :top="dialogTitle==='自制报工'?'5vh':'15vh'"
      :close-on-click-modal="false"
      @close="handleClose"
      @closed="handleClose"
    >
      <el-form
        ref="dialogForm"
        inline
        :rules="dialogFormRules"
        :model="dialogForm"
        label-width="110px"
      >
        <el-form-item label="工单编号:">
          <div style="width: 200px">{{ dialogForm.wo_code }}</div>
        </el-form-item>
        <el-form-item label="产品编码:">
          <div style="width: 200px">{{ dialogForm.partcode }}</div>
        </el-form-item>
        <el-form-item label="产品名称:">
          <div style="width: 200px">{{ dialogForm.partname }}</div>
        </el-form-item>
        <el-form-item label="产品规格:">
          <div style="width: 200px">{{ dialogForm.partspec }}</div>
        </el-form-item>
        <el-form-item label="当前工序:">
          <div style="width: 200px">{{ dialogForm.stepname }}</div>
        </el-form-item>
        <el-form-item label="工序描述:">
          <!--          <el-tooltip   class="item" effect="dark" content="原材料切按材料切按材料切按时打卡数据的卡" placement="top-start">-->
          <div style="width: 200px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">
            {{ dialogForm.stepdesc }}
          </div>
          <!--          </el-tooltip>-->
        </el-form-item>
        <el-form-item label="任务数量:">
          <div style="width: 200px">{{ dialogForm.planqty }}</div>
        </el-form-item>
 
        <el-form-item v-if="dialogTitle==='自制开始'" label="未开/已开:">
          <div style="width: 200px">{{ dialogForm.noreportqty }}/{{ dialogForm.reportqty }}</div>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制报工'" label="未报/已报:">
          <div style="width: 200px">{{ dialogForm.noreportqty }}/{{ dialogForm.reportqty }}</div>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='外协发料'" label="未发/已发:">
          <div style="width: 200px">{{ dialogForm.noreportqty }}/{{ dialogForm.reportqty }}</div>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='外协收料'" label="未收/已收:">
          <div style="width: 200px">{{ dialogForm.noreportqty }}/{{ dialogForm.reportqty }}</div>
        </el-form-item>
        <!--自制开始-->
        <el-form-item v-if="dialogTitle==='自制开始'" label="开工数量:">
          <div style="width: 200px">{{ dialogForm.startqty }}</div>
          <!--          <div style="width: 200px">{{  dialogForm.noreportqty }}</div>-->
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制开始'" prop="eqpcode" label="生产设备:">
          <el-select
            v-model="dialogForm.eqpcode"
            style="width: 200px;"
            placeholder="请选择"
          >
            <el-option
              v-for="item in ZZeqpArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <!--     自制报工   -->
        <el-form-item v-if="dialogTitle==='自制报工'" label="下道工序:">
          <div style="width: 200px">{{ dialogForm.nextstepname }}</div>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制报工'" prop="usergroupcode" label="生产班组:">
          <el-select
            v-model="dialogForm.usergroupcode"
            style="width: 200px;"
            placeholder="请选择"
            @change="usergroupChange"
          >
            <el-option
              v-for="item in ZZtreams"
              :key="item.group_code"
              :label="item.group_name"
              :value="item.group_code"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制报工'" label="设备名称:" prop="eqpcode">
          <el-select
            v-model="dialogForm.eqpcode"
            style="width: 200px;"
            placeholder="请选择"
          >
            <el-option
              v-for="item in ZZeqpArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制报工'" label="报工数量:" prop="startqty">
          <el-input v-model="dialogForm.startqty" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 200px;" />
          <!--          <el-input v-model="dialogForm.noreportqty" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 200px;" />-->
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制报工'" label="不良数量:">
          <el-input v-model="dialogForm.noputqty" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 200px;" />
        </el-form-item>
        <el-form-item v-if="dialogTitle==='自制报工'" label="不良原因:">
          <el-select
            v-model="dialogForm.badcode"
            style="width: 200px;"
            placeholder="请选择"
            :disabled="parseFloat(dialogForm.noputqty)===0||dialogForm.noputqty.trim()===''"
            multiple
          >
            <el-option
              v-for="item in badArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <div v-if="dialogTitle==='自制报工'">
          <i class="el-icon-s-operation" style="color:#42b983;" /> 人员列表
          <el-button type="primary" style="margin: 10px 0" @click="userAdd">增行</el-button>
          <el-table
            :data="userTableData"
            border
            :row-class-name="tableRowClassName"
            :header-cell-style="this.$headerCellStyle"
            :cell-style="this.$cellStyle"
            height="180"
            highlight-current-row
            style="width: 100%"
          >
            <el-table-column
              width="100"
              label="序号"
              type="index"
              fixed
            />
            <el-table-column
              prop="username"
              label="人员名称"
            >
              <template slot-scope="{row}">
                <div v-if="row.isVisible===0">{{ row.username }}</div>
                <el-select
                  v-if="row.isVisible===1"
                  v-model="row.username"
                  style="width: 200px;"
                  placeholder="请选择"
                  @change="val=>usernameChange(val,row)"
                >
                  <el-option
                    v-for="item in ZZuserArr"
                    :key="item.usercode"
                    :label="item.username"
                    :value="item.usercode"
                  />
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              prop="RowNum"
              label="操作"
              fixed="right"
            >
              <template slot-scope="{row}">
                <div class="operationClass">
                  <el-button v-if="row.isVisible===0" type="text" @click="userDel(row)">删除</el-button>
                  <el-button v-if="row.isVisible===1&&!userIsSave" type="text" @click="userSave(row)">保存</el-button>
                  <el-button v-if="row.isVisible===1" type="text" @click="userCancel(row)">取消</el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <!--分页-->
          <pagination
            v-show="UserTotal>0"
            :total="UserTotal"
            :page.sync="Userform.page"
            :limit.sync="Userform.rows"
            align="right"
            layout="total,prev, pager, next,sizes"
            popper-class="select_bottom"
            @pagination="getMesOrderStepSearch"
          />
        </div>
        <!--     外协发料-->
        <el-form-item
          v-if="dialogTitle==='外协发料'"
          label="外协供方:"
          prop="wxcode"
        >
          <el-select
            v-model="dialogForm.wxcode"
            style="width: 200px;"
            placeholder="请选择"
            filterable
          >
            <el-option
              v-for="item in WXouterprovide"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协发料'"
          label="发料人员:"
          prop="outuser"
        >
          <el-select
            v-model="dialogForm.outuser"
            style="width: 200px;"
            placeholder="请选择"
            filterable
          >
            <el-option
              v-for="item in WXoutuser"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协发料'"
          label="发料数量:"
          prop="fqty"
        >
          <el-input v-model="dialogForm.fqty" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 200px;" />
        </el-form-item>
        <!--     外协收料-->
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="下道工序:"
        >
          <div style="width: 200px">{{ dialogForm.nextstepname }}</div>
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="外协供方:"
          prop="wxcode"
        >
          <el-select
            v-model="dialogForm.wxcode"
            style="width: 200px;"
            placeholder="请选择"
          >
            <el-option
              v-for="item in WXouterprovide"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="收料人员:"
          prop="inuser"
        >
          <el-select
            v-model="dialogForm.inuser"
            style="width: 200px;"
            placeholder="请选择"
          >
            <el-option
              v-for="item in WXoutuser"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="收料数量:"
          prop="sqty"
        >
          <el-input
            v-model="dialogForm.sqty"
            style="width: 200px"
            oninput="value=value.replace(/[^0-9.]/g,'')"
          />
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="不良数量:"
          prop="noputqty"
        >
          <el-input
            v-model="dialogForm.noputqty"
            style="width: 200px"
            oninput="value=value.replace(/[^0-9.]/g,'')"
          />
        </el-form-item>
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="不良原因:"
          prop="badcode"
        >
          <el-select
            v-model="dialogForm.badcode"
            style="width: 200px;"
            multiple
            :disabled="parseFloat(dialogForm.noputqty)===0||dialogForm.noputqty.trim()===''"
            placeholder="请选择"
          >
            <el-option
              v-for="item in badArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
 
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisibleCancel">取 消</el-button>
          <el-button v-if="dialogTitle==='自制开始'" type="primary" @click="dialogVisibleConfirm">开 工</el-button>
          <el-button v-if="dialogTitle==='自制报工'" type="primary" @click="dialogVisibleConfirm">提交/打印</el-button>
          <el-button v-if="dialogTitle==='外协发料'" type="primary" @click="dialogVisibleConfirm">发料</el-button>
          <el-button v-if="dialogTitle==='外协收料'" type="primary" @click="dialogVisibleConfirm">收料/打印</el-button>
        </div>
      </span>
    </el-dialog>
 
    <!--打印预览页面-->
    <el-dialog
      title="预览"
      :visible.sync="dialogVisible2"
      width="1140"
      :close-on-click-modal="false"
      @close="dialogVisible2Close"
    >
      <!-- 要打印的区域 -->
      <div id="printMe2" style="padding: 30px;">
        <div
          style="display: flex;width: 250px;height: 150px;border: 1px solid #000;text-align: center;font-size: 10px;"
        >
 
          <div style="width: 60px;display: flex;flex-direction: column;border-right: 1px solid #000">
            <div
              style="display: flex;height: 75%;border-bottom:1px solid #000;justify-content: center;align-items: center "
            >
              <div id="qrCode2" ref="qrCodeDiv2" />
            </div>
            <div style="display: flex;height: 25%;justify-content: flex-start;align-items: center">
              <div style="margin-left: 5px;width: 40px">数量:</div>
              {{ qrForm.startqty }}
            </div>
          </div>
 
          <div style="width:190px;display: flex;flex-direction: column">
            <div
              style="display: flex;height: 25%;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: 25%;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: 25%;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: 25%;justify-content: flex-start;align-items: center;text-align: left">
              <div style="width: 60px;margin-left: 5px;">下道工序:</div>
              <div>{{ qrForm.nextstepname }}</div>
            </div>
 
          </div>
 
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisible2 = false">取 消</el-button>
          <el-button v-print="printObj2" type="primary">确 定</el-button>
        </div>
      </span>
    </el-dialog>
 
  </div>
</template>
 
<script>
import Pagination from '@/components/Pagination'
import $ from 'jquery'
import {
  MesOrderGroupSelectUser,
  MesOrderSelectUser,
  MesOrderStepReportSelectUserGroup,
  MesOrderStepSearch,
  MesOrderStepStart,
  MesOrderStepStartSelectEqp,
  MesOrderWxStepSearch,
  MesOrderStepSelectWX,
  SavaMesOrderStepOut,
  MesOrderStepSelectCause,
  SavaMesOrderStepIn,
  SavaMesOrderStepStart,
  SavaMesOrderStepReport
} from '@/api/scgl'
import { urlAddRandomNo, webapp_ws_ajax_run, webapp_ws_autoupdate } from '@/utils/grwebapp'
import QRCode from 'qrcodejs2'
 
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'SCKBG',
  components: {
    Pagination
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    const validateTypeCode = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请选择上级'))
      } else {
        callback()
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
      isIpad: false,
      // produceCode: '', // 工序码
      // WXproduceCode: '', // 外协工序码
      radioSelected: '', // 工序选中
      WXradioSelected: '', // 工序选中
      form: {
        orderstepqrcode: '', // 扫描的二维码信息
        prop: 'wo_code', // 排序字段
        order: 'asc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      total: 10,
      tableData: [],
      WXform: { // 外协表单
        orderstepqrcode: '', // 扫描的二维码信息
        prop: 'wo_code', // 排序字段z
        order: 'asc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      WXtotal: 10, // 外协表单总数
      WXtableData: [], // 外协表
 
      WXSelectArr: [// 外协类型下拉列表
        { code: 'OUT', name: '发料' },
        { code: 'IN', name: '收料' }
      ],
      WXSelected: 'OUT', // 外协下拉列表选中值
      dialogVisible: false,
      dialogTitle: '', // 自制开始、自制报工、外协发料、外协收料
      dialogForm: {
        wo_code: '', // 工单编号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        stepseq: '', // 工序序号
        stepcode: '', // 工序编码
        stepname: '', // 当前工序名
        nextstepname: '', // 下一道工序名
        stepdesc: '', // 工序描述
        planqty: '', // 任务数量
        reportqty: '', // 已报数量
        noreportqty: '', // 未报数量
        startqty: '', // 开(报)工数量
 
        wxcode: '', // 外协供应商编码
        outuser: '', // 发料人员
        taskqty: '', // 任务数量
        fqty: '', // 发料数量
 
        inuser: '', // 收料人员
        sqty: '', // 收料数量
        ngqty: '', // 不良数量
        badcode: '', // 不良原因编码
 
        noputqty: '', // 不良数量
 
        eqpcode: '', // 生产设备编码
 
        usergroupcode: '', // 班组编码
        reportuser: '', // 报工人员
 
        startqtySum: '' // 不能超过的数值
 
      },
      ZZuserArr: [], // 自制用户所有
      ZZtreams: [], // 自制生产班组数组
      ZZeqpArr: [], // 自制设备名称
      badArr: [], // 不良原因数组
      WXouterprovide: [], // 外协供方数组
      WXoutuser: [], // 发料人员数组
      userTableData: [], // 人员列表
      UserTotal: 0,
      Userform: {},
      userIsSave: false, // 此人员是否可保持
      dialogFormRules: {
        outuser: [
          { required: true, message: '请选择发料人员', trigger: ['blur', 'change'] }
        ],
        fqty: [
          { required: true, message: '请输入发料数量', trigger: ['blur', 'change'] }
        ],
        wxcode: [
          { required: true, message: '请选择外协供方', trigger: ['blur', 'change'] }
        ],
        inuser: [
          { required: true, message: '请选择收料人员', trigger: ['blur', 'change'] }
        ],
        sqty: [
          { required: true, message: '请输入收料数量', trigger: ['blur', 'change'] }
        ],
        // noputqty: [
        //   { required: true, message: '请输入不良数量', trigger: ['blur', 'change'] }
        // ],
        // badcode: [
        //   { required: true, message: '请选择不良原因', trigger: ['blur', 'change'] }
        // ]
        eqpcode: [
          { required: true, message: '请选择生产设备', trigger: ['blur', 'change'] }
        ],
        usergroupcode: [
          { required: true, message: '请选择生产班组', trigger: ['blur', 'change'] }
        ],
        startqty: [
          { required: true, message: '请输入报工数量', trigger: ['blur', 'change'] }
        ]
      },
      activeName: '',
      dialogVisible2: false,
      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('打开之前')
          console.log()
        },
        openCallback(vue) {
          vue.printLoading = false
          console.log('执行了打印')
        }
      },
      qrForm: {
        qrvalue: '',
        startqty: '',
        wo_code: '',
        partcode: '',
        partname: '',
        nextstepname: ''
      }
    }
  },
  // computed: {
  //   qrLink: function() {
  //     return this.$store.getters.getPreviewUrl
  //   }
  // },
  // watch: {
  //   qrLink: function(newVal, oldNew) {
  //     if (newVal !== oldNew) {
  //       this.$nextTick(() => {
  //         this.bindQRCode(newVal)
  //       })
  //     }
  //   }
  // },
  created() {
    this.getMesOrderStepSearch()
    this.tabClick()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
 
    this.$nextTick(() => {
      $("input[name='produceCode']")[0].focus()
      // this.bindQRCode('10001;001')
    })
    // webapp_urlprotocol_startup()
    // webapp_ws_autoupdate(true)
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
    async getMesOrderStepSearch() {
      const res = await MesOrderStepSearch(this.form)
      if (res.code === '200') {
        this.tableData = res.data
        this.total = res.count
      }
    },
    async getMesOrderWxStepSearch() {
      const res = await MesOrderWxStepSearch(this.WXform)
      if (res.code === '200') {
        this.WXtableData = res.data
      }
    },
    // 排序改变时
    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.getMesOrderStepSearch()
    },
    // WX排序改变时
    WXsortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.WXform.order = order
      this.WXform.prop = prop
      this.getMesOrderWxStepSearch()
    },
    // 自制页签原点点击
    getCurrentRow(val) {
 
    },
    // 外协页签原点点击
    getWXCurrentRow(val) {
      console.log(val)
      this.WXradioSelected = val
    },
    // tab按钮切换鼠标自动聚焦
    tabClick(val, d) {
      if (this.$refs.elTabs.currentName === '0') {
        this.$nextTick(() => {
          this.getMesOrderStepSearch()
          $("input[name='produceCode']")[0].focus()
          this.WXform.orderstepqrcode = ''
        })
      }
      if (this.$refs.elTabs.currentName === '1') {
        this.$nextTick(() => {
          this.getMesOrderWxStepSearch()
          $("input[name='WXproduceCode']")[0].focus()
          this.form.orderstepqrcode = ''
        })
      }
    },
    // 扫码键盘回车事件
    async enterNative(val, belong) {
      console.log(val, belong)
      // 开工:code="200"  count=0
      // 报工:code="200"  count=1
      // 发料:code="200"  count=2
      // 收料:code="200"  count=3
      // 走列表形式 code="200"  count=4
      if (belong === 'produceCode') {
        const orderstepqrcode = this.form.orderstepqrcode
        const data = {
          OperType: 'ZZ',
          orderstepqrcode: orderstepqrcode,
          SelectType: ''
        }
        const res = await MesOrderStepStart(data)
        if (res.code === '200' && res.count === 0) {
          await this.ZZstart(res.data)
        }
        if (res.code === '200' && res.count === 1) {
          await this.ZZreport(res.data)
        }
      }
      if (belong === 'WXproduceCode') {
        const orderstepqrcode = this.WXform.orderstepqrcode
        const data = {
          OperType: 'WX',
          orderstepqrcode: orderstepqrcode,
          SelectType: this.WXSelected// OUT、IN
        }
        const res = await MesOrderStepStart(data)
        if (res.code === '200' && res.count === 2) {
          await this.WXsend(res.data)
        }
        if (res.code === '200' && res.count === 3) {
          await this.WXback(res.data)
        }
      }
    },
    // 查询
    search() {
      this.getMesOrderStepSearch()
    },
    // 自制开始
    async ZZstart(obj) {
      // if (!this.ZZisExecutable) {
      //   return this.$message.info('请先扫码工序二维码!')
      // }
      this.dialogTitle = '自制开始'
      this.dialogVisible = true
 
      this.$nextTick(() => {
        this.dialogForm.wo_code = obj.wo_code
        this.dialogForm.partcode = obj.partnumber
        this.dialogForm.partname = obj.partname
        this.dialogForm.partspec = obj.partspec
        this.dialogForm.stepseq = obj.seq
        this.dialogForm.stepcode = obj.stepcode
        this.dialogForm.stepname = obj.stepname
        this.dialogForm.stepdesc = obj.stepdesc
        this.dialogForm.planqty = obj.planqty
        this.dialogForm.reportqty = obj.reportqty
        this.dialogForm.noreportqty = obj.noreportqty
        // this.dialogForm.startqty = obj.startqty
        this.dialogForm.startqty = obj.noreportqty
      })
 
      await this.getMesOrderStepStartSelectEqp()
    },
    // 自制报工
    async ZZreport(obj) {
      // if (!this.ZZisExecutable) {
      //   return this.$message.info('请先扫码工序二维码!')
      // }
      this.dialogTitle = '自制报工'
      this.dialogVisible = true
 
      this.$nextTick(() => {
        this.dialogForm.wo_code = obj.wo_code
        this.dialogForm.partcode = obj.partnumber
        this.dialogForm.partname = obj.partname
        this.dialogForm.partspec = obj.partspec
        this.dialogForm.stepseq = obj.seq
        this.dialogForm.stepcode = obj.stepcode
        this.dialogForm.stepname = obj.stepname
        this.dialogForm.stepdesc = obj.stepdesc
        this.dialogForm.planqty = obj.planqty
        this.dialogForm.reportqty = obj.reportqty
        this.dialogForm.noputqty = obj.noputqty
        this.dialogForm.noreportqty = obj.noreportqty
        // this.dialogForm.startqty = obj.startqty
        this.dialogForm.startqty = obj.noreportqty
 
        if (obj.nextstepname === null || obj.nextstepcode === '') {
          this.dialogForm.nextstepname = obj.stepname
          this.dialogForm.nextstepcode = obj.stepcode
        } else {
          this.dialogForm.nextstepname = obj.nextstepname
          this.dialogForm.nextstepcode = obj.nextstepcode
        }
 
        this.dialogForm.startqtySum = obj.noreportqty
      })
 
      await this.getMesOrderStepStartSelectEqp()
      await this.getMesOrderStepReportSelectUserGroup()
      await this.getMesOrderStepSelectCause('ZZ')
      await this.getMesOrderSelectUserZZ()
    },
    // 外协发料
    async WXsend(obj) {
      // if (this.WXradioSelected.length < 1 && obj.length < 1) {
      //   return this.$message.info('请先选择工序!')
      // }
      // console.log(this.WXform.orderstepqrcode === '', 6)
      // if (this.WXform.orderstepqrcode === '') {
      //   return this.$message.info('请先输入工序!')
      // }
      this.dialogTitle = '外协发料'
      this.dialogVisible = true
 
      this.$nextTick(() => {
        this.dialogForm.wo_code = obj.wo_code
        this.dialogForm.partcode = obj.partnumber
        this.dialogForm.partname = obj.partname
        this.dialogForm.partspec = obj.partspec
        this.dialogForm.stepname = obj.stepname
        this.dialogForm.stepdesc = obj.stepdesc
        this.dialogForm.planqty = obj.planqty
        this.dialogForm.reportqty = obj.reportqty
        this.dialogForm.noreportqty = obj.noreportqty
        this.dialogForm.fqty = obj.startqty
        this.dialogForm.stepcode = obj.stepcode
        this.dialogForm.stepseq = obj.seq
      })
 
      await this.getMesOrderStepSelectWX()
      await this.getMesOrderSelectUser()
    },
    // 外协收料
    async WXback(obj) {
      // if (this.WXform.orderstepqrcode === '') {
      //   return this.$message.info('请先输入工序!')
      // }
      this.dialogTitle = '外协收料'
      this.dialogVisible = true
 
      this.$nextTick(() => {
        this.dialogForm.wo_code = obj.wo_code
        this.dialogForm.partcode = obj.partnumber
        this.dialogForm.partname = obj.partname
        this.dialogForm.partspec = obj.partspec
        this.dialogForm.stepname = obj.stepname
        this.dialogForm.stepdesc = obj.stepdesc
        this.dialogForm.planqty = obj.planqty
        this.dialogForm.reportqty = obj.reportqty
        this.dialogForm.noreportqty = obj.noreportqty
        this.dialogForm.stepcode = obj.stepcode
        if (obj.nextstepname === null || obj.nextstepcode === '') {
          this.dialogForm.nextstepname = obj.stepname
          this.dialogForm.nextstepcode = obj.stepcode
        } else {
          this.dialogForm.nextstepname = obj.nextstepname
          this.dialogForm.nextstepcode = obj.nextstepcode
        }
        this.dialogForm.noputqty = obj.noputqty
        this.dialogForm.stepseq = obj.seq
        this.dialogForm.sqty = obj.startqty
 
        this.dialogForm.startqtySum = obj.startqty
      })
      await this.getMesOrderStepSelectWX()
      await this.getMesOrderSelectUser()
      await this.getMesOrderStepSelectCause('WX')
    },
    // 生产班组下拉改变
    usergroupChange(val) {
      this.dialogForm.usergroupcode = val
      this.getUserTableData()
    },
    // 获取自制报工生产班组下拉列表
    async getMesOrderStepReportSelectUserGroup() {
      const { data: res } = await MesOrderStepReportSelectUserGroup()
      this.ZZtreams = res
    },
    // 获取自制报工表格user所有
    async getMesOrderSelectUserZZ() {
      const { data: res } = await MesOrderSelectUser({ usercode: this.dialogForm.usergroupcode })
      this.ZZuserArr = res
    },
    // 获取自制生产设备下拉
    async getMesOrderStepStartSelectEqp() {
      const { data: res } = await MesOrderStepStartSelectEqp({ orderstepqrcode: this.form.orderstepqrcode })
      this.ZZeqpArr = res
    },
    // 获取WX供方接口
    async getMesOrderStepSelectWX() {
      const { data: res } = await MesOrderStepSelectWX({ orderstepqrcode: this.WXform.orderstepqrcode })
      this.WXouterprovide = res
    },
    // 获取收发料人员下拉接口
    async getMesOrderSelectUser() {
      const { data: res } = await MesOrderSelectUser({ usercode: this.dialogForm.outuser })
      this.WXoutuser = res
    },
    // 获取收料不良原因下拉
    async getMesOrderStepSelectCause(val) {
      let orderstepqrcode = ''
      if (val === 'WX') {
        orderstepqrcode = this.WXform.orderstepqrcode
      }
      if (val === 'ZZ') {
        orderstepqrcode = this.form.orderstepqrcode
      }
      const { data: res } = await MesOrderStepSelectCause({ orderstepqrcode: orderstepqrcode })
      this.badArr = res
    },
    // 报工查询用户表
    async getUserTableData() {
      const { data: res } = await MesOrderGroupSelectUser({ usergroupcode: this.dialogForm.usergroupcode })
      this.userTableData = res
      this.userTableData.forEach(item => {
        let number = Math.random() * Math.random()// 作为删除时的标识符
        number = number === 0 ? (10 + Math.random()) : number
        item.isVisible = 0
        item.number = number
      })
    },
    // 用户添加
    userAdd() {
      let number = Math.random() * Math.random()// 作为删除时的标识符
      number = number === 0 ? (10 + Math.random()) : number
      console.log(this.userTableData, 6)
      this.userTableData.unshift({ usercode: '', username: '', isVisible: 1, number: number })
    },
    // 用户列表删除
    userDel(row) {
      this.userTableData.forEach((item, index) => {
        if (item.number === row.number) {
          this.userTableData.splice(index, 1)
        }
      })
    },
    // 用户列表保存
    userSave(row) {
      console.log(row, 123)
      if (row.usercode === '') {
        return this.$message.info('人员名称不能为空!')
      }
      this.userTableData.forEach(item => {
        if (item.number === row.number) {
          item.isVisible = 0
        }
      })
    },
    // 用户列表取消
    userCancel(row) {
      this.userTableData.forEach((item, index) => {
        if (item.number === row.number) {
          this.userTableData.splice(index, 1)
        }
      })
    },
    // 用户列表人员名称值选中
    usernameChange(val, row) {
      this.userTableData.forEach(item => {
        if (item.usercode === val) {
          this.userIsSave = true
          return this.$message.info('此人员已在列中!')
        }
        if (item.number === row.number) {
          this.userIsSave = false
          item.usercode = val
          item.username = this.ZZuserArr.find(item => item.usercode === val).username
        }
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.wo_code = '', // 工单编号
      this.dialogForm.partcode = '', // 产品编码
      this.dialogForm.partname = '', // 产品名称
      this.dialogForm.partspec = '', // 产品规格
      this.dialogForm.stepseq = '', // 工序序号
      this.dialogForm.stepcode = '', // 工序编码
      this.dialogForm.stepname = '', // 当前工序名
      this.dialogForm.nextstepname = '', // 下一道工序名
      this.dialogForm.stepdesc = '', // 工序描述
      this.dialogForm.planqty = '', // 任务数量
      this.dialogForm.reportqty = '', // 已报数量
      this.dialogForm.noreportqty = '', // 未报数量
      this.dialogForm.startqty = '', // 开(报)工数量
 
      this.dialogForm.wxcode = '', // 外协供应商编码
      this.dialogForm.outuser = '', // 发料人员
      this.dialogForm.taskqty = '', // 任务数量
      this.dialogForm.fqty = '', // 发料数量
 
      this.dialogForm.inuser = '', // 收料人员
      this.dialogForm.sqty = '', // 收料数量
      this.dialogForm.ngqty = '', // 不良数量
      this.dialogForm.badcode = '', // 不良原因编码
 
      this.dialogForm.noputqty = '', // 不良数量
 
      this.dialogForm.eqpcode = '', // 生产设备编码
 
      this.dialogForm.usergroupcode = '', // 班组编码
      this.dialogForm.reportuser = '', // 报工人员
 
      this.dialogForm.startqtySum = '' // 不能超过的数值
 
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
      this.tabClick()
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          if (this.dialogTitle === '外协发料') {
            if (parseFloat(this.dialogForm.fqty) > parseFloat(this.dialogForm.noreportqty)) {
              return this.$message.info('发料数量不能大于未发数量!')
            }
            const data = {
              mesordercode: this.dialogForm.wo_code, // 工单编号
              partcode: this.dialogForm.partcode, // 产品编码
              stepseq: this.dialogForm.stepseq, // 工序序号   暂时缺
              stepcode: this.dialogForm.stepcode, // 工序编码
              wxcode: this.dialogForm.wxcode, // 外协供应商编码
              outuser: this.dialogForm.outuser, // 发料人员
              taskqty: this.dialogForm.planqty, // 任务数量
              fqty: this.dialogForm.fqty // 发料数量
            }
            SavaMesOrderStepOut(data).then(res => {
              if (res.code === '200') {
                this.$message.success('发料成功!')
                this.dialogVisible = false
                this.tabClick()
              } else {
                this.$message.error('发料失败!')
              }
            })
          }
 
          if (this.dialogTitle === '外协收料') {
            if (parseFloat(this.dialogForm.startqtySum) < parseFloat(this.dialogForm.sqty) + parseFloat(this.dialogForm.noputqty)) {
              return this.$message.info('收料数量加不良数量不能大于了未收数量!')
            }
 
            if (parseFloat(this.dialogForm.noputqty) > 0) {
              if (this.dialogForm.badcode.length < 1) {
                return this.$message.info('请选择不良原因!')
              }
            }
 
            const data = {
              mesordercode: this.dialogForm.wo_code, // 工单编号
              partcode: this.dialogForm.partcode, // 产品编码
              stepseq: this.dialogForm.stepseq, // 工序序号
              stepcode: this.dialogForm.stepcode, // 工序编码
              wxcode: this.dialogForm.wxcode, // 外协供应商编码
              inuser: this.dialogForm.inuser, // 发料人员
              taskqty: this.dialogForm.planqty, // 任务数量
              sqty: this.dialogForm.sqty, // 收料数量
              ngqty: this.dialogForm.noputqty === '' ? 0 : this.dialogForm.noputqty, // 不良数量
              badcode: this.dialogForm.badcode.length < 1 ? '' : this.dialogForm.badcode.join(';')// 不良原因
            }
            SavaMesOrderStepIn(data).then(res => {
              if (res.code === '200') {
                this.WXprint2()
                this.$message.success('收料成功!')
                this.dialogVisible = false
                this.dialogVisible2 = true
                this.tabClick()
              } else {
                this.$message.error('收料失败!')
              }
            })
          }
 
          if (this.dialogTitle === '自制开始') {
            const data = {
              mesordercode: this.dialogForm.wo_code, // 工单编号
              partcode: this.dialogForm.partcode, // 产品编码
              stepseq: this.dialogForm.stepseq, // 工序序号   暂时缺
              stepcode: this.dialogForm.stepcode, // 工序编码
              eqpcode: this.dialogForm.eqpcode, // 生产设备
              taskqty: this.dialogForm.planqty, // 任务数量
              startqty: this.dialogForm.startqty// 开始数量
            }
            SavaMesOrderStepStart(data).then(res => {
              if (res.code === '200') {
                this.$message.success('开工成功!')
                this.dialogVisible = false
                this.tabClick()
              } else {
                this.$message.error('开工失败!')
              }
            })
          }
 
          if (this.dialogTitle === '自制报工') {
            if (parseFloat(this.dialogForm.startqtySum) < parseFloat(this.dialogForm.startqty) + parseFloat(this.dialogForm.noputqty)) {
              return this.$message.info('报工数量加不良数量不能大于了未报数量!')
            }
            if (this.userTableData.length < 1) {
              return this.$message.info('人员列表不能为空!')
            }
 
            if (parseFloat(this.dialogForm.noputqty) > 0) {
              if (this.dialogForm.badcode.length < 1) {
                return this.$message.info('请选择不良原因!')
              }
            }
 
            const reportuser = this.userTableData.map(item => item.usercode).join(';')
            const data = {
              mesordercode: this.dialogForm.wo_code, // 工单编号
              partcode: this.dialogForm.partcode, // 产品编码
              stepseq: this.dialogForm.stepseq, // 工序序号
              stepcode: this.dialogForm.stepcode, // 工序编码
              eqpcode: this.dialogForm.eqpcode, // 设备编码
              usergroupcode: this.dialogForm.usergroupcode, // 班组编码
              reportuser: reportuser, // 报工人员
              taskqty: this.dialogForm.planqty, // 任务数量
              // startqty: this.dialogForm.startqty, // 开工数量
              startqty: this.dialogForm.reportqty, // 开工数量
              // reportqty: this.dialogForm.reportqty, // 报工数量
              reportqty: this.dialogForm.startqty, // 报工数量
              ngqty: this.dialogForm.noputqty === '' ? 0 : this.dialogForm.noputqty, // 不良数量
              badcode: this.dialogForm.badcode.length < 1 ? '' : this.dialogForm.badcode.join(';')// 不良原因
            }
 
            SavaMesOrderStepReport(data).then(res => {
              if (res.code === '200') {
                this.ZZprint2()
                this.$message.success('报工成功!')
                this.dialogVisible = false
                this.dialogVisible2 = true
                this.tabClick()
              } else {
                this.$message.error('报工失败!')
              }
            })
          }
        }
      })
    },
    // 生成二维码
    bindQRCode(text) {
      new QRCode(this.$refs.qrCodeDiv2, {
        text: text,
        width: 50,
        height: 50,
        colorDark: '#000', // 二维码颜色
        colorLight: '#ffffff', // 二维码背景色
        correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
      })
    },
    ZZprint2() {
      this.qrForm.qrvalue = this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode
      this.qrForm.startqty = this.dialogForm.startqty
      this.qrForm.wo_code = this.dialogForm.wo_code
      this.qrForm.partcode = this.dialogForm.partcode
      this.qrForm.partname = this.dialogForm.partname
      this.qrForm.nextstepname = this.dialogForm.nextstepname
 
      this.$nextTick(() => {
        this.bindQRCode(this.qrForm.qrvalue)
        console.log(this.$refs.qrCodeDiv2, 123)
        // console.log(this.$refs.qrCodeDiv2.querySelectorAll('#qrCode2>img'), 1)
        // console.log(this.$refs.qrCodeDiv2.querySelectorAll('#qrCode2>canvas'), 2)
      })
    },
    WXprint2() {
      this.qrForm.qrvalue = this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode
      this.qrForm.startqty = this.dialogForm.sqty
      this.qrForm.wo_code = this.dialogForm.wo_code
      this.qrForm.partcode = this.dialogForm.partcode
      this.qrForm.partname = this.dialogForm.partname
      this.qrForm.nextstepname = this.dialogForm.nextstepname
      this.$nextTick(() => {
        this.bindQRCode(this.qrForm.qrvalue)
      })
    },
    dialogVisible2Close() {
      this.qrForm.qrvalue = ''
      this.qrForm.startqty = ''
      this.qrForm.wo_code = ''
      this.qrForm.partcode = ''
      this.qrForm.partname = ''
      this.qrForm.nextstepname = ''
      this.$refs.qrCodeDiv2 = ''
    },
 
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 220
        this.isIpad = window.innerHeight < 769
        if (window.innerHeight < 769) {
          this.tableHeight = this.tableHeight - 50
        }
      })
    }
  }
}
</script>
 
<style lang="scss" scoped>
$main_color: #42b983;
.el-button--text{
  font-size: 14px;
  cursor: pointer;
}
.operationClass {
  height: 23px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
::v-deep .el-checkbox.is-bordered + .el-checkbox.is-bordered {
  margin: 10px 30px 0px 0;
}
 
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color;
}
 
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0px 0;
}
 
//.dialogVisible{
::v-deep .el-select .el-input .el-select__caret {
  display: flex;
  align-items: center;
  justify-content: center;
}
 
//}
.elTableDiv {
  ::v-deep .el-radio__label {
    display: none;
  }
}
</style>
<style media="print">
/*@media print {*/
@page {
  size: auto;
  margin: 3mm;
  font-size: 10px;
}
 
</style>
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
.el-icon-share ,.el-icon-delete,.el-icon-edit-outline{
  color: $main_color;
  cursor: pointer;
}
.el-icon-edit-outline{
  margin-right: 15px;
}
::v-deep .el-button--primary, .el-button--default, .el-button--info {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 15px;
}
 
::v-deep .el-button--primary {
  //background-color: $main_color !important;
}
 
::v-deep .el-button--default {
  background-color: #f8f8fa;
  border: none;
}
 
::v-deep .el-input__inner {
  height: 34px;
  line-height: 34px;
  //color: #a7a7a7;
}
 
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
 
::v-deep .dialogVisibleRoles .el-dialog__body {
  padding: 20px 20px !important;
}
 
::v-deep .importPickerClass .el-dialog__body {
  padding: 20px 20px !important;
}
 
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
 
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
 
::v-deep .cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
 
::v-deep .el-table::before {
  height: 0;
}
 
::v-deep .el-table__body-wrapper {
  background-color: #f8f8fa;
}
 
::v-deep .el-table__body .el-table__row.hover-row td{
  background-color: #eaecef ;
}
 
::v-deep .el-form--inline .el-form-item__label {
  color: #a7a7a7;
}
 
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
 
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
 
</style>
<style>
 
.el-table .custom-row {
  background: #f8f8fa;
}
</style>