loulijun2021
2023-03-08 43c4e92784dcfb82872a3f1ff2e49ea0f054c7e2
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
<template>
  <div>
    <div class="body" style="padding: 0;height: 100%" :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="tableHeight+'px'"
              border
              stripe
              :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"
              />
              <!--              <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="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="tableHeight+'px'"
              border
              stripe
              :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"
              />
              <!--              <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="prev, pager, next,sizes"
            popper-class="select_bottom"
            @pagination="getMesOrderStepSearch"
          />
        </el-tab-pane>
      </el-tabs>
 
    </div>
 
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="800"
      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
            stripe
            :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"
            />
            <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="操作"
            >
              <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="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>
  </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'
 
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,
      // 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: ''
    }
  },
  created() {
    this.getMesOrderStepSearch()
    this.tabClick()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
 
    this.$nextTick(() => {
      $("input[name='produceCode']")[0].focus()
    })
    // webapp_urlprotocol_startup()
    webapp_ws_autoupdate(true)
  },
  methods: {
    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) {
      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.WXprint()
                this.$message.success('收料成功!')
                this.dialogVisible = false
                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.ZZprint()
                this.$message.success('报工成功!')
                this.dialogVisible = false
                this.tabClick()
              } else {
                this.$message.error('报工失败!')
              }
            })
          }
        }
      })
    },
    async ZZprint() {
      const obj = {
        recordset: [
          {
            wo_code: this.dialogForm.wo_code, // 工单编号
            partcode: this.dialogForm.partcode, // 产品编码
            partname: this.dialogForm.partname, // 产品名称
            next_stepname: this.dialogForm.nextstepname, // 下道工序
            qty: this.dialogForm.startqty, // 数量
            // qrcode: this.form.orderstepqrcode// 二维码
            qrcode: this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode // 二维码
          }
        ]
      }
      const args = {
        type: 'print', // preview  print
        showOptionDlg: false, // 如果不显示打印对话框而直接打印,将此行注释去掉即可
        report: urlAddRandomNo('./static/grf/报工产出标签.grf'),
        data: obj
      }
      webapp_ws_ajax_run(args)
    },
    // 外协收料打印
    WXprint() {
      // 参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
      const obj = {
        recordset: [
          {
            wo_code: this.dialogForm.wo_code, // 工单编号
            partcode: this.dialogForm.partcode, // 产品编码
            partname: this.dialogForm.partname, // 产品名称
            next_stepname: this.dialogForm.nextstepname, // 下道工序
            qty: this.dialogForm.sqty, // 数量
            // qrcode: this.WXform.orderstepqrcode// 二维码
            qrcode: this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode// 二维码
          }
        ]
      }
      const args = {
        type: 'print', // preview  print
        showOptionDlg: false, // 如果不显示打印对话框而直接打印,将此行注释去掉即可
        report: urlAddRandomNo('./static/grf/外协收料标签.grf'),
        data: obj
      }
      webapp_ws_ajax_run(args)
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 250
        this.tableHeight = this.mainHeight - 80
      })
    }
  }
}
</script>
 
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--primary {
  background-color: $main_color !important;
  height: 30px;
  display: flex;
  align-items: center;
  //border: 1px solid $main_color;
  border: none;
  padding: 0 20px;
}
 
::v-deep .el-button--primary:hover {
  border: none;
}
 
::v-deep .el-button--info {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
 
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: $main_color !important;
}
 
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
 
.footerButton {
  display: flex;
  justify-content: end;
}
 
::v-deep .el-button--default {
  background-color: #ffffff !important;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
 
::v-deep .el-button--default:hover {
  color: #606266;
}
 
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
 
::v-deep .el-radio__input.is-checked .el-radio__inner {
  background-color: $main_color;
  border-color: $main_color;
}
 
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color !important;
}
 
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
  border-color: $main_color;
  background-color: $main_color;
}
 
::v-deep .el-input__inner {
  height: 30px;
  line-height: 30px;
}
 
::v-deep .el-input__inner:focus {
  border-color: $main_color;
}
 
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
 
::v-deep .cell {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
 
::v-deep .el-button--text {
  color: $main_color;
  font-size: 14px;
  cursor: pointer;
}
 
.operationClass {
  height: 23px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.el-icon-share {
  color: $main_color;
  cursor: pointer;
}
 
.el-checkbox.is-bordered.is-checked {
  border-color: $main_color;
}
 
::v-deep .el-radio__input.is-checked .el-radio__inner {
  border-color: $main_color;
  background: $main_color;
}
 
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  border-color: $main_color;
  background: $main_color;
}
 
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
  color: $main_color !important;
}
 
::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;
}
 
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
 
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
 
::v-deep .el-input__inner:focus {
  border-color: $main_color;
}
 
::v-deep .el-select .el-input__inner:focus {
  border-color: $main_color;
}
 
::v-deep .el-select-dropdown__item.selected {
  color: $main_color;
}
 
::v-deep .el-checkbox__inner:hover {
  border-color: $main_color;
}
 
::v-deep .el-textarea__inner:focus {
  border-color: $main_color;
}
 
//.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>