yxj
2025-01-03 30a3bd621ecb96b109bc5a743f2acfdd89a8c75c
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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>系统配置</title>
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <style>
        /* 防止下拉框的下拉列表被隐藏---必须设置--- */
        .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: 2px;background-color: #efefef;">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                    <div style="padding: 10px; ">
                        <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
                        <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="Exit" id="Exit">退出</button>
                    </div>
                    <div class="layui-collapse">
                        <div class="layui-colla-item">
                            <div class="layui-form-item" style="padding-top: 10px;">
                                <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="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>插入一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>上移</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>下移</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                                    </div>
                                </script>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
<!--删除按钮-->
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!--复选框 是否隐藏-->
<script type="text/html" id="HIsHide">
    <div class="layui-input-block" style="margin-left: 20px;">
        <input type="checkbox" name="HIsHide" lay-filter="HIsHide" id="HIsHide{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
    </div>
</script>
<!--复选框 是否禁用-->
<script type="text/html" id="HIsDisabled">
    <div class="layui-input-block" style="margin-left: 20px;">
        <input type="checkbox" name="HIsDisabled" lay-filter="HIsDisabled" id="HIsDisabled{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
    </div>
</script>
<!--复选框 是否必填-->
<script type="text/html" id="HIsMust">
    <div class="layui-input-block" style="margin-left: 20px;">
        <input type="checkbox" name="HIsMust" lay-filter="HIsMust" id="HIsMust{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
    </div>
</script>
<!--行下拉选择(元素ID)-->
<script type="text/html" id="HElementID">
    <select name="HElementID" lay-filter="HElementID" id="HElementID{{d.LAY_TABLE_INDEX+1}}">
    </select>
</script>
<!--行下拉选择(父级元素ID)-->
<script type="text/html" id="HParentElementID">
    <select name="HParentElementID" lay-filter="HParentElementID" id="HParentElementID{{d.LAY_TABLE_INDEX+1}}">
    </select>
</script>
<!--行下拉选择(组件类型)-->
<script type="text/html" id="HElementType">
    <select name="HElementType" lay-filter="HElementType" id="HElementType{{d.LAY_TABLE_INDEX+1}}">
    </select>
</script>
<!--行下拉选择(字段名)-->
<script type="text/html" id="HFieldName">
    <select name="HFieldName" lay-filter="HFieldName" id="HFieldName{{d.LAY_TABLE_INDEX+1}}">
    </select>
</script>
<!--行下拉选择(字段数据类型)-->
<script type="text/html" id="HFieldDataType">
    <select name="HFieldDataType" lay-filter="HFieldDataType" id="HFieldDataType{{d.LAY_TABLE_INDEX+1}}">
    </select>
</script>
 
