wtt
2025-04-11 6c97d33a418d35b2aeab0fac79f77490dd20d162
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title class="sckgd">生产开工单</title>
    <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">
    <!--引用layui样式文件-->
    <link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
    <!--引用layui js文件-->
    <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="../../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <!--自定义样式-->
    <style>      
        .layui-form-label {
            font-size: 14px;
            width: 85px;
            text-align: inherit;
        }
        /*全局设置输入框高度*/
        .layui-input {
            height: 30px;
        }
        /*设置表头输入框*/
        .t1_input {
            padding: 1%;
        }
        /*本站信息td*/
        .bz_td {
            display: -webkit-box; /*设置按钮不换行*/
            padding: 1%; /*设置输入框边距*/
        }
        /*设置本站信息按钮高度*/
        .bz_btu {
            height: 30px;
            width: 60px;
            line-height: 30px;
        }
 
        th {
            width: 70px;
            text-align: center;
        }
    </style>
</head>
 
<body>
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-card">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" id="formData" style="background-color:white;">
                    <div style="background-color:#0085E8;">
                        <span style="color: white;" class="jzd"><i class="layui-icon layui-icon-form"></i>生产开工单</span>
                    </div>
                    <div class="layui-form-item" style="margin: 1% 2%;text-align: right;">
                        <button type="button" lay-submit="" lay-filter="Add" class="layui-btn layui-btn-radius">新增</button>
                        <button type="button" lay-submit="" lay-filter="Saver" id="Saver" class="layui-btn layui-btn-radius">保存</button>
                        <button type="button" lay-submit="" lay-filter="Cancel" class="layui-btn layui-btn-radius layui-btn-danger">退出</button>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-tab layui-tab-card" lay-filter="TabTest">
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table style="width:80%;">
                                        <tbody>
                                            <tr>
                                                <th>条形码</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HBarCode" class="layui-input" id="HBarCode" placeholder="请输入条形码后回车" style="border-radius: 50px;" disabled>
                                                    <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu layui-btn-radius" lay-filter="QueDin" style="line-height: 30px;">确定</button>
                                                </td>
                                            </tr>
                                            <!--<tr>
        <th>设备</th>
        <td class="bz_td">
            <input type="text" name="HEquipName" class="layui-input" id="HEquipName" placeholder="请扫描设备二维码" style="border-radius: 50px;">
            <input type="hidden" name="HEquipID" id="HEquipID" value="0" autocomplete="off" class="layui-input">
        </td>
    </tr>-->
                                            <tr>
                                                <th>源单单号</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="border-radius: 50px;">
                                                    <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="0" style="border-radius: 50px;">
                                                    <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="0" style="border-radius: 50px;">
                                                    <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType" class="layui-input" value="" style="border-radius: 50px;">
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>生产订单</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HICMOBillNo" id="HICMOBillNo" class="layui-input" value="" style="border-radius: 50px;">
                                                    <input type="hidden" name="HICMOInterID" id="HICMOInterID" class="layui-input" value="0" style="border-radius: 50px;">
                                                    <input type="hidden" name="HICMOEntryID" id="HICMOEntryID" class="layui-input" value="0" style="border-radius: 50px;">
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>生产资源</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HSourceName" class="layui-input" id="HSourceName" placeholder="选择生产资源" style="border-radius: 50px;">
                                                    <input type="hidden" name="HSourceID" id="HSourceID" value="0" autocomplete="off" class="layui-input">
                                                    <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu" lay-filter="ProductionResources-BT" id="ProductionResources-BT" style="font-weight:bolder">...</button>
                                                </td>
                                            </tr>
 
                                            <!--<tr>
        <th>流水号</th>
        <td class="bz_td">
            <input type="text" name="HProcNo" class="layui-input" id="HProcNo" placeholder="选择流水号" style="background-color:#efefef4d;border-radius: 50px;">
            <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu" lay-filter="SerialNum-BT" id="SerialNum-BT" style="font-weight:bolder">...</button>
        </td>
    </tr>
    <tr>
        <th>当前工序</th>
        <td class="bz_td">
            <input type="text" name="HProcName" class="layui-input" id="HProcName" placeholder="当前工序" style="border-radius: 50px;background-color:#efefef4d;" readonly>
            <input type="hidden" name="HProcID" id="HProcID" value="0" autocomplete="off" class="layui-input">
        </td>
    </tr>-->
                                            <tr>
                                                <th>产品代码</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HMaterNumber" class="layui-input" id="HMaterNumber" placeholder="产品代码" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>产品名称</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HMaterName" class="layui-input" id="HMaterName" placeholder="产品名称" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                    <input type="hidden" name="HMaterID" id="HMaterID" value="0" autocomplete="off" class="layui-input">
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>开工时间</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HBeginWorkTime" class="layui-input" id="HBeginWorkTime" style="border-radius: 50px;" model="datetime" dateFormat="yyyy-MM-dd" placeholder="yyyy-MM-dd">
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>生产班组</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HGroupName" class="layui-input" id="HGroupName" placeholder="选择生产班组" style="background-color:#efefef4d;border-radius: 50px;">
                                                    <input type="hidden" name="HGroupID" id="HGroupID" value="0" autocomplete="off" class="layui-input">
                                                    <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu" lay-filter="ProductionTeam-BT" id="ProductionTeam-BT" style="font-weight:bolder">...</button>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>操作员</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HEmpName" class="layui-input" id="HEmpName" placeholder="选择接收人" style="background-color:#efefef4d;border-radius: 50px;" readonly>
                                                    <input type="hidden" name="HEmpID" id="HEmpID" value="0" autocomplete="off" class="layui-input">
                                                    <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu" lay-filter="HEmployeeID-BT" id="HEmployeeID-BT" style="font-weight:bolder">...</button>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>车间</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HDeptName" class="layui-input set_height" id="HDeptName" placeholder="选择车间" style="border-radius: 50px; background-color: #efefef4d;" readonly>
                                                    <input type="hidden" name="HDeptID" id="HDeptID" value="0" autocomplete="off" class="layui-input set_height">
                                                    <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu" lay-filter="btnHDept" id="btnHDept" style="font-weight:bolder;">...</button>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>生产班次</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HWorkShiftName" class="layui-input set_height" id="HWorkShiftName" placeholder="选择班次" style="border-radius: 50px; background-color: #efefef4d;" readonly>
                                                    <input type="hidden" name="HWorkShiftID" id="HWorkShiftID" value="0" autocomplete="off" class="layui-input set_height">
                                                    <button type="button" lay-submit="" class="layui-btn layui-col-xs2 bz_btu" lay-filter="btnHWorkShift" id="btnHWorkShift" style="font-weight:bolder;">...</button>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>单据日期</th>
                                                <td class="t1_input">
                                                    <input type="text" name="HDate" class="layui-input" id="HDate" style="border-radius: 50px;" placeholder="请选择日期" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>单据号</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HBillNo" class="layui-input" id="HBillNo" placeholder="单据号" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                    <input type="hidden" name="HInterID" id="HInterID" value="0" autocomplete="off" class="layui-input">
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="layui-tab-item">
                                    <table style="width:80%;">
                                        <tbody>
                                            <tr>
                                                <th>制单人</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HMaker" class="layui-input" id="HMaker" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>制单日期</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HMakeDate" class="layui-input" id="HMakeDate" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>修改人</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HUpDater" class="layui-input" id="HUpDater" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>修改日期</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HUpDateDate" class="layui-input" id="HUpDateDate" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>审核人</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HChecker" class="layui-input" id="HChecker" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>审核日期</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HCheckDate" class="layui-input" id="HCheckDate" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>关闭人</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HCloseMan" class="layui-input" id="HCloseMan" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>关闭日期</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HCloseDate" class="layui-input" id="HCloseDate" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>作废人</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HDeleteMan" class="layui-input" id="HDeleteMan" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>作废日期</th>
                                                <td class="bz_td">
                                                    <input type="text" name="HDeleteDate" class="layui-input" id="HDeleteDate" style="border-radius: 50px;background-color:#efefef4d;" readonly>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                            </div>
                            <ul class="layui-tab-title">
                                <li class="layui-this">单据信息</li>
                                <li>制单信息</li>
                            </ul>
                        </div>
                    </div>
                    <!--隐藏字段-->
                    <input type="hidden" name="lngProcInterID" id="lngProcInterID">
                    <input type="hidden" name="lngBillKey" id="lngBillKey" value="0">
                    <input type="hidden" name="lngBillSubKey" id="lngBillSubKey" value="0">
                    <!--<input type="hidden" name="HMaker" id="HMaker">--><!--制单人-->
                    <input type="hidden" name="eventType" id="eventType" value="Add">
                    <input type="hidden" name="HeqSouID" id="HeqSouID" value="0">
                </form>
            </div>
        </div>
    </div>
 
    <script>
        var HBillType = "";  //单据类型
        var HSourceInterID = ""; //源单主内码
        var HSourceEntryID = "";  //源单子内码
        var HSourceBillNo = "";   //源单单号
        var HSourceBillType = "";  //源单类型
        var HGroupID = 0;//班组ID
        //获取页面跳转参数  //单据编辑状态: 1.无源单新增   2.有源单新增   3.编辑  4.浏览  5.变更
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
        } else {
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSBillType = params[params[2]];//源单类型
        }
 
        var edit = function (data) {
            HBillType = data[0].HBillType;
            HSourceInterID = data[0].HSourceInterID;
            HSourceEntryID = data[0].HSourceEntryID;
            HSourceBillNo = data[0].HSourceBillNo;
            HSourceBillType = data[0].HSourceBillType;
            HGroupID = data[0].HGroupID;
        }
        layui.config({
            base: '../../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element','upload'], function () {
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
            //流转卡是否扫描标记
            var HProcExchBillNoFlag = false;
            //加载时间控件
            laydate.render({
                elem: '#HBeginWorkTime'
                , type: 'datetime'
            });
            //判断是否新增
            if (OperationType == 1 || OperationType == 2 || OperationType == 5) {
                //获取最大单据号
                var ajaxLoad = layer.load();
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3787' },
                    success: function (d) {
                        $("#HInterID").val(0);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        layer.close(ajaxLoad);
                    }
                    , error: function () {
                        layer.close(ajaxLoad);
                        layer.msg("获取单据号失败,请刷新重试!");
                    }
                });
                //通过登录用户获取默认值
                GetDefValByUser();
                //获取班组名称
                getHGroupNameByID()
                set_AddNew();
            }                      
 
            //进入页面默认光标在条形码上
            $("#HBarCode").focus();
 
            //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
 
            //#region 确定按钮
            form.on('submit(QueDin)', function (data) {//
                var HBarCode = $('#HBarCode').val();
 
                if (!HBarCode) {
                    layer.msg("条形码不能为空!")
                    return;
                }
                txtHBarCode_KeyDown(HBarCode);
 
            });
            //#endregion
                 
            //#region 保存按钮
            form.on('submit(Saver)', function (data) {//提交      
                var refSav = "";
                if (OperationType == 1 || OperationType == 2 || OperationType == 5) {
                    refSav = "Add";
                } else {
                    refSav = "Update";
                }
                if ($("#HSourceID").val() == '' || $("#HSourceID").val() == null || $("#HSourceID").val() == 0) {
                    layer.msg("生产资源不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HMainSourceInterID").val() == '' || $("#HMainSourceInterID").val() == null || $("#HMainSourceInterID").val() == 0) {
                    layer.msg("源单单号不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HEmpID").val() == '' || $("#HEmpID").val() == null||$("#HEmpID").val() == '0') {
                    layer.msg("操作员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HGroupID").val() == '' || $("#HGroupID").val() == null || $("#HGroupID").val() == '0') {
                    layer.msg("班组不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HDeptID").val() == '' || $("#HDeptID").val() == null || $("#HDeptID").val() == '0') {
                    layer.msg("车间不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HICMOInterID").val() == '' || $("#HICMOInterID").val() == null || $("#HICMOInterID").val() == '0') {
                    layer.msg("生产订单不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                
                var msg = JSON.stringify(data.field) + ";" + "{};" + sessionStorage["HUserName"] + ";" + refSav;
                var index = layer.load();
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "/Sc_MESBeginWorkBill/SaveGetMESBeginWorkFrom",
                    async: true,
                    data: { "msg": msg },
                    dataType: "json",
                    success: function (result) {
                        if (result.count == 1) {
                            $('#Saver').addClass("layui-btn-disabled").attr("disabled", true);//禁用保存按钮
                            $("#HInterID").val(result.HInterID);//获取提交成功返回的单据主ID
                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function (index) {
                                if (result.Verify == "Y") //自动审核
                                {
                                    layer.close(index);
                                    SaveVerify(); //审核
                                }
                                else {
                                    layer.close(index);
                                }
                            });
                            layer.close(index);
                        }
                        else {
                            layer.close(index);
                            layer.msg(result.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: "温馨提示" });
                    }
                });
                
                
            });
            //#endregion  
 
            //条形码回车方法
            $('#HBarCode').on('keydown', function (event) {
                var HBarCode = $('#HBarCode').val();
                if (event.keyCode == 13) {
                    if (!HBarCode) {
                        layer.msg("空白码,条形码不能为空!")
                        return;
                    }
                    txtHBarCode_KeyDown(HBarCode);
                }
            });
            //流水号(工序号)回车方法
            $('#HProcNo').on('keydown', function (event) {
                var sProcNo = $('#HProcNo').val();
                var sBillNo = $('#HMainSourceBillNo').val();
                if (event.keyCode == 13) {
                    if (!HProcExchBillNoFlag) {
                        layer.msg("流转卡没有扫描,或者没有按回车键,请扫描流转卡或者在流转卡文本框中按回车键!");
                        return;
                    }
                    txtHProcNo_KeyDown(sBillNo, sProcNo);
                }
            });
 
            //选择生产班组弹窗
            form.on('submit(ProductionTeam-BT)', function () {//选择生产班组
                layer.open({
                    type: 2
                    , area: ['80%', '80%']
                    , title: '本站工序'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: true //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../../Baseset/基础资料/Gy_GetProductionTeamList.html', 'yes']
                    , resize: false
                    , cancel: function (index, layero) {
                    }
                })
            });
 
            //选择生产资源弹窗
            form.on('submit(ProductionResources-BT)', function () {//生产资源
                console.log($('#HProcNo').val())
                layer.open({
                    type: 2
                    , area: ['80%', '80%']
                    , title: '生产资源'
                    , shade: 0.6 //遮罩透明度
                    //, maxmin: true //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../../Baseset/基础资料/Gy_GetProductionResourcesList.html', 'yes']
                    , resize: false
                    , cancel: function (index, layero) {
                    }
                })
            });
 
            //选择操作人
            form.on('submit(HEmployeeID-BT)', function () {
                layer.open({
                    type: 2
                    , area: ['80%', '80%']
                    , title: '职员列表'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: true //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../../Baseset/基础资料/Gy_EmployeeList.html?Type=HWorker', 'yes']
                    , resize: false
                    , cancel: function (index, layero) {
                    }
                })
            });
 
            //选择流水号弹窗
            form.on('submit(SerialNum-BT)', function () {//生产资源
                var value = $("#lngProcInterID").val();
                // 判断是否已经输入流水号,是则弹出模态框,否则给出提示
                if (value) {
                    layer.open({
                        type: 2
                        , area: ['80%', '80%']
                        , title: '流水号'
                        , shade: 0.6 //遮罩透明度
                        //, maxmin: true //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: [`../../../Baseset/基础资料/Gy_GetProcNoList.html?HInterID=${value}`, 'yes']
                        , resize: false
                        , cancel: function (index, layero) {
                        }
                        , end: function () {
                            var sProcNo = $('#HProcNo').val();
                            var sBillNo = $('#HMainSourceBillNo').val();
                            if (sProcNo != "") {
                                txtHProcNo_KeyDown(sBillNo, sProcNo);
                            }
                        }
                    })
                } else {
                    layer.alert('请您确认输入流转卡号后重试^_^', { icon: 7 });
                }
            });
 
            //选择部门弹窗
            form.on('submit(btnHDept)', function () {//部门
                layer.open({
                    type: 2 //类型
                    , skin: 'layui-layer-rim'//加上边框
                    , area: ['90%', '90%']//大小
                    , title: '部门列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../../Baseset/基础资料/Gy_DepartmentList.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('请选择数据');
                        }
                        //获取数据
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                })
            });
 
            //退出--全屏版
            form.on('submit(Cancel)', function () {
                //layer.confirm('您确定要退出吗?', { icon: 3, title: '提示' }, function (index) {
                //    parent.location.href = "../../../../views/index_Mobile.html";
                //});
                Pub_Close2(1);
            })
 
            //新增
            form.on('submit(Add)', function () {
                //var index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
                //parent.layer.close(index); // 再执行关闭
                Pub_Close2(1);
            })
 
            //#endregion
 
            //#region 本页面所有被调用的方法
 
            //#region 通过登录用户获取默认值
            function GetDefValByUser() {
                var index = layer.load();
                $.ajax({
                    url: GetWEBURL() + "/Cj_StationInBill/GetDefValByUser",
                    type: "GET",
                    async: false,
                    data: { "Czybm": sessionStorage["Czybm"], "Czymc": sessionStorage["HUserName"] },
                    success: function (result) {
                        var data = result.data[0];
 
                        form.val("formData", {
                            //"HSourceID": data.HSourceID,
                            //"HSourceName": data.生产资源名称,
                            "HGroupID": data.HGroupID,
                            "HGroupName": data.生产班组名称,
                            "HEmpID": data.HEmpID,
                            "HEmpName": data.操作员名称
                        });
                        layer.close(index);
                    }
                    , error: function () {
                        layer.close(index);
                        layer.msg("接口请求失败");
                    }
                })
            }
            //#endregion
 
            //#region 通过班组ID获取班组名称
            function getHGroupNameByID() {
                $.ajax({
                    url: GetWEBURL() + '/Gy_Group/cx',
                    type: "GET",
                    async: false,
                    data: { "HInterID": HGroupID },
                    success: function (data1) {
                        if (data1.count == 1) {
                            $("#HGroupID").val(HGroupID)
                            $("#HGroupName").val(data1.data[0].班组名称)
                        } 
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
 
                });
            }
            
            //#endregion
 
            //条形码回车方法
            function txtHBarCode_KeyDown(HBarCode) {
                var ajaxLoad = layer.load();
                var sql = "select * from Sc_ICMOBillStatus_Tmp where HICMOBillNo =  '" + HBarCode + "'" ;
                $.ajax({
                    url: GetWEBURL() + '/Gy_SOPBillList/WindowPrintList',
                    type: "GET",
                    async: false,
                    data: { "sWhere": sql },
                    success: function (data1) {
                        if (data1.count == 1) {
                            HSourceInterID = data1.data[0].HInterID;
                            HSourceEntryID = data1.data[0].HICMOEntryID;
                            HSourceBillNo = HBarCode;
                            HSourceBillType = data1.data[0].HBillType;
                        } else {
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                            layer.close(ajaxLoad);
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                        layer.close(ajaxLoad);
                    }
                });
                $.ajax(
                    {
                        type: "GET",
                        url: GetWEBURL() + "/Sc_MESBeginWorkBill/GetMESBeginWorkFrom", //方法所在页面和方法名
                        async: false,
                        data: {
                            "HSourceInterID": HSourceInterID,
                            "HSourceEntryID": HSourceEntryID,
                            "HSourceBillNo": HSourceBillNo,
                            "HSourceBillType": HSourceBillType
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1)// 说明验证成功了,
                            {
                                var LoadData = data.data.h_p_JIT_GetInfoByICMOStatusInterID;
 
                                $("#HProcID").val(LoadData[0].HProcID); //当前工序ID
                                $("#HProcName").val(LoadData[0].HProcName); //当前工序
                                $("#HMaterID").val(LoadData[0].HMaterID); //产品ID
                                $("#HMaterCode").val(LoadData[0].HMaterNumber); //产品代码
                                $("#HMaterName").val(LoadData[0].HMaterName); //产品名称
                                $("#HMaterSpec").val(LoadData[0].HModel); //产品规格
                                $("#HSourceID").val(LoadData[0].HSourceID); //生产资源ID
                                $("#HSourceName").val(LoadData[0].HSourceName); //生产资源
                                $("#HMainSourceBillNo").val(LoadData[0].HICMOBillNo); //源单单号(暂时取值订单编号)
                                $("#HMainSourceInterID").val(LoadData[0].HSourceInterID); //源单主内码(取值HInterID)
                                $("#HMainSourceEntryID").val(LoadData[0].HSourceEntryID); //源单子内码(源单行号)
                                $("#HMainSourceBillType").val(HSourceBillType); //源单类型
                                $("#HDeptID").val(LoadData[0].HDeptID); //车间ID
                                $("#HDeptName").val(LoadData[0].HDeptName); //车间
                                $("#HICMOInterID").val(LoadData[0].HICMOInterID); //生产订单ID
                                $("#HICMOEntryID").val(LoadData[0].HICMOEntryID); //生产订单子ID
                                $("#HICMOBillNo").val(LoadData[0].HICMOBillNo); //生产订单
                                //HCenterID = LoadData[0].HCenterID == null ? sessionStorage["HWorkCenterID"] : LoadData[0].HCenterID;//工作中心id
                                layer.close(ajaxLoad);
                            }
                            else {
                                layer.alert(data.Message, { icon: 5 });
                                layer.close(ajaxLoad);
                            }
                        },
                        error: function (err) {
                            layer.alert(err, { icon: 5 });
                            layer.close(ajaxLoad);
                        }
                    });
            }
            //流水号回车方法
            function txtHProcNo_KeyDown(sBillNo, sProcNo) {
                var index = layer.load();
                $.ajax({
                    url: GetWEBURL() + "/Cj_StationInBill/txtHProcNo_KeyDown",
                    type: "GET",
                    data: { "sBillNo": sBillNo, "sProcNo": sProcNo },
                    success: function (result) {
                        if (result.count == 1) {
                            var data = result.data[0];
                            form.val("formData", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                                "HProcName": data.工序,
                                "HProcID": data.HProcID,
                                "HSourceID": data.HSourceID,
                                "HSourceName": data.生产资源
                            });
                            $("#HProcNo").attr("readonly", "readonly");
                            $("#HProcNo").css("background-color", "#efefef4d");
                            layer.close(index);
                        }
                        else {
                            layer.close(index);
                            layer.msg(result.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 SaveVerify() {
                var InterID = $("#HInterID").val();
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MESBeginWorkBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 0, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // 说明验证成功了,
                            layer.msg(data.Message, { time: 1 * 2000, icon: 1 }, function (index) {
                                //layer.close(layer.index);
                                //window.parent.location.reload();
                            });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
                        layer.alert(err, { icon: 5 })
                    }
                })
            }
 
            //有源单新增
            function set_AddNew() {
                //初始基本信息赋值
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));      //单据日期
                $("#HBeginWorkTime").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"))  //开始时间
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));  //制单日期
                $("#HMaker").val(sessionStorage["HUserName"]);     //制单人
 
 
                //加源单类型区分(可以写不同的方法)
                $('#HProcName').attr("disabled", true);
                $('#HSourceName').attr("disabled", true);
                $('#ProductionResources-BT').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMainSourceBillNo').attr("disabled", true);
                $('#HICMOBillNo').attr("disabled", true);
                $('#HDeptName').attr("disabled", true);
                $('#btnHDept').addClass("layui-btn-disabled").attr("disabled", true);
 
                $.ajax(
                    {
                        type: "GET",
                        url: GetWEBURL() + "/Sc_MESBeginWorkBill/GetMESBeginWorkFrom", //方法所在页面和方法名
                        async: false,
                        data: {
                            "HSourceInterID": HSourceInterID,
                            "HSourceEntryID": HSourceEntryID,
                            "HSourceBillNo": HSourceBillNo,
                            "HSourceBillType": HBillType
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1)// 说明验证成功了,
                            {
                                var LoadData = data.data.h_p_JIT_GetInfoByICMOStatusInterID;
 
                                $("#HProcID").val(LoadData[0].HProcID); //当前工序ID
                                $("#HProcName").val(LoadData[0].HProcName); //当前工序
                                $("#HMaterID").val(LoadData[0].HMaterID); //产品ID
                                $("#HMaterNumber").val(LoadData[0].HMaterNumber); //产品代码
                                $("#HMaterName").val(LoadData[0].HMaterName); //产品名称
                                $("#HSourceID").val(LoadData[0].HSourceID); //生产资源ID
                                $("#HSourceName").val(LoadData[0].HSourceName); //生产资源
                                $("#HMainSourceBillNo").val(LoadData[0].HICMOBillNo); //源单单号(暂时取值订单编号)
                                $("#HMainSourceInterID").val(LoadData[0].HSourceInterID); //源单主内码(取值HInterID)
                                $("#HMainSourceEntryID").val(LoadData[0].HSourceEntryID); //源单子内码(源单行号)
                                $("#HMainSourceBillType").val(HSourceBillType); //源单类型
                                $("#HDeptID").val(LoadData[0].HDeptID); //车间ID
                                $("#HDeptName").val(LoadData[0].HDeptName); //车间
                                $("#HICMOInterID").val(LoadData[0].HICMOInterID); //生产订单ID
                                $("#HICMOEntryID").val(LoadData[0].HICMOEntryID); //生产订单子ID
                                $("#HICMOBillNo").val(LoadData[0].HICMOBillNo); //生产订单
                                //HCenterID = LoadData[0].HCenterID == null ? sessionStorage["HWorkCenterID"] : LoadData[0].HCenterID;//工作中心id
                            }
                            else {
                                layer.alert(data.Message, { icon: 5 });
 
                            }
                        },
                        error: function (err) {
                            layer.alert(err, { icon: 5 });
                        }
                    });
            }
 
            //以上为layui模块
        });
        //返回流水号
        function GetProcNoValue(obj) {
            $("#HProcNo").val(obj[0].流水号);
        }
 
        //返回生产班组
        function GetProductionTeamValue(obj) {
            $("#HGroupName").val(obj[0].班组);
            $("#HGroupID").val(obj[0].HItemID);
        }
 
        //返回生产资源
        function GetProductionResourcesValue(obj) {
            $("#HSourceName").val(obj[0].生产资源);
            $("#HSourceID").val(obj[0].HItemID);
        }
        //返回操作员
        function GetHWorkerValue(obj) {
            $("#HEmpName").val(obj[0].HName);
            $("#HEmpID").val(obj[0].HItemID);
        }      
        //返回当前工序
        function GetHProcValue(obj) {  //返回当前工序
            $("#HProcName").val(obj[0].工序);
            $("#HProcID").val(obj[0].HItemID);
        }
       
    </script>
</body>
</html>