wtt
2025-08-05 bef1b10cc26f29b96c5eb7afacfdcce8ca534ea5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>条码生成_迦南</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.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/layui/layui.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="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/PageTitle.js"></script>
    <script src="../../../layuiadmin/MESLanguage.js"></script>
    <style type="text/css">
        .layui-form-item .layui-inline {
            margin-right: 0;
        }
 
        html {
            background-color: white;
            color: white;
        }
 
        .layui-table-cell {
            overflow: visible !important;
        }
 
        td .layui-form-select {
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
    </style>
</head>
<body>
 
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-card" style="padding: 15px;">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" lay-filter="component-form-group" action="">
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" id="set_SaveBill" lay-filter="set_SaveBill">生成</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" id="set_Export" lay-filter="set_Export">导出</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" id="btn-print" lay-filter="btn-print">打印</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" id="Exit" lay-filter="Exit">退出</button>
                        </div>
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <h1 style="text-align: center; padding: 10px 0;"><b>条码生成</b></h1>
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</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">日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-block">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="width:190px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="margin-left:10px;">
                                            <label class="layui-form-label">源单号</label>
                                            <div class="layui-input-inline">
                                                <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="0" style="background-color:#efefef4d;">
                                                <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="0" style="background-color:#efefef4d;">
                                                <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType" class="layui-input" value="" style="background-color:#efefef4d;">
                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">采购订单</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HPOOrderBillNo" id="HPOOrderBillNo" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">条码类型</label>
                                            <div class="layui-input-inline">
                                                <select name="HBarCodeType" id="HBarCodeType" lay-filter="HBarCodeType" style="width: 180px; ">
                                                    <option style="color:blue;" value="BarCode" selected="selected">包条码</option>
                                                    <option style="color:blue;" value="BarCode_Box">内箱条码</option>
                                                    <option style="color:blue;" value="BarCode_Pack">托盘条码</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">物料编码</label>
                                            <div class="layui-input-inline">
                                                <input type="hidden" name="HMaterID" id="HMaterID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="text" class="layui-input" name="HMaterNumber" id="HMaterNumber" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">物料名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HMaterName" id="HMaterName" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">规格型号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HMaterModel" id="HMaterModel" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">计量单位</label>
                                            <div class="layui-input-inline">
                                                <input type="hidden" name="HUnitID" id="HUnitID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="text" class="layui-input" name="HUnitName" id="HUnitName" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">辅助属性代码</label>
                                            <div class="layui-input-inline">
                                                <input type="hidden" name="HAuxPropID" id="HAuxPropID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="text" name="HAuxPropNumber" id="HAuxPropNumber" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">辅助属性</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HAuxPropName" id="HAuxPropName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">批号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HBatchNo" id="HBatchNo" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">供应商代码</label>
                                            <div class="layui-input-inline">
                                                <input type="hidden" name="HSupID" id="HSupID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="text" class="layui-input" name="HSupNumber" id="HSupNumber" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">供应商名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HSupName" id="HSupName" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline" id="HQty_SourceElement">
                                            <label class="layui-form-label">源单数量</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HQty_SourceBill" id="HQty_SourceBill" style="background-color:#efefef4d;">
                                            </div>
                                        </div>
                                        <div class="layui-inline" id="HBarCodeQtyElement">
                                            <label class="layui-form-label">条码张数</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HBarCodeQty" id="HBarCodeQty" class="layui-input" value="0">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline" id="HMinQtyElement">
                                            <label class="layui-form-label">每包数量</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMinQty" id="HMinQty" class="layui-input" value="0" style="background-color:#efefef4d;">
                                            </div>
                                        </div>
                                        <div class="layui-inline" id="HBQtyElement">
                                            <label class="layui-form-label">包数</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HBQty" id="HBQty" class="layui-input" value="0" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline" id="HEndQtyElement">
                                            <label class="layui-form-label">尾包数量</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HEndQty" id="HEndQty" class="layui-input" value="0" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline" id="HEndQty_SureElement">
                                            <label class="layui-form-label">尾包确认</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HEndQty_Sure" id="HEndQty_Sure" class="layui-input" value="0">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
 
                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                    <script type="text/html" id="toolbarDemo">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                        </div>
                    </script>
                    <script type="text/html" id="xuhao">
                        {{d.LAY_TABLE_INDEX+1}}
                    </script>
                </form>
            </div>
        </div>
    </div>
 
    <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 = "Gy_BarCodeBill_JiaNan";
            var option = {};                                                            //子表渲染参数
            var ins;                                                                    //导出对象
 
            //#region 获取页面跳转参数
            var params = get_UrlVars();
            var OperationType = params[params[0]];      //操作类型
            var HBarCodeType = params[params[1]];       //条码类型
            var HSourceInterID = params[params[2]];     //源单主id
            var HSourceEntryID = params[params[3]];     //源单子id
            var HSourceBillType = params[params[4]];    //源单类型
            var HSourceBillNo = params[params[5]];
 
            var HZZRQ = "";                             //制造日期
 
            var HQty_waitProduce = 0;                   //可生成条码数量
            //源单单号
            //#endregion
            //#endregion
 
 
            //#region 页面加载
            //#region 判断是否登录 未登录则跳到登录页
            get_LoginIs();
            //#endregion
 
            //#region 初始化子表
            set_InitGrid();
            //#endregion
 
            //#region 判断操作类型并初始化界面
            if (OperationType == "1") {                                             //包条码
 
            }
            else if (OperationType == "4") {                                        //下推
                var temp = getPushSource_POInStockBillInit(HSourceInterID, HSourceEntryID);
                var dataArray = [];
                dataArray.push(temp);
                if (dataArray[0].条码同步标记.trim() != "") {
                    layer.alert("该单据明细记录条码已经同步,不允许生成条码,请撤销同步后再进行生成!!", { icon: 5 });
                    return;
                }
 
                setInit_PushBill();
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
            //#endregion
 
            //#region 表头操作按钮监听
            //#region 生成按钮
            form.on('submit(set_SaveBill)', function (data) {
                $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);                   //生成按钮禁用
 
                var sMainData = data.field;
                if (sMainData.HMaterName != null && (sMainData.HMaterName.indexOf("\"") != -1 || sMainData.HMaterName.indexOf(";") != -1)) {
                    sMainData.HMaterName = sMainData.HMaterName.replaceAll("\"", "”").replaceAll(";", ";")
                }
                if (sMainData.HMaterModel != null && (sMainData.HMaterModel.indexOf("\"") != -1 || sMainData.HMaterModel.indexOf(";") != -1)) {
                    sMainData.HMaterModel = sMainData.HMaterModel.replaceAll("\"", "”").replaceAll(";", ";")
                }
 
                var sMainData_temp = [];
 
                if (sMainData.HBarCodeType == "BarCode") {
                    //判断生成条码数量是否超过可生成条码数量
                    var temp = getPushSource_POInStockBillInit(HSourceInterID, HSourceEntryID);
                    var dataArray = [];
                    dataArray.push(temp);
                    var HQty_SourceBill = $("#HQty_SourceBill").val() * 1;
                    if (HQty_SourceBill > ((dataArray[0].数量 * 1) - (dataArray[0].已生成条码数量 * 1))) {
                        layer.msg("条码生成数量大于最大可生成数量【" + ((dataArray[0].数量 * 1) - (dataArray[0].已生成条码数量 * 1)) + "】!!");
                        return false;
                    }
 
                    sMainData_temp = [
                        {
                            "HMainID": sMainData.HMainSourceInterID
                            , "HSubID": sMainData.HMainSourceEntryID
                            , "HBillNo": sMainData.HMainSourceBillNo
                            , "HBillType": sMainData.HMainSourceBillType
                            , "HMaterID": sMainData.HMaterID
                            , "HMaterNumber": sMainData.HMaterNumber
                            , "HMaterName": sMainData.HMaterName
                            , "HMaterModel": sMainData.HMaterModel
                            , "HCusModel": ""
                            , "HCusMaterName": ""
                            , "HEmpID": 0
                            , "HEmpNumber": ""
                            , "HEmpName": ""
                            , "HGroupID": 0
                            , "HGroupNumber": ""
                            , "HGroupName": ""
                            , "HCheckEmpName": ""
                            , "HBatchNo": sMainData.HBatchNo
                            , "HQty": sMainData.HQty_SourceBill
                            , "HMinQty": sMainData.HMinQty
                            , "HBQty": sMainData.HBQty
                            , "HPackQty": 0
                            , "HCoilNO": ""
                            , "HFurnaceNO": ""
                            , "HFactory": ""
                            , "HCusID": 0
                            , "HCusNumber": ""
                            , "HCusName": ""
                            , "HSeOrderBillNo": ""
                            , "HRemark": ""
                            , "HProduceDate": sMainData.HDate
                            , "HExpiryDate": sMainData.HDate
                            , "HheatNO": ""
                            , "HAuxPropID": sMainData.HAuxPropID
                            , "HAuxPropNumber": sMainData.HAuxPropNumber
                            , "HAuxPropName": sMainData.HAuxPropName
                            , "HUnitID": sMainData.HUnitID
                            , "HUnitNumber": ""
                            , "HUnitName": sMainData.HUnitName
                            , "HAuxQty": 0
                            , "HExpirationDateFlag": 0
                            , "HGiveAwayFlag": 0
                            , "HDate": sMainData.HDate
                            , "HMTONo": ""
                            , "HBarCodeType": sMainData.HBarCodeType
                            , "HSupID": sMainData.HSupID
                            , "HSupNumber": sMainData.HSupNumber
                            , "HSupName": sMainData.HSupName
                            , "HInnerBillNo": sMainData.HPOOrderBillNo
                            , "HZZRQ": HZZRQ
                        }
                    ]
                } else if(sMainData.HBarCodeType == "BarCode_Box") {
                    sMainData_temp = [
                        {
                            "HMainID": sMainData.HMainSourceInterID
                            , "HSubID": sMainData.HMainSourceEntryID
                            , "HBillNo": sMainData.HMainSourceBillNo
                            , "HBillType": sMainData.HMainSourceBillType
                            , "HMaterID": sMainData.HMaterID
                            , "HMaterNumber": sMainData.HMaterNumber
                            , "HMaterName": sMainData.HMaterName
                            , "HMaterModel": sMainData.HMaterModel
                            , "HCusModel": ""
                            , "HCusMaterName": ""
                            , "HEmpID": 0
                            , "HEmpNumber": ""
                            , "HEmpName": ""
                            , "HGroupID": 0
                            , "HGroupNumber": ""
                            , "HGroupName": ""
                            , "HCheckEmpName": ""
                            , "HBatchNo": sMainData.HBatchNo
                            , "HQty": 1
                            , "HMinQty": 1
                            , "HBQty": sMainData.HBarCodeQty
                            , "HPackQty": 0
                            , "HCoilNO": ""
                            , "HFurnaceNO": ""
                            , "HFactory": ""
                            , "HCusID": 0
                            , "HCusNumber": ""
                            , "HCusName": ""
                            , "HSeOrderBillNo": ""
                            , "HRemark": ""
                            , "HProduceDate": sMainData.HDate
                            , "HExpiryDate": sMainData.HDate
                            , "HheatNO": ""
                            , "HAuxPropID": sMainData.HAuxPropID
                            , "HAuxPropNumber": sMainData.HAuxPropNumber
                            , "HAuxPropName": sMainData.HAuxPropName
                            , "HUnitID": sMainData.HUnitID
                            , "HUnitNumber": ""
                            , "HUnitName": sMainData.HUnitName
                            , "HAuxQty": 0
                            , "HExpirationDateFlag": 0
                            , "HGiveAwayFlag": 0
                            , "HDate": sMainData.HDate
                            , "HMTONo": ""
                            , "HBarCodeType": sMainData.HBarCodeType
                            , "HSupID": sMainData.HSupID
                            , "HSupNumber": sMainData.HSupNumber
                            , "HSupName": sMainData.HSupName
                            , "HInnerBillNo": sMainData.HPOOrderBillNo
                            , "HZZRQ": HZZRQ
                        }
                    ]
                }else if (sMainData.HBarCodeType == "BarCode_Pack") {
                    sMainData_temp = [
                        {
                            "HMainID": sMainData.HMainSourceInterID
                            , "HSubID": sMainData.HMainSourceEntryID
                            , "HBillNo": sMainData.HMainSourceBillNo
                            , "HBillType": sMainData.HMainSourceBillType
                            , "HMaterID": sMainData.HMaterID
                            , "HMaterNumber": sMainData.HMaterNumber
                            , "HMaterName": sMainData.HMaterName
                            , "HMaterModel": sMainData.HMaterModel
                            , "HCusModel": ""
                            , "HCusMaterName": ""
                            , "HEmpID": 0
                            , "HEmpNumber": ""
                            , "HEmpName": ""
                            , "HGroupID": 0
                            , "HGroupNumber": ""
                            , "HGroupName": ""
                            , "HCheckEmpName": ""
                            , "HBatchNo": sMainData.HBatchNo
                            , "HQty": 1
                            , "HMinQty": 1
                            , "HBQty": sMainData.HBarCodeQty
                            , "HPackQty": 0
                            , "HCoilNO": ""
                            , "HFurnaceNO": ""
                            , "HFactory": ""
                            , "HCusID": 0
                            , "HCusNumber": ""
                            , "HCusName": ""
                            , "HSeOrderBillNo": ""
                            , "HRemark": ""
                            , "HProduceDate": sMainData.HDate
                            , "HExpiryDate": sMainData.HDate
                            , "HheatNO": ""
                            , "HAuxPropID": sMainData.HAuxPropID
                            , "HAuxPropNumber": sMainData.HAuxPropNumber
                            , "HAuxPropName": sMainData.HAuxPropName
                            , "HUnitID": sMainData.HUnitID
                            , "HUnitNumber": ""
                            , "HUnitName": sMainData.HUnitName
                            , "HAuxQty": 0
                            , "HExpirationDateFlag": 0
                            , "HGiveAwayFlag": 0
                            , "HDate": sMainData.HDate
                            , "HMTONo": ""
                            , "HBarCodeType": sMainData.HBarCodeType
                            , "HSupID": sMainData.HSupID
                            , "HSupNumber": sMainData.HSupNumber
                            , "HSupName": sMainData.HSupName
                            , "HInnerBillNo": sMainData.HPOOrderBillNo
                            , "HZZRQ": HZZRQ
                        }
                    ]
                } else {
                    layer.msg("条码类型不存在!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                    return;
                }
 
 
                var sSubStr = JSON.stringify(sMainData_temp);
                //物料明细信息不为空判断
                if (!AllowLoadData(sSubStr))//数据验证
                {
                    $('#set_SaveBill').removeClass("layui-btn-disabled").attr("disabled", false);//生成按钮启用
                    return false;
                }
                //获取选择的组织
                var HOrgType = sessionStorage["Organization"];
                //获取选择的工厂代码
                var CampanyName = "xxx";
                //获取选择的源单类型
                var HSourceBillType = $("#HMainSourceBillType").val();
                //获取选择的条码类型
                var HSelectBarCodeType = $("#HBarCodeType").val();
                //获取当前登录人员
                var UserName = sessionStorage["HUserName"];
                //var UserName = "Admin";
                var sMainSub = sSubStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' + CampanyName + ';' + UserName;
                SaveBarCodeCreate(sMainSub);
            });
 
            //#region 条码生成
            //条码生成
            function SaveBarCodeCreate(sMainSub, CampanyName) {
                $.ajax(
                    {
                        type: "POST",
                        url: GetWEBURL() + "/Sc_BarCode/Sub_SaveBill_JiaNan", //方法所在页面和方法名
                        async: false,
                        data: { "msg": sMainSub},
                        dataType: "json",
                        success: function (result) {
                            if (result.count == 1) { // 说明验证成功了,
                                option.data = result.data;
                                ins = table.render(option);
                            }
                            else {
                                $('#ToolCreate').removeClass("layui-btn-disabled").attr("disabled", false);//生成按钮启用
                                layer.alert(get_MessageError(result.Message, sessionStorage["HTranSlate"]), { icon: 5 });
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            layer.alert(get_MessageError(err.Message, sessionStorage["HTranSlate"]), { icon: 5 });
                        }
                    });
            }
            //#endregion
 
            //#region 数据校验
            function AllowLoadData(sSubStr) {
                var Result = true;
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^[1-9]\d*$/;            //正整数正则表达式
                var temp = "";
                sSubStr = JSON.parse(sSubStr);
 
                if (sSubStr[0].HDate == "") {
                    layer.msg("日期未设置!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                    return Result = false;
                }
                if (sSubStr[0].HBarCodeType == "") {
                    layer.msg("条码类型未设置!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                    return Result = false;
                }
                if (sSubStr[0].HSourceInterID == "0" || sSubStr[0].HSourceEntryID == "0" || sSubStr[0].HSourceBillNo == "") {
                    layer.msg("源单信息有误!!【主内码:" + sSubStr[0].HSourceInterID + ";子内码:" + sSubStr[0].HSourceEntryID + ";源单号:" + sSubStr[0].HSourceBillNo + ";】", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                    return Result = false;
                }
                if (sSubStr[0].HMaterID == "0") {
                    layer.msg("物料信息有误!!【物料ID:" + sSubStr[0].HMaterID + ";物料代码:" + sSubStr[0].HMaterNumber + ";物料名称:" + sSubStr[0].HMaterName + ";规格型号:" + sSubStr[0].HMaterModel + ";】", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                    return Result = false;
                }
                if (sSubStr[0].HSupID == "0") {
                    layer.msg("供应商信息有误!!【供应商ID:" + sSubStr[0].HMaterID + ";供应商代码:" + sSubStr[0].HMaterNumber + ";供应商名称:" + sSubStr[0].HMaterName + ";】", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                    return Result = false;
                }
 
                if (sSubStr[0].HBarCodeType == "BarCode") {
                    temp = sSubStr[0].HQty + "";
                    if (temp == "0" || temp == "") {
                        layer.msg("源单数量不能为0或空!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    } else if (!ref.test(temp)) {
                        layer.msg("源单数量请输入大于0的数字!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
 
                    temp = sSubStr[0].HMinQty + "";
                    if (temp == "0" || temp == "") {
                        layer.msg("每包数量不能为0或空!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    } else if (!ref.test(temp)) {
                        layer.msg("每包数量请输入大于0的数字!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
 
                    temp = sSubStr[0].HBQty + "";
                    if (!ref1.test(temp)) {
                        layer.msg("包数请输入大于0的整数数字!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
 
                    var HEndQty = $("#HEndQty").val();
                    if (HEndQty == "") {
                        layer.msg("尾包数量不能为空!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    } else if (!ref.test(HEndQty)) {
                        layer.msg("尾包数量请输入不小于0的数字!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
 
                    var HEndQty_Sure = $("#HEndQty_Sure").val();
                    if (HEndQty != HEndQty_Sure) {
                        layer.msg("尾包数量与尾包确认不一致!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
                }
                else if (sSubStr[0].HBarCodeType == "BarCode_Box") {
                    temp = sSubStr[0].HBQty + "";
                    if (!ref1.test(temp)) {
                        layer.msg("条码张数请输入大于0的数字!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
                }
                else if (sSubStr[0].HBarCodeType == "BarCode_Box") {
                    temp = sSubStr[0].HBQty + "";
                    if (!ref1.test(temp)) {
                        layer.msg("条码张数请输入大于0的数字!!", { icon: 5, btn: [get_MessageError('[0000-2-008]确认', sessionStorage["HTranSlate"])], time: 2000, offset: 't', skin: 'layui-layer-lan', title: get_MessageError("[0000-2-009]温馨提示", sessionStorage["HTranSlate"]) });
                        return Result = false;
                    }
                }
                return Result;
            }
            //#endregion
            //#endregion
 
            //#region 导出按钮
            form.on('submit(set_Export)', function (data) {
                get_Export();
            });
 
            //#region 导出Execel
            function get_Export() {
                //var ModRightNameCheck = "Gy_BarCodeBill_JiaNan_ExportExcel";
 
                ////逻辑审核方法
                //$.ajax({
                //    type: "GET",
                //    url: GetWEBURL() + "/LMES/getReportByModRightNameCheck", //方法所在页面和方法名
                //    data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
                //    success: function (result) {
                //        if (result.count == 1) {
                            var data = option.data;
                            data.forEach((item) => {
                                for (let itemobj in item) {
                                    if (item[itemobj] == null) {
                                        item[itemobj] = "";
                                    }
                                    if (item[itemobj].length > 0) {  // 假设字段名为field
                                        item[itemobj] = item[itemobj].toString().replaceAll(/[\r\n]+/g, '');  // 将换行符替换为空字符串
                                        item[itemobj] = item[itemobj].toString().replaceAll(/[,]+/g, ',');  // 将换分号替换为空字符串
                                    }
                                }
                            });
                            table.exportFile(ins.config.id, data, "xls");
                //        } else {
                //            layer.alert("当前模块没有导出权限!", { icon: 5 });
                //        }
                //    }, error: function () {
                //        layer.alert("接口请求失败!", { icon: 5 });
                //    }
                //});
            }
            //#endregion
            //#endregion
 
            //#region 打印按钮
            form.on('submit(btn-print)', function (data) {
                get_PrintReport();
            });
 
            //#region 打印
            function get_PrintReport() {
                var checkStatus = table.checkStatus('mainTable')
                    , dataArr = checkStatus.data;
 
                //由于条码信息列表中没有 HItemID 字段,所以采取了用 条码编号 去获取 HItemID 的方式
                if (checkStatus.data.length > 0) {
                    var rows = [];
                    for (var i = 0; i < dataArr.length; i++) {
                        rows.push(dataArr[i].HItemID.toString());
                    }
                    //rows = rows.substring(rows.length - 1, 0);
                    layer.open({
                        type: 2
                        , area: ['50%', '50%']
                        , title: '打印模版选择'
                        , shade: 0.6 //遮罩透明度
                        , maxmin: false //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + rows.toString() + '&MyMsg=' + rows.toString() + '&Type=HGy_BarCodeBill_JiaNan', 'yes']
                        , resize: false
                    })
                }
                else {
                    layer.msg(get_MessageError('[0000-1-016]请选择要打印的条码数据!', sessionStorage["HTranSlate"]));
                }
            }
            //#endregion
            //#endregion
 
            //#region 退出按钮
            form.on('submit(Exit)', function () {
                if (params[1] != null) {
                    Pub_Close(1);
                } else if (params[1] == null) {
                    Pub_Close(2);
                }
            })
            //#endregion
            //#endregion
 
            //#region 文本框监听
            $(document).ready(function () {
                if (HBarCodeType == "BarCode") {
                    //#region 源单数量失焦事件
                    var oldHQty_SourceBill = "";                          //修改前的值
                    var newHQty_SourceBill = "";                          //修改后的值
                    $("#HQty_SourceBill").on('focus', function (data) {
                        oldHQty_SourceBill = $("#HQty_SourceBill").val() * 1;   //金额文本框获取焦点时获取修改前的值
                    }).on('blur', function (data) {
                        newHQty_SourceBill = $("#HQty_SourceBill").val();       //金额文本框失焦时获取修改后的值
 
                        //判断输入的金额是否合法
                        var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                        if (!ref.test(newHQty_SourceBill)) {
                            layer.msg("源单数量请输入不小于0的数字!");
                            $("#HQty_SourceBill").val(oldHQty_SourceBill);
                            return false;
                        }
 
                        if (newHQty_SourceBill > HQty_waitProduce) {
                            layer.msg("条码生成数量大于最大可生成数量【" + HQty_waitProduce + "】!!");
                            $("#HQty_SourceBill").val(oldHQty_SourceBill);
                            return false;
                        }
 
                        //输入的源单数量合法,重算相关数据
                        var HQty_SourceBill = newHQty_SourceBill * 1;                               //源单数量
                        var HMinQty = $("#HMinQty").val() * 1;                                      //每包数量
                        if (!ref.test(HMinQty) || HMinQty == "0") {
                            layer.msg("每包数量请输入不小于0的数字!");
                            $("#HQty_SourceBill").val(oldHQty_SourceBill);
                            return false;
                        }
 
 
                        var HEndQty = HQty_SourceBill % HMinQty;                                    //尾包数量
                        var HBQty = (HQty_SourceBill - HEndQty) / HMinQty + ((HEndQty > 0) ? 1 : 0);      //包数
 
                        $("#HQty_SourceBill").val(newHQty_SourceBill);
                        $("#HBQty").val(HBQty);
                        $("#HEndQty").val(HEndQty);
                    });
                //#endregion
 
                    //#region 每包数量失焦事件
                    var oldHMinQty = "";                                    //修改前的值
                    var newHMinQty = "";                                    //修改后的值
                    $("#HMinQty").on('focus', function (data) {
                        oldHMinQty = $("#HMinQty").val() * 1;               //每包数量文本框获取焦点时获取修改前的值
                    }).on('blur', function (data) {
                        newHMinQty = $("#HMinQty").val();                   //金额文本框失焦时获取修改后的值
 
                        //判断输入的数据是否合法
                        var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                        if (!ref.test(newHMinQty) || newHMinQty == "0") {
                            layer.msg("每包数量请输入大于0的数字!");
                            $("#HMinQty").val(oldHMinQty);
                            return false;
                        }
 
                        //输入的源单数量合法,重算相关数据
                        var HMinQty = newHMinQty * 1;                                                   //每包数量
                        var HQty_SourceBill = $("#HQty_SourceBill").val() * 1;                          //源单数量
                        var HEndQty = HQty_SourceBill % HMinQty;                                        //尾包数量
                        var HBQty = (HQty_SourceBill - HEndQty) / HMinQty + ((HEndQty > 0) ? 1 : 0);    //包数
 
                        $("#HMinQty").val(HMinQty);
                        $("#HBQty").val(HBQty);
                        $("#HEndQty").val(HEndQty);
                    });
                //#endregion
                }
            });
            //#endregion
 
            //#region 子表相关监听
            //#region 头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
 
                switch (obj.event) {
                    //列设置
                    case 'set_HideColumn':
                        get_HideColumn();
                        break;
                }
            });
            //#endregion
 
            //#region 子表1:隐藏列设置
            function get_HideColumn() {
                var colName = "";
                var contentUrl = "";
                for (var i = 1; i < option.cols[0].length - 1; i++) {
                    colName += option.cols[0][i]["title"] + ",";
                }
                var urlStr = window.document.location.pathname;//获取文件路径
                var urlLen = urlStr.split('/');
                for (var i = 0; i < urlLen.length - 4; i++) {
                    contentUrl += "../";
                }
                colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
 
                contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
 
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: "隐藏列设置"  //标题
                    , closeBtn: 1  //窗体右上角关闭 的 样式
                    , shift: 2 //弹出动画
                    , area: ["50%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: [contentUrl, "yes"]
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //刷新表格数据
                        DisPlay_HideColumn();
                        //更新表格缓存的数据
                        layer.close(index);//关闭弹窗
                    }
                })
            }
            //#endregion
            //#region 子表1:显示列数据
            function DisPlay_HideColumn() {
                $.ajax({
                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                    async: false,
                    type: "GET",
                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                    async: false,
                    success: function (data1) {
                        if (data1.data.length != 0) {
                            var dataCol = [];//数据库查询出的列数据
                            var titleData = ["HMaterID", "HUnitID", "源单内码", "源单子内码", "源单号", "源单类型", "关联数量", "关联金额", "HQty_Old", "HQty_New"];//不需要显示的字段 可扩展
                            //titleData = [];
 
                            dataCol = data1.data[0].HGridString.split(',');
 
                            for (var i = 0; i < option.cols[0].length - 2; i++) {
                                var dataCols = dataCol[i].split('|');
                                //隐藏列
                                if (dataCols[1] == 1) {
                                    option.cols[0][i + 1]["hide"] = true;
                                }
                                //设置列宽
                                if (dataCols[3] > 0) {
                                    option.cols[0][i + 1]["width"] = dataCols[3];
                                }
                                //设置内容字体大小
                                if (data1.data[0].HFontSize != 0) {
                                    option.cols[0][i + 1]["style"] += "font-size:" + data1.data[0].HFontSize + "px;";
                                } else {
                                    option.cols[0][i + 1]["style"] += "font-size:100%";
                                }
                                //设置列宽
                                //if (data1.data[0].HColumnWidth != 0) {
                                //    option.cols[0][i + 1]["width"] = data1.data[0].HColumnWidth + "px;";
                                //} else {
                                //    option.cols[0][i + 1]["width"] = "";
                                //}
                                //显示列
                                if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
                                    option.cols[0][i + 1]["hide"] = false;
                                }
                                //字体所在位置(左 居中 右)
                                switch (dataCols[2]) {
                                    case "L":
                                        option.cols[0][i + 1]["align"] = "left";
                                        break;
                                    case "M":
                                        option.cols[0][i + 1]["align"] = "center";
                                        break;
                                    case "R":
                                        option.cols[0][i + 1]["align"] = "right";
                                        break;
                                }
                                //设置表格title属性显示别名
                                if (dataCols[4] != null && dataCols[4] != "") {
                                    option.cols[0][i + 1]["title"] = dataCols[4];
                                }
                            }
 
                            //取消冻结列
                            for (var i = 1; i < option.cols[0].length - 1; i++) {
                                if (option.cols[0][i]["fixed"] != null) {
                                    option.cols[0][i]["fixed"] = null;
                                }
                                else {
                                    break;
                                }
                            }
                            //冻结列
                            if (data1.data[0].HFixCols != 0) {
                                for (var i = 0; i < data1.data[0].HFixCols; i++) {
                                    if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
                                        data1.data[0].HFixCols += 1;
                                    }
                                    option.cols[0][i + 1]["fixed"] = "left";
                                }
                            }
                            table.render(option);
                        } else {
                            table.render(option);
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                })
            }
            //#endregion
            //#endregion
 
            //#region 页面初始化方法
            //#region 子表初始化
            function set_InitGrid() {
                //表头
                var columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HItemID', title: 'HItemID', width: 100, hide: true }
                    , { field: 'hmainid', title: 'hmainid', width: 100, hide: true }
                    , { field: 'hsubid', title: 'hsubid', width: 100, hide: true }
                    , { field: 'HinterID', title: 'HinterID', width: 100, hide: true }
                    , { field: '条码类型', title: '条码类型', width: 100 }
                    , { field: '条码编号', title: '条码编号', width: 120 }
                    , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                    , { field: '物料代码', title: '物料代码', width: 120 }
                    , { field: '物料名称', title: '物料名称', width: 120 }
                    , { field: '规格型号', title: '规格型号', width: 120 }
                    , { field: 'HUnitID', title: '计量单位ID', width: 100, hide: true }
                    , { field: '计量单位代码', title: '计量单位代码', width: 120 }
                    , { field: '计量单位', title: '计量单位', width: 120 }
                    , { field: 'HAuxPropID', title: '辅助属性ID', width: 100, hide: true }
                    , { field: '辅助属性代码', title: '辅助属性代码', width: 120 }
                    , { field: '辅助属性', title: '辅助属性', width: 120 }
                    , { field: '批号', title: '批号', width: 120 }
                    , { field: '数量', title: '数量', width: 100 }
                    , { field: '源单单号', title: '源单单号', width: 120 }
                    , { field: '计划跟踪号', title: '计划跟踪号', width: 120 }
                    , { field: '是否赠品', title: '是否赠品', width: 100 }
                    , { field: 'DeptID', title: '车间ID', width: 100, hide: true }
                    , { field: '车间', title: '车间', width: 120 }
                    , { field: 'HSupID', title: '供应商ID', width: 100, hide: true }
                    , { field: '供应商代码', title: '供应商代码', width: 120 }
                    , { field: '供应商', title: '供应商', width: 120 }
                    , { field: '客户条码编号', title: '客户条码编号', width: 120 }
                    , { field: '客户型号', title: '客户型号', width: 120 }
                    , { field: '往来单位', title: '往来单位', width: 120 }
                    , { field: '销售订单号', title: '销售订单号', width: 120 }
                    , { field: '销售订单行号', title: '销售订单行号', width: 120 }
                    , { field: '托号', title: '托号', width: 120 }
                    , { field: '总托数', title: '总托数', width: 100 }
                    , { field: '条码日期', title: '条码日期', width: 120 }
                    , { field: '生产入库日期', title: '生产入库日期', width: 120 }
                    , { field: '生产入库单号', title: '生产入库单号', width: 120 }
                    , { field: '生产入库次数', title: '生产入库次数', width: 100 }
                    , { field: '销售出库日期', title: '销售出库日期', width: 120 }
                    , { field: '销售出库单号', title: '销售出库单号', width: 120 }
                    , { field: '销售出库次数', title: '销售出库次数', width: 100 }
                    , { field: '作废标记', title: '作废标记', width: 100 }
                    , { field: '作废人', title: '作废人', width: 100 }
                    , { field: '备注', title: '备注', width: 120 }
                    , { field: '制作人', title: '制作人', width: 100 }
                    , { field: '日期', title: '日期', width: 120 }
                    , { field: '计划完工日期', title: '计划完工日期', width: 120 }
                    , { field: '打印次数', title: '打印次数', width: 100 }
                    , { field: 'HSTOCKORGID', title: 'HSTOCKORGID', width: 100, hide: true }
                    , { field: '生成组织', title: '生成组织', width: 120 }
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: false
                    , limit: 50000
                    , cellMinWidth: 120
                    , height: 'full-325'
                    , cols: [columns]
                    , data: []
                    , done: function (res, curr, count) {
                    }
                };
                table.render(option);
            }
            //#endregion
 
            //#region 下推页面初始化
            function setInit_PushBill() {
                //初始化日期、制单人、制单日期
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HBarCodeType").val(HBarCodeType);
                $("#HMainSourceInterID").val(HSourceInterID);
                $("#HMainSourceEntryID").val(HSourceEntryID);
                $("#HMainSourceBillNo").val(HSourceBillNo);
                $("#HMainSourceBillType").val(HSourceBillType);
 
                //禁用条码类型
                $("#HBarCodeType").attr("disabled", true);
 
                if (HBarCodeType == "BarCode") {
                    var HBarCodeQtyElement = document.getElementById("HBarCodeQtyElement");
                    HBarCodeQtyElement.style.display = "none";
 
                    var temp = getPushSource_POInStockBillInit(HSourceInterID, HSourceEntryID);
                    var dataArray = [];
                    dataArray.push(temp);
 
                    form.val("component-form-group", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                        "HPOOrderBillNo": dataArray[0].源单单号
                        , "HSupID": dataArray[0].HSupID
                        , "HSupNumber": dataArray[0].供应商代码
                        , "HSupName": dataArray[0].供应商
                        , "HMaterID": dataArray[0].HMaterID
                        , "HMaterNumber": dataArray[0].物料代码
                        , "HMaterName": dataArray[0].物料名称
                        , "HMaterModel": dataArray[0].规格型号
                        , "HUnitID": dataArray[0].HUnitID
                        , "HUnitName": dataArray[0].计量单位
                        , "HQty_SourceBill": (dataArray[0].数量 * 1) - (dataArray[0].已生成条码数量 * 1)
                        , "HBatchNo": dataArray[0].批号
                        , "HAuxPropID": dataArray[0].HAuxPropID
                        , "HAuxPropNumber": dataArray[0].辅助属性代码
                        , "HAuxPropName": dataArray[0].辅助属性
                    });
                    HZZRQ = dataArray[0].制造日期;
 
                    HQty_waitProduce = (dataArray[0].数量 * 1) - (dataArray[0].已生成条码数量 * 1);
                }
                else if (HBarCodeType == "BarCode_Box") {
                    var HQty_SourceElement = document.getElementById("HQty_SourceElement");
                    HQty_SourceElement.style.display = "none";
                    var HMinQtyElement = document.getElementById("HMinQtyElement");
                    HMinQtyElement.style.display = "none";
                    var HBQtyElement = document.getElementById("HBQtyElement");
                    HBQtyElement.style.display = "none";
                    var HEndQtyElement = document.getElementById("HEndQtyElement");
                    HEndQtyElement.style.display = "none";
                    var HEndQty_SureElement = document.getElementById("HEndQty_SureElement");
                    HEndQty_SureElement.style.display = "none";
 
 
                    var temp = getPushSource_POInStockBillInit(HSourceInterID, HSourceEntryID);
                    var dataArray = [];
                    dataArray.push(temp);
 
                    form.val("component-form-group", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                        "HPOOrderBillNo": dataArray[0].源单单号
                        , "HSupID": dataArray[0].HSupID
                        , "HSupNumber": dataArray[0].供应商代码
                        , "HSupName": dataArray[0].供应商
                        , "HMaterID": dataArray[0].HMaterID
                        , "HMaterNumber": dataArray[0].物料代码
                        , "HMaterName": dataArray[0].物料名称
                        , "HMaterModel": dataArray[0].规格型号
                        , "HUnitID": dataArray[0].HUnitID
                        , "HUnitName": dataArray[0].计量单位
                        , "HQty_SourceBill": dataArray[0].数量
                        , "HBatchNo": dataArray[0].批号
                        , "HAuxPropID": dataArray[0].HAuxPropID
                        , "HAuxPropNumber": dataArray[0].辅助属性代码
                        , "HAuxPropName": dataArray[0].辅助属性
                    });
                    HZZRQ = dataArray[0].制造日期;
                }
                else if (HBarCodeType == "BarCode_Pack") {
                    var HQty_SourceElement = document.getElementById("HQty_SourceElement");
                    HQty_SourceElement.style.display = "none";
                    var HMinQtyElement = document.getElementById("HMinQtyElement");
                    HMinQtyElement.style.display = "none";
                    var HBQtyElement = document.getElementById("HBQtyElement");
                    HBQtyElement.style.display = "none";
                    var HEndQtyElement = document.getElementById("HEndQtyElement");
                    HEndQtyElement.style.display = "none";
                    var HEndQty_SureElement = document.getElementById("HEndQty_SureElement");
                    HEndQty_SureElement.style.display = "none";
 
 
                    var temp = getPushSource_POInStockBillInit(HSourceInterID, HSourceEntryID);
                    var dataArray = [];
                    dataArray.push(temp);
 
                    form.val("component-form-group", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                        "HPOOrderBillNo": dataArray[0].源单单号
                        , "HSupID": dataArray[0].HSupID
                        , "HSupNumber": dataArray[0].供应商代码
                        , "HSupName": dataArray[0].供应商
                        , "HMaterID": dataArray[0].HMaterID
                        , "HMaterNumber": dataArray[0].物料代码
                        , "HMaterName": dataArray[0].物料名称
                        , "HMaterModel": dataArray[0].规格型号
                        , "HUnitID": dataArray[0].HUnitID
                        , "HUnitName": dataArray[0].计量单位
                        , "HQty_SourceBill": dataArray[0].数量
                        , "HBatchNo": dataArray[0].批号
                        , "HAuxPropID": dataArray[0].HAuxPropID
                        , "HAuxPropNumber": dataArray[0].辅助属性代码
                        , "HAuxPropName": dataArray[0].辅助属性
                    });
                    HZZRQ = dataArray[0].制造日期;
                }
                else {
                    return layer.msg('当前不支持该源单下推!!');
                }
            }
 
            //#endregion
 
            //#region 根据主内码与子内码获取源单收料通知单数据
            function getPushSource_POInStockBillInit(HSourceInterID, HSourceEntryID) {
                var res = "none";
                var sql = "select * from h_v_IF_POInStockBillList_Source where 1=1 and HMainID = " + HSourceInterID + " and HSubID = " + HSourceEntryID;
                var ModRightNameCheck = "";
                $.ajax({
                    url: GetWEBURL() + "/CommonModel/searchMethod",
                    async: false,
                    type: "GET",
                    data: {
                        "sql": sql
                        , "user": sessionStorage["HUserName"]
                        , "ModRightNameCheck": ModRightNameCheck
                    },
                    success: function (result) {
                        if (result.code == 1) { // 说明验证成功了,
                            res = result.data[0];
                        } else {
                            res = result.data;
                            //layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function (err) {
                        res = "none";
                        layer.alert("发生错误!" + err, { icon: 5 });
                    }
                });
                return res;
            }
            //#endregion
            //#endregion
            
            //#region 页面通用方法
            //#region 判断是否登录 未登录则跳到登录页
            function get_LoginIs() {
                if (sessionStorage.login != "login") {
                    layer.confirm("登录失效,请重新登录!", {
                        icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
                    }, function () { window.location.href = "../../user/login.html"; });
                }
            }
            //#endregion
 
            //#region 获取参数_传递的JSON格式参数
            function getUrlVars_JSON() {
                var datajson;
                var str = window.location.search; //获取链接中传递的参数
                var arr = str.substring(str.lastIndexOf("=")+1);
                datajson = $.parseJSON(decodeURI(arr));
                return datajson;
            }
            //#endregion
 
            //#region  时间转换
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
 
                if (month.length < 2) {
                    month = '0' + month;
                }
                if (day.length < 2) {
                    day = '0' + day;
                }
 
                return [year, month, day].join('-');
            }
            //#endregion
            //#endregion
            //#endregion
        });
    </script>
</body>
</html>