<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 = "Xt_AutoLoadBillList";
 
        //获取参数
        var params = getUrlVars();
        var HSetMainModName = params[params[0]];                //表头加载模块名称
        var HTableName = params[params[1]];                                    //主表名
        var HDataViewName = params[params[2]];                  //视图名
        var HDataProcName = params[params[3]];                  //存储过程名
        var HRowElementCount = params[params[4]];               //每行元素数
 
        var HUserName = sessionStorage["HUserName"];            //用户名
        var HInterID = 0;
        //元素ID与元素数据类型对照列表
        var HFieldDataTypeForElementID = [];
 
        //查询条件
        var sWhere = "";
        var option = [];
 
        //#endregion
 
        //#region 进入页面即加载
 
        //页面初始化
        set_ClearBill();
 
        //#endregion
 
        //#region 触发事件
        //#region 复选框触发事件相关监听
        //#region 是否隐藏
        form.on('checkbox(HIsHide)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (value.LAY_TABLE_INDEX == dataindex) {
                    value.HIsHide = data.elem.checked;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
 
        //#region 是否禁用
        form.on('checkbox(HIsDisabled)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (value.LAY_TABLE_INDEX == dataindex) {
                    value.HIsDisabled = data.elem.checked;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
 
        //#region 是否必填
        form.on('checkbox(HIsMust)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (value.LAY_TABLE_INDEX == dataindex) {
                    value.HIsMust = data.elem.checked;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
        //#endregion
 
        //#region 下拉框触发事件相关监听
        //#region 表格行选择处理(元素ID)
        form.on('select(HElementID)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HElementID = data.value;//把选中下拉框id值赋值给表格缓存
                    for (var i = 0; i < HFieldDataTypeForElementID.length; i++) {
                        if (value.HElementID == HFieldDataTypeForElementID[i].HElementID) {
                            value.HFieldDataType = HFieldDataTypeForElementID[i].HFieldDataType;
                            value.HElementIDAdditionalName = value.HElementID;
                            $('#HFieldDataType' + (index+1) + '').val(value.HFieldDataType);
                            form.render('select');
                            table.render(option);
                            //根据option中的数据,设置子表中的下拉列表、复选框
                            setSelectByTableRender();
                            break;
                        }
                    }
                }
            });
        });
        //#endregion
 
        //#region 表格行选择处理(父级元素ID)
        form.on('select(HParentElementID)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HParentElementID = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
 
        //#region 表格行选择处理(组件类型)
        form.on('select(HElementType)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HElementType = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
 
        //#region 表格行选择处理(字段名)
        form.on('select(HFieldName)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HFieldName = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
 
        //#region 表格行选择处理(数据类型)
        form.on('select(HFieldDataType)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HFieldDataType = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
        //#endregion
 
        //#region 操作按钮相关监听
        //#region 保存提交
        form.on('submit(btnSave)', function (data) {//提交
            set_AddNew(data);
        });
        //#endregion
 
        //#region 退出
        form.on('submit(Exit)', function () {
            Pub_Close(1);
        })
        //#endregion
        //#endregion
 
        //#region 子表相关监听
        //#region 头工具栏事件
        table.on('toolbar(mainTable)', function (obj) {
            var checkStatus = table.checkStatus('mainTable')
                , data = checkStatus.data;
            //新增行表格数据
            var NewRow = {
                "HArrangeOrder": "0",
                "HArrangeOrderSub": "0",
                "HParentElementID": "",
                "HIsHide": false,
                "HIsDisabled": false,
                "HIsMust": false,
                "HElementID": "",
                "HElementIDAdditionalName": "",
                "HElementLabel": "",
                "HElementType": "",
                "HFieldMaxLength": "0",
                "HDefaultValue": "",
                "HFieldName": "",
                "HFieldDataType": "",
                "HRelateUrl": "",
                "HSubWindowBackData": "",
                "HSubWindowBackDataMethodName": "",
                "HSelectContent": "",
            };
 
            switch (obj.event) {
                //新增一行
                case 'btn-AddLine': btnAddLine(NewRow);
                    break;
                //复制一行
                case 'btn-CopyLine': btnCopyLine(data);
                    break;
                //指定位置下插入一行
                case 'btn-InsertLine': btnInsertLine(NewRow)
                    break;
                //上移
                case 'btn-Up': btn_up();
                    break;
                //下移
                case 'btn-Under': btn_under();
                    break;
                //列设置
                case 'set_HideColumn':
                    get_HideColumn();
                    break;
            }
        });
        //#endregion
 
        //#region 行内事件
        table.on('tool(mainTable)', function (obj) {
            set_GridDelete(obj);   //行内删除
            set_GridCellCheck(obj); //行内快捷键筛选
        });
        //#endregion
        //#endregion
        //#endregion
 
        //#region 页面初始化相关方法
        //#region 获取参数
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
        //#endregion
 
        //#region 初始化界面
        function set_ClearBill() {
            ////根据url参数获取加载页面的数据[主表名、视图名、存储过程名]
            //getBaseDataByURLParams();
 
            //初始化子表
            set_InitGrid();
 
            //查询历史设置记录,设置子表
            if (RoadBillMain() == true) {
 
            } else {
                //初始化子表中的下拉列表
                setSelectInit();
            }
        }
        //#endregion
 
        //#region 子表初始化
        function set_InitGrid() {
            option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 420
                , cellMinWidth: 90
                , limit: 500
                , cols: [[
                    { type: 'checkbox', totalRowText: '合计行' }
                    , { type: 'numbers', title: '序号', width: 100 }
                    , { field: 'HArrangeOrder', title: '一级次序', width: 100, edit: true }
                    , { field: 'HArrangeOrderSub', title: '二级次序', width: 100, edit: true }
                    , { field: 'HParentElementID', title: '父级元素ID', width: 100, templet: '#HParentElementID' }
                    , { field: 'HIsHide', title: '隐藏', width: 100, templet: '#HIsHide' }
                    , { field: 'HIsDisabled', title: '禁用', width: 100, templet: '#HIsDisabled' }
                    , { field: 'HIsMust', title: '必填', width: 100, templet: '#HIsMust' }
                    , { field: 'HElementID', title: '元素ID', width: 100, templet: '#HElementID' }
                    , { field: 'HElementIDAdditionalName', title: '元素ID附加字段', width: 100, edit: true, event:"HElementIDAdditionalName" }
                    , { field: 'HElementLabel', title: '元素标签', width: 100, edit: true }
                    , { field: 'HElementType', title: '元素类型', width: 100, templet: '#HElementType' }
                    , { field: 'HFieldMaxLength', title: '最大长度', width: 100, edit: true }
                    , { field: 'HDefaultValue', title: '默认值', width: 100, edit: true }
                    , { field: 'HFieldName', title: '字段名', width: 100, templet: '#HFieldName' }
                    , { field: 'HFieldDataType', title: '字段数据类型', width: 100, templet: '#HFieldDataType' }
                    , { field: 'HRelateUrl', title: '路径信息', width: 100, edit: true }
                    , { field: 'HSubWindowBackData', title: '返回数据对应键值', width: 100, edit: true }
                    , { field: 'HSubWindowBackDataMethodName', title: '返回数据父级方法名', width: 100, edit: true }
                    , { field: 'HSelectContent', title: '下拉列表默认对应键值', width: 100, edit: true }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                ]]
            };
 
            var rowdata = [{
                "HArrangeOrder": "0",
                "HArrangeOrderSub": "0",
                "HParentElementID": "",
                "HIsHide": false,
                "HIsDisabled": false,
                "HIsMust": false,
                "HElementID": "",
                "HElementIDAdditionalName": "",
                "HElementLabel": "",
                "HElementType": "",
                "HFieldMaxLength": "0",
                "HDefaultValue": "",
                "HFieldName": "",
                "HFieldDataType": "",
                "HRelateUrl": "",
                "HSubWindowBackData": "",
                "HSubWindowBackDataMethodName": "",
                "HSelectContent": "",
            }];
 
            option.data = rowdata;
            table.render(option);
 
            //根据option中的数据,设置子表中的下拉列表、复选框
            setSelectByTableRender();
        }
        //#endregion
 
        //#region 根据url参数获取加载页面的数据
        function getBaseDataByURLParams() {
            $.ajax({
                type: "get",
                async: false,
                url: GetWEBURL() + "/Xt_DefineBillMainSet/getDefineBillMainSet",
                data: { "HModName": HSetMainModName, "user": sessionStorage["HUserName"] },
                success: function (result) {
                    if (result.count == 1 && result.data.length>0) { // 说明验证成功了,
                        HTableName = result.data[0]["HTableName"];
                        HDataViewName = result.data[0]["HDataViewName"];
                        HDataProcName = result.data[0]["HDataProcName"];
                    } else {
 
                    }
                }
            })
        }
        //#endregion
 
        //#region 查询历史设置记录,设置子表
        function RoadBillMain() {
            var returnResult = false;
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Xt_DefineBillMainSet/getDefineBillMainSet',
                type: "GET",
                async: false,
                data: { "HModName": HSetMainModName, "user": sessionStorage["HUserName"] },
                success: function (data1) {
                    if (data1.count == 1) {
                        var data = data1.data;
 
                        if (data.length > 0) {
                            for (var i = 0; i < data.length; i++) {
                                if (data[i].HUser == sessionStorage["HUserName"]) {
                                    HInterID = data[i].HInterID;
                                }
 
                                data[i].HElementIDAdditionalName = data[i].HElementID;
                            }
                        }
 
                        option.data = data;
                        table.render(option);
 
                        
 
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                        layer.close(ajaxLoad);
 
                        DisPlay_HideColumn();
 
                        returnResult = true;
                    } else {
                        layer.close(ajaxLoad);
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
            return returnResult;
        }
        //#endregion
 
        //#region 下拉框初始化
        //#region 下拉框初始化
        function setSelectInit() {
            setSelectInit_HElementID();
 
            setSelectInit_HParentElementID();
 
            setSelectInit_HElementType();
 
            setSelectInit_HFieldDataType();
 
            setSelectInit_HFieldName();
        }
        //#endregion
 
        //#region 元素ID、元素数据类型
        function setSelectInit_HElementID() {
            $.ajax({
                type: "get",
                async: false,
                url: GetWEBURL() + "/Xt_DefineBillMainSet/getColsListByName",
                data: { "HName": HTableName },
                success: function (data1) {
                    if (data1.count == 1) { // 说明验证成功了,
                        var HElementIDList = [];                                //元素ID下拉列表数据
                        var HFieldDataTypeList = [];                              //数据类型下拉列表数据
                        //获取下拉列表的列表数据
                        for (var key in data1.list) {
                            if ($.inArray(data1.list[key].ColmCols, HElementIDList) == -1) {
                                HFieldDataTypeForElementID.push({
                                    "HElementID": data1.list[key].ColmCols
                                    , "HFieldDataType": data1.list[key].ColmType
                                })
 
                                HElementIDList.push(data1.list[key].ColmCols);
                                if ($.inArray(data1.list[key].ColmType, HFieldDataTypeList) == -1) {
                                    HFieldDataTypeList.push(data1.list[key].ColmType);
                                }
                            }
                        }
                        //根据下拉列表的列表数据,设置下拉列表的列表
                        for (var i = 0; i < option.data.length; i++) {
                            var Organization = "";
                            Organization += '<option  style="color:blue;" selected="selected" value=""></option>';
                            for (var j = 0; j < HElementIDList.length; j++) {
                                Organization += '<option  style="color:blue;" value="' + HElementIDList[j] + '">' + HElementIDList[j] + '</option>';
                            }
                            $('#HElementID' + (i + 1) + '').empty();
                            $('#HElementID' + (i + 1) + '').append(Organization);
 
                            var Organization1 = "";
                            Organization1 += '<option  style="color:blue;" selected="selected" value=""></option>';
                            for (var j = 0; j < HFieldDataTypeList.length; j++) {
                                Organization1 += '<option  style="color:blue;" value="' + HFieldDataTypeList[j] + '">' + HFieldDataTypeList[j] + '</option>';
                            }
                            $('#HFieldDataType' + (i + 1) + '').empty();
                            $('#HFieldDataType' + (i + 1) + '').append(Organization1);
                        }
 
                        form.render('select');
                    } else {
 
                    }
                }
            })
        }
        //#endregion
 
        //#region 父级元素ID
        function setSelectInit_HParentElementID() {
            var HElementIDList = ["HBaseInfo", "HFileInfo","HOtherInfo"];
            var HProTypeList = ["基本信息","附件信息","其他信息"];
            for (var i = 0; i < option.data.length; i++) {
                var Organization = "";
                Organization += '<option  style="color:blue;" selected="selected" value=""></option>';
                for (var j = 0; j < HProTypeList.length; j++) {
                    Organization += '<option  style="color:blue;" value="' + HElementIDList[j] + '">' + HProTypeList[j] + '</option>';
                }
                $('#HParentElementID' + (i + 1) + '').empty();
                $('#HParentElementID' + (i + 1) + '').append(Organization);
            }
            form.render('select');
        }
        //#endregion
 
        //#region 组件类型
        function setSelectInit_HElementType() {
            var HProTypeList = ["标题", "页签", "输入文本", "富文本框", "日期", "选择弹窗", "选择弹窗_transfer", "下拉列表"];
            for (var i = 0; i < option.data.length; i++) {
                var Organization = "";
                Organization += '<option  style="color:blue;" selected="selected" value=""></option>';
                for (var j = 0; j < HProTypeList.length; j++) {
                    Organization += '<option  style="color:blue;" value="' + HProTypeList[j] + '">' + HProTypeList[j] + '</option>';
                }
                $('#HElementType' + (i + 1) + '').empty();
                $('#HElementType' + (i + 1) + '').append(Organization);
            }
            form.render('select');
        }
        //#endregion
 
        //#region 字段名
        function setSelectInit_HFieldName() {
            $.ajax({
                type: "get",
                async: false,
                url: GetWEBURL() + "/Xt_DefineBillMainSet/getColsListByName",
                data: { "HName": HDataViewName },
                success: function (data1) {
                    if (data1.count == 1) { // 说明验证成功了,
                        var HFieldNameList = [];                                    //字段名下拉列表数据
                        //获取下拉列表的列表数据
                        for (var key in data1.list) {
                            if ($.inArray(data1.list[key].ColmCols, HFieldNameList) == -1) {
                                HFieldNameList.push(data1.list[key].ColmCols);
                            }
                        }
 
                        //根据下拉列表的列表数据,设置下拉列表的列表
                        for (var i = 0; i < option.data.length; i++) {
                            var Organization = "";
                            Organization += '<option  style="color:blue;" selected="selected" value=""></option>';
                            for (var j = 0; j < HFieldNameList.length; j++) {
                                Organization += '<option  style="color:blue;" value="' + HFieldNameList[j] + '">' + HFieldNameList[j] + '</option>';
                            }
                            $('#HFieldName' + (i + 1) + '').empty();
                            $('#HFieldName' + (i + 1) + '').append(Organization);
                        }
 
                        form.render('select');
                    } else {
 
                    }
                }
            })
        }
        //#endregion
 
        //#region 字段数据类型
        function setSelectInit_HFieldDataType() {
 
        }
        //#endregion
        //#endregion
        //#endregion
 
        //#region 此页面所有的方法
 
        //#region 操作按钮调用方法
        //#region 保存方法
        function set_AddNew(data) {
            data.field.HInterID = HInterID;
            data.field.HModName = HSetMainModName;
            data.field.HUser = sessionStorage["HUserName"];
            data.field.HTableName = HTableName;
            data.field.HDataViewName = HDataViewName;
            data.field.HDataProcName = HDataProcName;
            data.field.HRowElementCount = HRowElementCount;
 
            //序列化表头信息和子表信息
            var sMainStr = JSON.stringify(data.field);
            var sSubStr = JSON.stringify(option.data);
            //拼接参数
            var sMainSub = sMainStr + ';' + sSubStr + ";" + sessionStorage["HUserName"];
 
            var index = layer.load();
            $.ajax({
                type: "POST",
                url: GetWEBURL() + "/Xt_DefineBillMainSet/SaveXt_DefineBillMainSet", //方法所在页面和方法名
                async: true,
                data: { "msg": sMainSub },
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) { // 说明验证成功了,
                        layer.msg(data.Message, { icon: 1 });
                        layer.close(index);
                    }
                    else {
                        layer.alert(data.Message, { icon: 5 });
                        layer.close(index);
                    }
                },
                error: function (err) {
                    layer.alert("错误:" + err, { icon: 5 });
                    layer.close(index);
                }
            });
        }
        //#endregion
        //#endregion
 
        //#region 子表相关方法
        //#region 根据option中的数据,设置子表中的下拉列表、复选框
        function setSelectByTableRender() {
            //下拉框列表初始化
            setSelectInit();
 
            for (var i = 1; i <= option.data.length; i++) {
                $('#HElementID' + i + '').val(option.data[i - 1].HElementID);
                $('#HParentElementID' + i + '').val(option.data[i - 1].HParentElementID);
                $('#HElementType' + i + '').val(option.data[i - 1].HElementType);
                $('#HFieldName' + i + '').val(option.data[i - 1].HFieldName);
                $('#HFieldDataType' + i + '').val(option.data[i - 1].HFieldDataType);
 
                $('#HIsHide' + i + '').attr("checked", option.data[i - 1].HIsHide);
                $('#HIsDisabled' + i + '').attr("checked", option.data[i - 1].HIsDisabled);
                $('#HIsMust' + i + '').attr("checked", option.data[i - 1].HIsMust);
            }
            form.render('select');
            form.render('checkbox');
        }
        //#endregion
 
        //#region 上移
        function btn_up() {
            var checkStatus = table.checkStatus('mainTable')
                , data = checkStatus.data;
            if (data.length == 1) {
                var tables = [];
                //获取表格的全部行
                var rowList = table.cache['mainTable'];
                for (var i = 0; i < rowList.length; i++) {          //遍历表格的行
                    if (rowList[i].LAY_CHECKED == true) {           //获取选中行的位置
                        //如果是第一行上移,则失败并提醒
                        if (i == 0) {
                            layer.msg("第一行数据无法上移!");
                            return;
                        }
                        tables.push(option.data[i - 1]);
                        data[0].LAY_CHECKED = true;
                        option.data[i - 1] = data[0];
                        option.data[i] = tables[0];
                        table.render(option);
 
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
 
                        break;
                    }
                }
            } else {
                layer.msg("请选择一行数据!");
            }
        }
        //#endregion
 
        //#region 下移
        function btn_under() {
            var checkStatus = table.checkStatus('mainTable')
                , data = checkStatus.data;
            if (data.length == 1) {
                var tables = [];
                //获取表格的全部行
                var rowList = table.cache['mainTable'];
                for (var i = 0; i < rowList.length; i++) {          //遍历表格的行
                    if (rowList[i].LAY_CHECKED == true) {           //获取选中行的位置
                        //如果是最后一行下移,则失败并提醒
                        if (i == option.data.length - 1) {
                            layer.msg("最后一行数据无法下移!");
                            return;
                        }
 
 
                        tables.push(option.data[i + 1]);
                        data[0].LAY_CHECKED = true;
                        option.data[i + 1] = data[0];
                        option.data[i] = tables[0];
                        table.render(option);
 
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                        break;
                    }
                }
            } else {
                layer.msg("请选择一行数据!");
            }
        }
        //#endregion
 
        //#region 在末尾增加一行
        function btnAddLine(NewRow) {
            table.cache["mainTable"].push(NewRow);
            option.data = table.cache["mainTable"];
            table.render(option);
 
            //根据option中的数据,设置子表中的下拉列表、复选框
            setSelectByTableRender();
            //rows++;
            //layer.msg('增加一行按钮!')
        }
        //#endregion
 
        //#region 在指定行下插入一行
        function btnInsertLine(NewRow) {
            var checkStatus = table.checkStatus('mainTable')
                , data = checkStatus.data;
            if (checkStatus.data.length === 1) {
                var tables = [];                                    //存储插入一行后的表格数据
                //获取表格的全部行
                var rowList = table.cache['mainTable'];
                for (var i = 0; i < rowList.length; i++) {          //遍历表格的行
                    tables.push(option.data[i]);
                    if (rowList[i].LAY_CHECKED == true) {           //获取选中行的位置
                        tables.push(NewRow);
                    }
                }
                option.data = tables;
                table.render(option);
 
                //根据option中的数据,设置子表中的下拉列表、复选框
                setSelectByTableRender();
            } else {
                layer.msg('请选择一行数据编辑!');
            }
        }
        //#endregion
 
        //#region 复制一行
        function btnCopyLine(data) {
            var copydata = JSON.stringify(data);
            if (data.length <= 0) {
                layer.msg("请选择需要复制的一行!");
            }
            else if (data.length > 1) {
                layer.msg("只能选择复制一行!");
            }
            else {
                var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                option.data = table.cache["mainTable"];//将数据绑定到data上
                //设置复制得到的记录的实际称重为0
                option.data[option.data.length - 1].HWeight = "0";
 
                table.render(option);//将数据渲染到表格上
 
                //根据option中的数据,设置子表中的下拉列表、复选框
                setSelectByTableRender();
            }
        }
        //#endregion
 
        //#region 行内删除
        function set_GridDelete(obj) {
            var data = obj.data;
            var rowIndex = $(obj.tr).attr("data-index");
            if (obj.event === 'del') {
                layer.confirm('真的删除行吗?', function (index) {
                    console.log("索引为:" + rowIndex);
                    if (rowIndex === '0') {
                        layer.msg('首行无法删除!!!');
                    } else {
                        obj.del();
                        option.data = table.cache["mainTable"];//将数据绑定到data上
                        table.reload(option);
                        layer.close(index);
                    }
                });
            }
        }
        //#endregion
 
        //#region 行内快捷键筛选
        function set_GridCellCheck(obj) {
            $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                if (event.key == "F7") {
                    if (obj.event == "HMaterID") {
                        
                    }
                    obj.event = "";
                    return false;
                }
            })
        }
        //#endregion
 
        //#region 监听单元格编辑  单元格编辑后 变更
        table.on('edit(mainTable)', function (obj) {
            //数值格式校验工具
            var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
            var temp = "";
 
            // 单元格编辑之前的值
            var oldText = $(this).prev().text();
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
 
            switch (field) {
                case "HElementIDAdditionalName":                                                       //元素ID附加字段
                    obj.update({
                        HElementID: ""
                        , HFieldDataType: ""
                    });
                    table.render(option);
                    //根据option中的数据,设置子表中的下拉列表、复选框
                    setSelectByTableRender();
                    break;
                default:
            }
        });
        //#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 = [];                                                                     //不需要显示的字段 可扩展
 
                        dataCol = data1.data[0].HGridString.split(',');
 
                        for (var i = 0; i < option.cols[0].length - 2; i++) {
                            if (i >= dataCol.length) {
                                continue;
                            }
 
                            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);
 
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                    } else {
                        table.render(option);
 
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                    }
                }, error: function () {
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            })
        }
            //#endregion
        //#endregion
        //#endregion
 
    });
 
 
</script>