yusijie
2024-09-26 301c9ba4bfa1af5547d723c2fbdbfb35071dab3b
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
 
 
<!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">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/style-self.css" media="all">
    <style type="text/css">
        .layui-input-block {
            width: 190px;
        }
    </style>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card" style="padding: 1px">
                    <div class="layui-card-body" style="padding: 1px;">
                        <form class="layui-form" action="" lay-filter="component-form-group">
                            <div class="layui-collapse">
                                <div class="layui-colla-item">
                                    <div class="layui-colla-title layui-inline">
                                        <div class="layui-inline">
                                            <span>更多</span>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">单据号</label>
                                        <div class="layui-input-block" style="width:150px;">
                                            <input type="text" class="layui-input" name="HBillNo" id="HBillNo">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">采购订单号</label>
                                        <div class="layui-input-block" style="width:150px;">
                                            <input type="text" class="layui-input" name="HBillNoFrom" id="HBillNoFrom">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">开始日期</label>
                                        <div class="layui-input-block" style="width:120px;">
                                            <input type="text" class="layui-input" name="HDate1" id="HDate1">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">结束日期</label>
                                        <div class="layui-input-block" style="width:120px;">
                                            <input type="text" class="layui-input" name="HDate2" id="HDate2">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">单据状态</label>
                                        <div class="layui-input-block">
                                            <select id="HClStatus" name="HClStatus" lay-filter="">
                                                <option value=""  selected="">全部</option>
                                                <option value="未审核">未审核</option>
                                                <option value="已审核">已审核</option>
                                                <option value="未关闭">未关闭</option>
                                                <option value="已关闭">已关闭</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">物料编码</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="HMaterNumber" id="HMaterNumber">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">物料名称</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="HName" id="HName">
                                        </div>
                                    </div>  
                                    <div class="layui-inline">
                                        <label class="layui-form-label">供应商</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="HSupName" id="HSupName">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch">
                                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                        </button>
                                    </div>
                                    <div class="layui-colla-content" style="padding-left:82px">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">旧物料编码</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" name="HOldMaterNumber" id="HOldMaterNumber">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">规格型号</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" name="HModel" id="HModel">
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="display:none">
                                            <label class="layui-form-label">订单状态</label>
                                            <div class="layui-input-block">
                                                <select name="HStatus" id="HStatus" lay-filter="">
                                                    <option value="" selected="">全部</option>
                                                    <option value="未打印">未打印</option>
                                                    <option value="未到货">未到货</option>
                                                    <option value="已到货">已到货</option>
                                                    <option value="未生成条码">未生成条码</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="display:none">
                                            <label class="layui-form-label">送货单号</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" name="HInnerBillNo" id="HInnerBillNo">
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="display:none;">
                                            <label class="layui-form-label">物料代码</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" name="HNumber" id="HNumber">
                                            </div>
                                        </div>
                                    </div>
 
                                </div>
                            </div>
                        </form>
                    </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="btn-getCheckData"><i class="layui-icon layui-icon-tips"></i>预览</button>-->
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-reload"><i class="layui-icon layui-icon-refresh"></i>刷新</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Audit"><i class="layui-icon layui-icon-radio"></i>审核</button>
                            <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-confirm"><i class="layui-icon layui-icon-ok-circle"></i>确认</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-back"><i class="layui-icon layui-icon-close-fill"></i>驳回</button>-->
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-details"><i class="layui-icon layui-icon-form"></i>详情</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-changebg"><i class="layui-icon layui-icon-form"></i>变更</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-print"><i class="layui-icon layui-icon-print"></i>打印送货单</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-print-Convenient"><i class="layui-icon layui-icon-print"></i>一键打印</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Delete"><i class="layui-icon layui-icon-delete"></i>删除</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-generate"><i class="layui-icon layui-icon-file"></i>生成条码</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-exit"><i class="layui-icon layui-icon-return"></i>退出</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-HideColumn"><i class="layui-icon layui-icon-return"></i>隐藏列设置</button>
                        </div>
                    </script>
                </div>
            </div>
        </div>
    </div>
    <!--<script src="../../layuiadmin/layui/lay/modules/mobile/jquery-3.3.1.min.js"></script>-->
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../CreateControl.js"></script>
    <script src="../GRInstall.js"></script>
    <script src="../GRUtility.js"></script>
    <script src="../../../../Scripts/webConfig.js"></script>
    <script>
        var _cur_page = 1;
        var sql = "";
        var options = document.getElementById('HStatus').children;
        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;
        }
        function f_alert(sMsg) {
            layer.alert(sMsg, { icon: 5 });
            //layer.open({
            //    type: 1
            //  , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
            //  , id: 'layerDemo' //防止重复弹出
            //  , content: '<div style="padding: 20px 100px;">' + sMsg + '</div>'
            //  , shade: 0 //不显示遮罩
            //  , yes: function () {
            //      layer.closeAll();
            //  }
            //});
        }
        var params = getUrlVars();
        var type = params[params[0]];
        switch (type) {
            case "UnPrint":
                options[1].selected = true;
                sql += " and 状态 like ^^%未打印%^^";
                break;
            case "UnArrival":
                options[2].selected = true;
                sql += " and 状态 like ^^%未到货%^^";
                break;
            case "ReArrival":
                options[3].selected = true;
                sql += " and 状态 like ^^%已到货%^^";
                break;
            case "UnBarCode":
                options[4].selected = true;
                sql += " and 状态 like ^^%未生成条码%^^";
                break;
        }
        //CreateReport("Report");  //打印
        //Report.LoadFromURL("送货单(A4纸).grf");//打印
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'code', 'table', 'element', 'layer'], function () {
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , laydate = layui.laydate
                , table = layui.table
                , form = layui.form
                , element = layui.element;
            //常规用法
            laydate.render({
                elem: '#HDate1'
            });
            laydate.render({
                elem: '#HDate2'
            });
            var option = [];
            var HModName = "SRM_POInStockBillList";
            //不需要显示的字段 可扩展
            var titleData = ["HItemID", "HParentID", "hmainid","hsubid","F_xbkf_Combo","FSHDD","HPrintId"];
            //#region 进入页面既加载
            set_ClearBill();
            //#region 此页面所有方法
            function set_ClearBill() {
                //初始化表格
                set_InitGrid();
                //显示列数据
                DisPlay_HideColumn();
                //直接执行列表筛选 加载数据到网格
                get_FastQuery(table, option)
            }
            function set_InitGrid() {
                var columns = [
                    { checkbox: true, fixed: 'left', totalRowText: '合计'/*, fixed: true*/ }
                    , { field: 'sorderid', title: '序号', width: 80/*, fixed: true*/ }
                    , { field: 'hmainid', title: 'hmainid', sort: true/*, fixed: true*/, hide: true }
                    , { field: 'hsubid', title: 'hsubid', sort: true/*, fixed: true*/, hide: true }
                    , { field: '状态', title: '状态', width: 100, sort: true/*, fixed: true*/ }
                    , { field: '单据状态', title: '单据状态', sort: true/*, fixed: true*/ }
                    , { field: '单据号', title: '单据号', width: 135, sort: true/*, fixed: true*/ }
                    , { field: '送货单号', title: '送货单号', width: 135, sort: true/*, fixed: true*/ }
                    , { field: 'F_xbkf_Combo', title: '自定义标识', width: 135 }
                    , { field: '源单单号', title: '源单单号', width: 135 }
                    , { field: '包装标识', title: '包装标识', width: 135 }
                    //, { field: '物流单号', title: '物流单号', width: 150, sort: true/*, fixed: true*/ }
                    , { field: '物料编码', title: '物料编码', width: 120, sort: true }
                    , { field: '旧物料编码', title: '旧物料编码', width: 120, sort: true }
                    , { field: '物料代码', title: '物料代码', width: 120, sort: true }
                    , { field: '物料名称', title: '物料名称', width: 120, sort: true }
                    , { field: '规格型号', title: '规格型号', width: 120, sort: true }
                    , { field: '计量单位', title: '计量单位', width: 80, sort: true }
                    , { field: '数量', title: '订货数量', width: 100, sort: true, totalRow: true  }
                    , { field: '未生成条码数量', title: '未生成条码数量', width: 100, sort: true, totalRow: true  }
                    , { field: '合格数量', title: '合格数量', width: 100, sort: true, totalRow: true  }
                    , { field: '不合格数量', title: '不合格数量', width: 100, sort: true, totalRow: true  }
                    , { field: '含税单价', title: '含税单价', width: 100, sort: true, hide: true }
                    , { field: '金额', title: '金额', width: 100, sort: true, hide: true }
                    , { field: '日期', title: '日期', width: 150, sort: true }
                    , { field: '批次', title: '批次', width: 150, sort: true }
                    , { field: '生产日期', title: '生产日期', width: 150, sort: true, hide: true }
                    , { field: '预计到货日期', title: '预计到货日期', width: 150, sort: true, hide: true }
                    , { field: '源单主内码', title: '源单主ID', width: 100, hide: true }
                    , { field: '源单子内码', title: '源单子ID', width: 100, hide: true }
                    , { field: 'FSHDD', title: '送货地点', width: 120 }
                    , { field: '源单类型', title: '源单类型', width: 80, hide: true }
                    , { field: '采购订单号', title: '采购订单号', width: 180, sort: true, hide: true }
                    , { field: '委外订单号', title: '委外订单号', width: 180, sort: true, hide: true }
                    , { field: '变更状态', title: '变更状态', sort: true }
                    , { field: '收料组织', title: '收料组织', sort: true, hide: true }
                    , { field: '采购组织', title: '采购组织', sort: true, hide: true }
                    , { field: '需求组织', title: '需求组织', sort: true, hide: true }
                ];
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: true
                    //, cellMinWidth: 120
                    , totalRow: true
                    , limit: 500
                    , height: 'full-50'
                    , cols: [columns]
                    , limits: [500, 5000, 20000]
                    , done: function (res, curr, count) {
 
                    }
                };
            }
            //隐藏列设置
            function get_HideColumn() {
                var colName = "";
                for (var i = 1; i < option.cols[0].length - 1; i++) {
                    colName += option.cols[0][i]["title"] + ",";
                }
 
                colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: "隐藏列设置"  //标题
                    , closeBtn: 1  //窗体右上角关闭 的 样式
                    , shift: 2 //弹出动画
                    , area: ["50%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: ['../基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName, "yes"]
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //刷新表格数据
                        DisPlay_HideColumn();
                        //更新表格缓存的数据
                        layer.close(index);//关闭弹窗
                    }
                })
            }
            //显示列数据
            function DisPlay_HideColumn() {
                $.ajax({
                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                    type: "GET",
                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                    success: function (data1) {
                        if (data1.data.length != 0) {
                            var dataCol = [];//数据库查询出的列数据
                            var titleData = ["HItemID", "HParentID", "hmainid", "hsubid", "F_xbkf_Combo", "FSHDD", "HPrintId"];//不需要显示的字段 可扩展
 
                            dataCol = data1.data[0].HGridString.split(',');
 
                            for (var i = 0; i < dataCol.length; 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;
                                }
                            }
 
                            //取消冻结列
                            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 });
                    }
                })
            }
            ///加载显示数据
            function get_Display(sqlWhere) {
                var wait = layer.load();//遮罩
                //$.ajax({
                //    type: "POST",
                //    url: GetWEBURL() + "GetPOInStockBill",
                //    async: false,
                //    data: { "HSupNo": sessionStorage["HUserName"], "sqlWhere": sqlWhere },
                //    success: function (result) {
                //        if (result.Message == "获取成功") {
                //            option.data = result.data;
                //            table.render(option);
                //            layer.close(wait);
                //        } else {
                //            layer.close(wait);
                //            layer.alert(result.Message, { icon: 5 });
                //        }
                //    },
                //    error: function (result) {
                //        layer.close(wait);
                //        layer.alert(result.Message, { icon: 5 });
                //    }
                //});
 
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "GetPOInStockBill",
                    async: true,
                    data: { "HSupNo": sessionStorage["HUserName"], "sqlWhere": sqlWhere },
                    success: function (data1) {
                        if (data1.Message == "获取成功") {
                            var data = [];
                            var col = [];
                            //给空的数组赋值
                            for (var key in data1.list) {
                                data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
                            }
                            //在列表左边添加勾选框
                            col.push({ type: 'checkbox', fixed: 'left', totalRowText: '合计' });
                            for (var i = 0; i < data.length; i++) {
                                // if (data[i].name == 'HInterID' || data[i].name == 'HBillType' || data[i].name == 'hmainid') {
                                if ($.inArray(data[i].name, titleData) > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true }); //隐藏id列
                                }
                                else if (data[i].name.indexOf('id') > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true }); //id列
                                }
                                else {
                                    switch (data[i].Type) {
                                        //int
                                        case 'DateTime':
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, templet: "<div>{{d." + data[i].name + " ==null ?'':layui.util.toDateString(d." + data[i].name + ", 'yyyy-MM-dd')}}</div>", width: 200 });
                                            break;
                                        default:
                                            if (data[i].name == '订单数量' || data[i].name == '已发货数量' || data[i].name == '未发货数量') {
                                                col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 200, totalRow: true });
                                            } else if (data[i].name == '回复交期') {
                                                col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 200, event: 'HSupSendGoodsDateRemark' });
                                            } else {
                                                col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 200 });
                                            }
                                    }
                                }
                            }
                            //动态显示列名
                            option = {
                                elem: '#mainTable'
                                , toolbar: '#toolbarDemo'
                                , cols: [col]
                                , data: data1.data
                                , height: 'full-80'
                                , totalRow: true
                                , page: true
                                , cellMinWidth: 90
                                , limit: 500
                                , limits: [50, 500, 5000, 20000]
                            }
                            table.render(option);
                            //刷新表格数据
                            DisPlay_HideColumn();
                            layer.close(wait);
                        } else {
                            layer.close(wait);
                            layer.alert(data1.Message, { icon: 5 });
                        }
                    },
                    error: function (result) {
                        layer.close(wait);
                        layer.alert(result.Message, { icon: 5 });
                    }
                });
            };
            //查询按钮
            form.on('submit(btnSearch)', function (data) {//查询
                get_FastQuery(table, option);
            });
            //查询条件
            function get_FastQuery(table, option) {
                var sqlWhere = "";
                if ($("#HStatus").val() != "")
                    if ($("#HStatus").val() == "未生成条码") {
                        sqlWhere += " and 未生成条码数量 > 0";
                    }
                    else {
                        sqlWhere += " and 状态 like ^^%" + $("#HStatus").val() + "%^^";
                    }
 
                if ($("#HBillNo").val() != "")
                    sqlWhere += " and 单据号 like ^^%" + $("#HBillNo").val() + "%^^";
                if ($("#HBillNoFrom").val() != "")
                    sqlWhere += " and 源单单号 like ^^%" + $("#HBillNoFrom").val() + "%^^";
                if ($("#HInnerBillNo").val() != "")
                    sqlWhere += " and 送货单号 like ^^%" + $("#HInnerBillNo").val() + "%^^";
                if ($("#HOldMaterNumber").val() != "")
                    sqlWhere += " and 旧物料编码 like ^^%" + $("#HOldMaterNumber").val() + "%^^";
                if ($("#HSupName").val() != "")
                    sqlWhere += " and 供应商 like ^^%" + $("#HSupName").val() + "%^^";
                if ($("#HMaterNumber").val() != "")
                    sqlWhere += " and 物料编码 like ^^%" + $("#HMaterNumber").val() + "%^^";
                if ($("#HNumber").val() != "")
                    sqlWhere += " and 物料代码 like ^^%" + $("#HNumber").val() + "%^^";
                if ($("#HName").val() != "")
                    sqlWhere += " and 物料名称 like ^^%" + $("#HName").val() + "%^^";
                if ($("#HModel").val() != "")
                    sqlWhere += " and 规格型号 like ^^%" + $("#HModel").val() + "%^^";
                if ($("#HClStatus").val() != "")
                    sqlWhere += " and 单据状态 like ^^%" + $("#HClStatus").val() + "%^^";
                if ($("#HDate1").val() != "") {
                    sqlWhere += " and 日期 >= ^^" + $("#HDate1").val() + "^^";
                }
                if ($("#HDate2").val() != "") {
                    sqlWhere += " and 日期 <= ^^" + $("#HDate2").val() + "^^";
                }
                sql = sqlWhere;
                _cur_page = 1;
                get_Display(sqlWhere);
            }
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'btn-getCheckData':
                        var data = checkStatus.data;
                        layer.alert(JSON.stringify(data));
                        break;
                    //case 'getCheckLength':
                    //    var data = checkStatus.data;
                    //    layer.msg('选中了:' + data.length + ' 个');
                    //    break;
                    //case 'isAll':
                    //    layer.msg(checkStatus.isAll ? '全选' : '未全选');
                    //    break;
                    //审核
                    case 'btn-Audit':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        var InterID = "";
                        if (checkStatus.data.length > 0) {
                            for (var i = 0; i < checkStatus.data.length; i++) {
                                InterID += data[i].hmainid.toString() + ",";
                            }
                            InterID = InterID.substring(0, InterID.length - 1);
 
                            var HBillNo = data[0].单据号;
                            //逻辑审核方法
                            $.ajax({
                                type: "GET",
                                url: GetWEBURL() + "/AuditPOInStockBill",
                                data: { "HInterID": InterID, "CurUserName": sessionStorage["HUserName"], "HBillNo": HBillNo },
                                success: function (result) {
                                    if (result.count == 1) {
                                        layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                            // 得到frame索引
                                            var index = layer.getFrameIndex(window.name);
                                            //关闭当前frame
                                            layer.close(index);
                                            //修改为功后刷新界面
                                            get_Display(sql);
                                        });
 
                                    } else {
                                        layer.alert(result.Message, { icon: 5 });
                                    }
                                }, error: function () {
                                    layer.alert("接口请求失败!", { icon: 5 });
                                }
                            });
                        }
                        else {
                            layer.msg('请选择数据!');
                        }
                    //自定义头工具栏右侧图标 - 提示
                    case 'btn-reload':
                        _cur_page = $(".layui-laypage-em").next().html();
                        get_Display(sql);
                        //    });
                        break;
                    case 'btn-HideColumn':
                        get_HideColumn();
                        break;
                    case 'btn-details':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
 
                        var linterid = data[0].hmainid.toString();
                        //if (AllowLoadData(sSubStr) != false) {//非空验证
                        layer.open({
                            type: 2
                            , area: ['100%', '100%']
                            , title: '送货单'
                            , shade: 0.6 //遮罩透明度
                            , maxmin: true //允许全屏最小化
                            , anim: 0 //0-6的动画形式,-1不开启
                            , content: '../../../src/views/SRM/SRM_POInStockBill.html?linterid=' + linterid
                            , resize: false
                            , cancel: function () {
                                //$(".layui-btn").removeClass("layui-btn-disabled");
                            }
                        })
                        break;
                    case 'btn-changebg':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
 
                        var linterid = data[0].hmainid.toString();
                        //if (AllowLoadData(sSubStr) != false) {//非空验证
                        layer.open({
                            type: 2
                            , area: ['100%', '100%']
                            , title: '送货单'
                            , shade: 0.6 //遮罩透明度
                            , maxmin: true //允许全屏最小化
                            , anim: 0 //0-6的动画形式,-1不开启
                            , content: '../../../src/views/SRM/SRM_POInStockBill.html?linterid=' + linterid + '&type =changebg'
                            , resize: false
                            , cancel: function () {
                                //$(".layui-btn").removeClass("layui-btn-disabled");
                            }
                        })
                        break;
                    case 'btn-Delete':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        var InterID = "";
                        for (i = 0; i < data.length; i++) {
                            InterID += data[i].hmainid.toString() + ",";
                        }
                        InterID = InterID.substring(0, InterID.length - 1)
                        //逻辑删除方法
                        layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                            $.ajax({
                                type: "GET",
                                url: GetWEBURL() + "/DeltetPOInStockBill", //方法所在页面和方法名
                                data: { "HInterID": InterID, "HUserName": sessionStorage["HUserName"] },
                                success: function (result) {
                                    if (result.count == 1) {
                                        layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                            // 得到frame索引
                                            var index = layer.getFrameIndex(window.name);
                                            //关闭当前frame
                                            layer.close(index);
                                            //修改为功后刷新界面
                                            window.location.reload();
                                        });
 
                                    } else {
                                        layer.alert(result.Message, { icon: 5 });
                                    }
                                }, error: function () {
                                    layer.alert("接口请求失败!", { icon: 5 });
                                }
                            });
                        })
                        break;
                    case 'btn-print':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (data.length != 1) {
                            layer.msg("请选择一条数据", { icon: 5 });
                            return;
                        }
                        if (data[0].单据状态 != '已审核') {
                            layer.msg("请审核送货单后在进行打印( ´◔︎ ‸◔︎`)", { icon: 5 });
                            return;
                        }
                        //for (var i = 0; i < data.length; i++) {
                        //    if (data[i].单据状态 != "审核") {
                        //        layer.msg("选中行未审核", { icon: 5 });
                        //        return;
                        //    }
                        //}
                        layer.open({
                            type: 2
                            , area: ['80%', '80%']
                            , title: '打印模版选择'
                            , shade: 0.6 //遮罩透明度
                            , maxmin: false //允许全屏最小化
                            , anim: 0 //0-6的动画形式,-1不开启
                            , content: ['../../views/BaseSet/SRM_OpenTmpList.html?linterid=' + data[0].hmainid.toString() + '&MyMsg=' + data[0].hmainid.toString() + '&Type=SRM_POInStockBillList', 'yes']
                            , resize: false
                            //, cancel: function () {
                            //    $(".layui-btn").removeClass("layui-btn-disabled");
                            //}
                        })
 
                        break;
                    case 'btn-print-Convenient':
                        convenientPrint();
                        break;
                    case 'btn-generate':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (data[0].未生成条码数量 <= 0) {
                            layer.msg("选中行已生成条码!", { icon: 5 });
                        }
                        else {
                            layer.open({
                                type: 2
                                , area: ['100%', '100%']
                                , title: '条码生成'
                                , shade: 0.6 //遮罩透明度
                                , maxmin: false //允许全屏最小化
                                , anim: 0 //0-6的动画形式,-1不开启
                                , content: ['../../views/SRM/SRM_BarCodeBill.html?linterid=' + data[0].hmainid + '&lentryid=' + data[0].hsubid, 'yes']
                                , resize: false
                                , cancel: function () {
                                    $(".layui-btn").removeClass("layui-btn-disabled");
                                }
                            })
                        }
                        break;
                    case 'btn-exit':
                        //var index = parent.layer.getFrameIndex(window.name);
                        //element.tabDelete('layadmin-layout-tabs', this);
                        parent.layui.admin.events.closeThisTabs();
                        //parent.layer.close(index);
                        break;
                };
            });
 
            //行监听事件
            table.on('row(mainTable)', function (obj) {
                var flag = !obj.tr.find(':checkbox:first').prop('checked');
                obj.tr.find(':checkbox').prop('checked', flag);
                if (flag) {
                    obj.tr.find('.layui-form-checkbox').addClass('layui-form-checked');  //设置复选框选中样式
                    $(obj.tr.selector).attr({ "style": "background:#ceedfa;color:black" });//改变当前tr背景颜色和字体颜色
                } else {
                    obj.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//取消复选框选中样式
                    $(obj.tr.selector).attr({ "style": "background:" });//取消当前tr颜色
                }
                //mainTable 为表格ID   注意此处如果ID不正确将导致你在监听复选框时获取不到你选择的数据,前面的只是添加或删除选中未选中样式以及设置背景色,字体颜色
                layui.each(table.cache.mainTable, function (i, l) {
                    if (obj.tr.index() == l.LAY_TABLE_INDEX) {
                        l.LAY_CHECKED = flag;
                    }
                });
            });
 
            //一键打印
            function convenientPrint() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (data.length != 1) {
                    layer.msg("请选择一条数据", { icon: 5 });
                    return;
                }
                if (data[0].单据状态 != '已审核') {
                    layer.msg("请审核送货单后在进行打印( ´◔︎ ‸◔︎`)", { icon: 5 });
                    return;
                }
 
                $.ajax({
                    type: "get",
                    url: GetWEBURL() + "/Open_PrintTem/GetDefaultOpenTmp_Json",
                    async: true,
                    data: { "HNumber": 'SRM_POInStockBillList' },
                    //data: { "Value": Value },
                    success: function (result) {
                        if (result.count == 1) {
                            var OpenTmp = result.data[0].模板名称
                            window.open("../../views/SRM/HBarPlanPrint.html?linterid=" + data[0].hmainid.toString() + "&Type=SRM_POInStockBillList" + "&OpenTmp=" + OpenTmp.toString());
                        } else {
                            layer.msg(result.Message);
                        }
                    },
                    error: function (result) {
                        console.log(result);
                    }
                });
            }
 
        });
    </script>
</body>
</html>