wtt
2025-03-17 980207d432914dce2d63a4358db2a5fcdcc7434f
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
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>工序单品不良采集</title>
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../CreateControl.js"></script>
</head>
<body>
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-card" style="padding: 2px;background-color: #efefef;">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                    <div style="padding: 2px; ">
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="set_AddNew" id="set_AddNew">新增</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave_BL" id="btnSave_BL">不良品保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave_BF" id="btnSave_BF">报废保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave_WXP" id="btnSave_WXP">微瑕品保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnEdit" id="btnEdit">退出</button>
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
                            <li lay-id="2" style="padding:1px;">其他信息</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--基本信息-->
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">条形码</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBarCodeSN" autocomplete="off" lay-verify="HBarCodeSN" id="HBarCodeSN" style="width:500px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">当前车间<label style="color:red"> * </label></label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" lay-verify="HDeptName" name="HDeptName" id="HDeptName" style="background-color:#efefef4d;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" lay-verify="HDeptID" name="HDeptID" id="HDeptID">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">当前工序</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" lay-verify="HProName" name="HProName" id="HProName" style="background-color:#efefef4d;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" lay-verify="HProcID" name="HProcID" id="HProcID" value="0">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">不良原因</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" lay-verify="HBadReasonName" name="HBadReasonName" id="HBadReasonName" value="" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" lay-verify="HBadReasonID" name="HBadReasonID" id="HBadReasonID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHBadReason" id="btnHBadReason" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <!--<div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">不良后果</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" name="HMaterModel" id="HMaterModel" onmouseover="this.title=this.value" style="background-color: #efefef4d; width: 60%; display: inline-block;" readonly>
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnUnit" id="btnUnit" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>-->
 
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">单据号</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HInterID" id="HInterID" lay-verify="HInterID">
                                                <input type="hidden" name="HBillNo_bak" id="HBillNo_bak" lay-verify="HBillNo_bak">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">不良类型</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBadTypeName" lay-verify="HBadTypeName" id="HBadTypeName" style="background-color:#efefef4d;display: inline-block;" readonly>
                                                <input type="hidden" name="HBadTypeID" id="HBadTypeID" lay-verify="HBadTypeID" value="0">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">质检员</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" lay-verify="HEmpName" name="HEmpName" id="HEmpName" value="" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" lay-verify="HEmpID" name="HEmpID" id="HEmpID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHEmp" id="btnHEmp" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <!--<div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">判断结果</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" lay-verify="HMainProcIDName" name="HMainProcIDName" id="HMainProcIDName" value="" style="background-color:#efefef4d;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" name="HMainProcID" id="HMainProcID" lay-verify="HMainProcID" value="0">
                                            </div>
                                        </div>-->
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">产品MAC</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" lay-verify="HAddr" name="HAddr" id="HAddr" value="">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">产品SN</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBarCode" lay-verify="HBarCode" id="HBarCode" value="" style="background-color:#efefef4d;display: inline-block;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">生产订单</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HICMOBillNo" lay-verify="HICMOBillNo" id="HICMOBillNo" value=""  style="background-color:#efefef4d;">
                                                <input type="hidden" class="layui-input" name="HICMOInterID" lay-verify="HICMOInterID" id="HICMOInterID" value="0" >
                                                <input type="hidden" class="layui-input" name="HICMOEntryID" lay-verify="HICMOEntryID" id="HICMOEntryID" value="0" >
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">工序流转卡</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HProcExchBillNo" lay-verify="HProcExchBillNo" id="HProcExchBillNo" value="" style="background-color:#efefef4d;">
                                                <input type="hidden" class="layui-input" name="HProcExchInterID" lay-verify="HProcExchInterID" id="HProcExchInterID" value="0">
                                                <input type="hidden" class="layui-input" name="HProcExchEntryID" lay-verify="HProcExchEntryID" id="HProcExchEntryID" value="0">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px; padding: 9px 18px;">生产班组</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" name="HGroupName" id="HGroupName" lay-verify="HGroupName" value="" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" name="HGroupID" lay-verify="HGroupID" id="HGroupID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHGroup" id="btnHGroup" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px; padding: 9px 18px;">生产资源</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" name="HSourceName" id="HSourceName" lay-verify="HSourceName" value="" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <input type="hidden" class="layui-input" name="HSourceID" lay-verify="HSourceID" id="HSourceID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHSource" id="btnHSource" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">物料编码</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMaterNumber" id="HMaterNumber" lay-verify="HMaterNumber" value="" style="background-color:#efefef4d;">
                                                <input type="hidden" class="layui-input" name="HMaterID" lay-verify="HMaterID" id="HMaterID" value="0">
                                                <input type="hidden" class="layui-input" name="HProdOrgID" lay-verify="HProdOrgID" id="HProdOrgID" value="0">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">物料名称</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" lay-verify="HMaterName" name="HMaterName" id="HMaterName" value="" style="background-color:#efefef4d;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">规格型号</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HModel" id="HModel" lay-verify="HModel" placeholder="请输入内容" >
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">备注</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HRemark" id="HRemark" lay-verify="HRemark" placeholder="请输入内容" onmouseover="this.title=this.value" style=" width: 500px;">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--其他信息-->
                            <div class="layui-tab-item">
                                <div class="layui-form-item">
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">制单人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMaker" id="HMaker" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">审核人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hchecker" id="hchecker" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">启用人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="" id="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">制单日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hmakedate" id="hmakedate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">审核日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hcheckdate" id="hcheckdate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">启用日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="" id="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">关闭人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="" id="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">修改人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hupdater" id="hupdater" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">作废人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hdeleteman" id="hdeleteman" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">关闭日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="" id="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">修改日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hupdatedate" id="hupdatedate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">作废日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="hdeletedate" id="hdeletedate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
<script>
 
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
 
        //#region 公共变量
 
        var $ = layui.$
            , admin = layui.admin
            , layer = layui.layer
            , table = layui.table
            , form = layui.form
            , element = layui.element;
 
        //定义全局变量
     
        var HModName = "Cj_CollectionOfSingleProductDefects";
        //#endregion
 
        //#region 进入页面即加载
 
        var params = getUrlVars();
        var OperationType = params[params[0]]; //从参数中获取 数据类型  1添加 保存  2复制  3 编辑 4添加子工艺路线
        var linterid = params[params[1]]; //从参数中获取 单据内码
        var HProcExchBillNo = params[params[2]]; //从参数中获取 单据内码
        var HBillSubType = params[params[3]]; //从参数中获取 单据内码
        //制单人
        $("#HMaker").val(sessionStorage["HUserName"]);
        $("#hmakedate").val(Format(new Date(), "yyyy-MM-dd"));
        $("#HProdOrgID").val(sessionStorage["OrganizationID"]);
 
        if (HBillSubType === '3717-1') {
            document.getElementById('btnSave_BL').style.display = 'none';
            document.getElementById('btnSave_BF').style.display = 'none';
        } else {
            document.getElementById('btnSave_WXP').style.display = 'none';
        }
 
     
        //判断是否新增
        if (OperationType == 1) {
 
            $.ajax({
                url: GetWEBURL() + "/Web/GetMAXNum",
                type: "GET",
                data: { "HBillType": '3717' },
                success: function (d) {
                    //console.log(d.data);
                    $("#HInterID").val(d.data[0].HInterID);
                    $("#HBillNo").val(d.data[0].HBillNo);
                    $("#HBillNo_bak").val(d.data[0].HBillNo);
                }
            });
            //初始化界面
            set_ClearBill();
        }
 
 
 
        //#endregion
 
        //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
 
        //条形码回车方法
        $('#HBarCodeSN').on('keydown', function (event) {
            var HBarCode = $('#HBarCodeSN').val();
            if (event.keyCode == 13) {
                if (!HBarCode) {
                    layer.msg("条形码不能为空!")
                    return;
                } else {
                    if (HBarCode.length != 29 && HBarCode.length != 50) {
                        layer.alert("子件条码长度不为29位或50位!", { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        return;
                    }
 
                    if (HBarCode.match(/[^\x00-\xff]/g) != null) {
                        layer.alert("必须是半角字符!", { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        return;
                    }
                }
                txtHBarCode_KeyDown(HBarCode);
            }
        });
 
        //选择不良原因
        form.on('submit(btnHBadReason)', function () {
            btnHBadReason();
        });
 
        //选择质检员
        form.on('submit(btnHEmp)', function () {
            btnHEmp();
        });
 
        //选择生产资源
        form.on('submit(btnHSource)', function () {
            btnHSource();
        });
 
        //选择生产班组按钮
        form.on('submit(btnHGroup)', function () {
            btnHGroup();
        });
 
        //新增
        form.on('submit(set_AddNew)', function () {
            if (HBillSubType=='3717-1') {
                layer.confirm('新增后页面数据将消失?', { icon: 3, title: '提示' }, function (index) {
                    location.replace('Cj_CollectionOfSingleProductDefects.html?OperationType=1&linterid=' + linterid + '&HProcExchBillNo=&HBillSubType=3717-1');
                });
            } else{
                layer.confirm('新增后页面数据将消失?', { icon: 3, title: '提示' }, function (index) {
                    location.replace('Cj_CollectionOfSingleProductDefects.html?OperationType=1&linterid=' + linterid);
                });
            }          
        });
 
        //保存提交
        form.on('submit(btnSave_BL)', function (data) {//提交
            if (AllowLoadData(data)) {
                set_AddNew(data,"不良");
            }
        });
 
        form.on('submit(btnSave_BF)', function (data) {//提交
            if (AllowLoadData(data)) {
                set_AddNew(data,"报废");
            }
        });
 
        form.on('submit(btnSave_WXP)', function (data) {//提交
            if (AllowLoadData(data)) {
                set_AddNew(data, "微瑕品");
            }
        });
 
        //退出
        form.on('submit(btnEdit)', function (data) {
            if (params[1] != null) {
                Pub_Close(1);
            } else if (params[1] == null) {
                Pub_Close(2);
            }
        });
 
 
        //#endregion
 
        //#region 此页面所有的方法
 
        //初始化界面
        function set_ClearBill() {
            get_Display();
        }
 
        //查询
        function get_Display() {
            var sWhere = " and 编码='" + sessionStorage["Czybm"]+"'";
            var ajaxLoad = layer.load();
            //进入页面显示的缓存列表
            $.ajax({
                url: GetWEBURL() + '/Cj_SingleStation/Cj_CollectionOfSingleProductDefectsUserList',
                type: "GET",
                data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
                success: function (data1) {
                    if (data1.count == 1) {
 
                        $("#HDeptID").val(data1.data[0]["HDeptID"]);
                        $("#HDeptName").val(data1.data[0]["车间"]);
                        $("#HProName").val(data1.data[0]["工序"]);
                        $("#HProcID").val(data1.data[0]["HProcID"]);
                        $("#HSourceID").val(data1.data[0]["HSourceID"]);
                        $("#HSourceName").val(data1.data[0]["生产资源"]);
                        $("#HEmpID").val(data1.data[0]["HEmpID"]);
                        $("#HEmpName").val(data1.data[0]["质检员"]);
                        $("#HGroupID").val(data1.data[0]["HGroupID"]);
                        $("#HGroupName").val(data1.data[0]["生产班组"]);
                        layer.close(ajaxLoad);
                     
                        //layer.alert("查询成功", { icon: 1 });
                    } else {
                        layer.close(ajaxLoad);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
 
            });
        }
 
        //条码回车查询
        function txtHBarCode_KeyDown(HBarCode) {
 
            var indexs = layer.load();
            $.ajax({
                type: "GET",
                url: GetWEBURL() + "/Cj_SingleStation/SNHBardCodeList",
                async: false,
                data: { "HBarCode": HBarCode, "HProcExchBillNo": HProcExchBillNo, "user": sessionStorage["HUserName"], "HOrgID": sessionStorage["OrganizationID"] },
                dataType: "json",
                success: function (data1) {
                    if (data1.count == 1) {
                        layer.close(indexs);
                        var index = layer.load();
 
                        $.ajax({
                            type: "GET",
                            url: GetWEBURL() + "/Cj_SingleStation/HBardCodeList",
                            async: false,
                            data: { "HBarCode": HBarCode, "user": sessionStorage["HUserName"] },
                            dataType: "json",
                            success: function (data1) {
                                if (data1.count == 1) {
                                    layer.close(index);
 
                                    var numHProcess = 0;
                                    for (var i = 0; i < data1.data.length; i++) {
                                        if (data1.data[i]["HProcID"] == $("#HProcID").val()) {
                                            numHProcess = data1.data[i]["HProcExchEntryID"];
                                            break;
                                        }
                                    }
 
                                    $("#HICMOBillNo").val(data1.data[0]["生产订单"]);
                                    $("#HICMOInterID").val(data1.data[0]["HICMOInterID"]);
                                    $("#HICMOEntryID").val(data1.data[0]["HICMOEntryID"]);
                                    $("#HProcExchBillNo").val(data1.data[0]["工序流转卡"]);
                                    $("#HProcExchInterID").val(data1.data[0]["HSourceInterID"]);
                                    $("#HProcExchEntryID").val(numHProcess);
                                    $("#HMaterNumber").val(data1.data[0]["物料编码"]);
                                    $("#HMaterID").val(data1.data[0]["HMaterID"]);
                                    $("#HMaterName").val(data1.data[0]["物料名称"]);
                                    $("#HModel").val(data1.data[0]["规格型号"]);
                                    $("#HBarCode").val(data1.data[0]["条码"]);
 
                                }
                                else {
                                    layer.close(index);
                                    layer.msg(data1.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                                }
                                $("#HBarCodeSN").val("");
                            },
                            error: function (err) {
                                layer.close(index);
                                layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            }
                        });
                    }
                    else {
                        layer.close(indexs);
                        layer.msg(data1.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                    $("#HBarCodeSN").val("");
                },
                error: function (err) {
                    layer.close(indexs);
                    layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                }
            });
 
          
        }
 
         //不良原因选择页面
        function btnHBadReason() {
            layer.open({
                type: 2//弹窗类型
                , skin: 'layui-layer-rim' //加上边框
                , area: ['90%', '90%']//大小
                , title: '不良原因列表'//标题
                , shift: 2//弹出动画
                , content: ['../../基础资料/生产基础资料/Gy_BadReason.html', 'yes']
                , btn: ['确定', '取消']
                , btn1: function (index, layero) {//按钮【按钮一】的回调
                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    if (checkStatus.data.length === 0) {
                        return layer.msg('请选择数据');
                    }
                    //获取数据
                    $("#HBadReasonID").val(checkStatus.data[0].HItemID);
                    $("#HBadReasonName").val(checkStatus.data[0].不良缺陷名称);
                    $("#HBadTypeName").val(checkStatus.data[0].不良类型);
                    $("#HBadTypeID").val(checkStatus.data[0].不良类型代码);
                    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                }
            })
        }
 
         //质检员选择页面
        function btnHEmp() {
            layer.open({
                type: 2//弹窗类型
                , skin: 'layui-layer-rim' //加上边框
                , area: ['90%', '90%']//大小
                , title: '质检员列表'//标题
                , shift: 2//弹出动画
                , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html', 'yes']
                , btn: ['确定', '取消']
                , btn1: function (index, layero) {//按钮【按钮一】的回调
                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    if (checkStatus.data.length === 0) {
                        return layer.msg('请选择数据');
                    }
                    //获取数据
                    $("#HEmpID").val(checkStatus.data[0].HItemID);
                    $("#HEmpName").val(checkStatus.data[0].职员名称);
 
                    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                }
            })
        }
 
        //生产资源选择页面
        function btnHSource() {
            layer.open({
                type: 2//弹窗类型
                , skin: 'layui-layer-rim' //加上边框
                , area: ['90%', '90%']//大小
                , title: '生产资源列表'//标题
                , shift: 2//弹出动画
                , content: ['../../基础资料/生产基础资料/Gy_Source.html', 'yes']
                , btn: ['确定', '取消']
                , btn1: function (index, layero) {//按钮【按钮一】的回调
                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    if (checkStatus.data.length === 0) {
                        return layer.msg('请选择数据');
                    }
                    //获取数据
                    $("#HSourceID").val(checkStatus.data[0].HItemID); 
                    $("#HSourceName").val(checkStatus.data[0].生产资源名称);
 
                    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                }
                , btn2: function (index, layero) { }
            })
        }
 
        //生产班组选择页面
        function btnHGroup() {
            layer.open({
                type: 2//弹窗类型
                , skin: 'layui-layer-rim' //加上边框
                , area: ['90%', '90%']//大小
                , title: '班组表'//标题
                , shift: 2//弹出动画
                , content: ['../../基础资料/工资基础资料/Gy_Group.html', 'yes']
                , btn: ['确定', '取消']
                , btn1: function (index, layero) {//按钮【按钮一】的回调
                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    if (checkStatus.data.length != 1) {
                        return layer.msg('请选择一条数据');
                    }
                    //获取数据
                    $("#HGroupID").val(checkStatus.data[0].HItemID);//班组id
                    $("#HGroupName").val(checkStatus.data[0].班组名称);//计量单位名称
 
                    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                }
                , btn2: function (index, layero) { }
            })
        }
 
        //获取参数
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
 
        //保存HMaker
        function set_AddNew(data, HResult) {
 
            var sMainStr = JSON.stringify(data.field);
 
            var sMainSub = sMainStr + ';' + HResult + ";" + sessionStorage["HUserName"] +";"+ linterid ;
 
            var index = layer.load();
            $.ajax({
                type: "POST",
                url: GetWEBURL() + "/Cj_SingleStation/ProcessBLSave",
                async: false,
                data: { "sMainSub": sMainSub },
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) {
                        $('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);
                        layer.close(index);
                        layer.msg("提交成功");
                    }
                    else {
                        layer.close(index);
                        layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                },
                error: function (err) {
                    layer.close(index);
                    layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                }
            });
        }
 
        //非空验证
        function AllowLoadData(data) {
 
            var HBarCode = $("#HBarCode").val();
            if (HBarCode == "") {
                layer.msg("产品SN不能为空!")
                return false;
            }
 
            var HBadReasonID = $("#HBadReasonID").val();
            if (HBadReasonID == 0) {
                layer.msg("不良原因不能为空!")
                return false;
            }
            return true;
        }
 
        //#endregion
 
    });
</script>