yangle
15 小时以前 76824fbc74817dc6a87cef54c2ab18705490356e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>销售出库明细报表</title>
    <meta name="renderer" content="webkit" charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/HideButton.js"></script>
    <script src="../../../layuiadmin/xlsx.full.min.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <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-row">
                                    <div class="layui-colla-title layui-inline">
                                        <div class="layui-inline">
                                            <span>更多</span>
                                        </div>
                                    </div>
                                    <div class="layui-form layui-inline" style="width:200px;">
                                        <label class="layui-form-label" style="width:35px;">日期</label>
                                        <div class="layui-input-block" style="position:relative; left:-45px;">
                                            <input type="text" class="layui-input" id="HBeginDate" placeholder="yyyy-MM-dd HH:mm:ss" style="width:140px;">
                                        </div>
                                    </div>
                                    <div class="layui-inline" style="width:200px;">
                                        <label class="layui-form-label" style="width:5px;">-</label>
                                        <div class="layui-input-block" style="position:relative; left:-70px;">
                                            <input type="text" class="layui-input" id="HEndDate" placeholder="yyyy-MM-dd HH:mm:ss" style="width:140px;">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 85px;">客户</label>
                                        <div class="layui-input-block" style="margin-left: 120px;">
                                            <input type="text" class="layui-input" name="HCusName" id="HCusName">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 85px;">业务员</label>
                                        <div class="layui-input-block" style="margin-left: 120px;">
                                            <input type="text" class="layui-input" name="HEmpName" id="HEmpName">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">产品类型</label>
                                        <div class="layui-input-inline">
                                            <select name="HProductType" id="HProductType" lay-filter="HProductType" style="width: 180px; ">
                                                <option style="color:blue;" value="全部">全部</option>
                                                <option style="color:blue;" value="非样品">非样品</option>
                                                <option style="color:blue;" value="样品">样品</option>
                                            </select>
                                        </div>
                                    </div>
                                    <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                    </button>
                                    <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">重置</button>
                                    <div class="layui-row" style="position:relative; left:30px;">
                                        <div class="layui-inline" style="width:450px;">
                                            <label class="layui-form-label" style="width: 85px;">件数总合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HPieceQtyTotalSum" id="HPieceQtyTotalSum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>件</span>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">米数总合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HQtyTotalSum" id="HQtyTotalSum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>米</span>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">金额总合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMoneyTotalSum" id="HMoneyTotalSum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">重量总合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HWeightTotalSum" id="HWeightTotalSum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>吨</span>
                                    </div>
                                    <div class="layui-row" style="position:relative; left:30px;">
                                        <div class="layui-inline" style="width:450px;">
                                            <label class="layui-form-label" style="width: 85px;">涤纶件数合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HPieceQtySum" id="HPieceQtySum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>件</span>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">涤纶米数合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HQtySum" id="HQtySum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>米</span>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">涤纶金额合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMoneySum" id="HMoneySum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">涤纶重量合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HWeightSum" id="HWeightSum" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>吨</span>
                                    </div>
                                    <div class="layui-row" style="position:relative; left:30px;">
                                        <div class="layui-inline" style="width:450px;">
                                            <label class="layui-form-label" style="width: 85px;">羊毛件数合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HPieceQtySum_YM" id="HPieceQtySum_YM" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>件</span>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">羊毛米数合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HQtySum_YM" id="HQtySum_YM" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>米</span>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">羊毛金额合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMoneySum_YM" id="HMoneySum_YM" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">羊毛重量合计</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HWeightSum_YM" id="HWeightSum_YM" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <span>吨</span>
                                    </div>
                                    <div class="layui-colla-content" style="padding: 0px; margin-left: 6%;">
                                        <div class="layui-row" style="margin-top:5px">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">过滤</label>
                                                <div class="layui-input-block">
                                                    <select name="ColName" id="ColName" lay-filter="ColName" style="width:190px;">
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <select name="Comparator" id="Comparator" lay-filter="Comparator" style="width:190px;">
                                                    <option value="0" selected="selected"></option>
                                                    <option value="=">=</option>
                                                    <option value=">=">>=</option>
                                                    <option value=">">></option>
                                                    <option value="<="><=</option>
                                                    <option value="<"><</option>
                                                    <option value="<>"><></option>
                                                    <option value="7">包含</option>
                                                    <option value="8">左包含</option>
                                                    <option value="9">右包含</option>
                                                    <option value="10">不包含</option>
                                                </select>
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" class="layui-input" value="" name="ColContent" id="ColContent">
                                            </div>
                                        </div>
                                        <div class="layui-row" style=" margin-top: 10px; margin-left: 70px;">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">过滤</label>
                                                <div class="layui-input-block">
                                                    <select name="ColName1" id="ColName1" class="ForFilteringSchemes" lay-filter="ColName1" style="width:190px;">
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <select name="Comparator1" id="Comparator1" class="ForFilteringSchemes" lay-filter="Comparator1" style="width:190px;">
                                                    <option value="0" selected="selected"></option>
                                                    <option value="=">=</option>
                                                    <option value=">=">>=</option>
                                                    <option value=">">></option>
                                                    <option value="<="><=</option>
                                                    <option value="<"><</option>
                                                    <option value="<>"><></option>
                                                    <option value="7">包含</option>
                                                    <option value="8">左包含</option>
                                                    <option value="9">右包含</option>
                                                    <option value="10">不包含</option>
                                                </select>
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" class="layui-input ForFilteringSchemes" value="" name="ColContent1" id="ColContent1">
                                            </div>
                                        </div>
 
                                        <div class="layui-row" style=" margin-top: 10px; margin-left: 70px;">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">过滤</label>
                                                <div class="layui-input-block">
                                                    <select name="ColName2" id="ColName2" class="ForFilteringSchemes" lay-filter="ColName2" style="width:190px;">
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <select name="Comparator2" id="Comparator2" class="ForFilteringSchemes" lay-filter="Comparator2" style="width:190px;">
                                                    <option value="0" selected="selected"></option>
                                                    <option value="=">=</option>
                                                    <option value=">=">>=</option>
                                                    <option value=">">></option>
                                                    <option value="<="><=</option>
                                                    <option value="<"><</option>
                                                    <option value="<>"><></option>
                                                    <option value="7">包含</option>
                                                    <option value="8">左包含</option>
                                                    <option value="9">右包含</option>
                                                    <option value="10">不包含</option>
                                                </select>
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" class="layui-input ForFilteringSchemes" value="" name="ColContent2" id="ColContent2">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <table class="" id="mainTable" lay-filter="mainTable"></table>
                        <table class="" id="mainTable1" lay-filter="mainTable1"></table>
                        <script type="text/html" id="toolbarDemo">
                            <div class="layui-btn-container">
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Refresh" id="get_Refresh"><i class="layui-icon layui-icon-refresh-3"></i>刷新</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Exit" id="get_Exit"><i class="layui-icon layui-icon-logout"></i>退出</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_export_normal" id="get_export_normal"><i class="layui-icon layui-icon-export"></i>导出(常规)</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_export" id="get_export"><i class="layui-icon layui-icon-export"></i>导出(特殊)</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn" id="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="HideButton" id="HideButton"><i class="layui-icon layui-icon-form"></i>按钮设置</button>
                            </div>
                        </script>
                        <script type="text/html" id="toolbarDemo1">
                            <div class="layui-btn-container">
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_export_normal" id="get_export_normal"><i class="layui-icon layui-icon-export"></i>导出(常规)</button>
                            </div>
                        </script>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
            //#region 公用变量
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , element = layui.element
                , laypage = layui.laypage
                , laydate = layui.laydate
                , excel = layui.excel;
            var option = {};
            var option1 = {};
            var sWhere = "";
            var HModName = "Kf_SellOutEntryReport";
            //不需要显示的字段 可扩展
            var titleData = ["日期", "HCusID", "HMaterID", "HEmpID", "hmainid", "hsubid"];
 
            //导出功能获取数据
            var option_Bak = {};
            var option1_Bak = {};
            var sWhere_Bak = "";
 
 
            var ins1;
            var ins2;
            //#endregion
 
            //#region 进入页面即加载
 
            //初始化界面
            set_ClearBill();
 
            //#endregion
 
            //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region 头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                switch (obj.event) {
                    //刷新
                    case 'get_Refresh': get_Refresh();
                        break;
                    //退出按钮
                    case 'get_Exit': Pub_Close(2);
                        break;
                    //导出excel
                    case 'get_export':
                        get_Export();
                        break;
                    //导出excel
                    case 'get_export_normal':
                        get_Export_Normal();
                        break;
                    //列设置
                    case 'set_HideColumn': get_HideColumn();
                        break;
                    //按钮设置
                    case 'HideButton':
                        var btns = document.getElementsByTagName("button");     //获取本页所有按钮对象
                        var HBillType = "Kf_SellOutEntryReport";
                        get_HideButton(btns, HBillType, HModName, sessionStorage["HUserName"]);
                        break;
                };
            });
            //#endregion
 
            //#region 头工具栏事件
            table.on('toolbar(mainTable1)', function (obj) {
                switch (obj.event) {
                    //导出excel
                    case 'get_export_normal':
                        get_Export1_Normal();
                        break;
                };
            });
            //#endregion
 
            //#region 点击行选中高亮
            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;
                    }
                });
            })
            //#endregion
 
            //#region 重置按钮
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
            });
            //#endregion
 
            //#region 查询按钮
            form.on('submit(btnSearch)', function (data) {
                get_FastQuery(2);
            });
            //#endregion
 
            //#endregion
 
            //#region 本页面所有被调用的方法
 
            //#region 初始化界面
            function set_ClearBill() {
                //初始化时间
                var HBeginDate = Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 1).setHours(7, 0, 0, 0), "yyyy-MM-dd hh");
                var HEndDate = Format(new Date(new Date()).setHours(7, 0, 0, 0), "yyyy-MM-dd hh");
                laydate.render({
                    elem: '#HBeginDate',
                    type: 'datetime',
                    fullPanel: true
                    , format: 'yyyy-MM-dd HH'
                    , value: HBeginDate
                });
                laydate.render({
                    elem: '#HEndDate',
                    type: 'datetime',
                    fullPanel: true
                    , format: 'yyyy-MM-dd HH'
                    , value: HEndDate
                });
 
                //初始化表格
                set_InitGrid();
                //查询
                get_FastQuery(1);
 
                DisPlay_HideColumn();
 
            }
            //#endregion
 
            //#region 初始化表格方法
            function set_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , height: 'full-50'
                    , page: true
                    , totalRow: true
                    //, cellMinWidth: 90
                    , limit: 50
                    , limits: [50, 500, 5000, 20000]
                };
 
                option1 = {
                    elem: '#mainTable1'
                    , toolbar: '#toolbarDemo1'
                    , height: 'full-50'
                    , page: true
                    , totalRow: true
                    //, cellMinWidth: 90
                    , limit: 50
                    , limits: [50, 500, 5000, 20000]
                };
 
                option_Bak = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , height: 'full-50'
                    , page: true
                    , totalRow: true
                    //, cellMinWidth: 90
                    , limit: 50
                    , limits: [50, 500, 5000, 20000]
                };
 
                option1_Bak = {
                    elem: '#mainTable1'
                    //, toolbar: '#toolbarDemo'
                    , height: 'full-50'
                    , page: true
                    , totalRow: true
                    //, cellMinWidth: 90
                    , limit: 50
                    , limits: [50, 500, 5000, 20000]
                };
            }
            //#endregion
            //#endregion
 
            //#region 查询
            function get_Display(sWhere) {
                var ajaxLoad = layer.load();
                $.ajax({
                    url: GetWEBURL() + '/Kf_SellOutEntryReport/list',
                    type: "GET",
                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"], "userid": sessionStorage["Czybm"]},
                    success: function (data1) {
                        if (data1.count == 1) {
                            var totalArray = ["件数", "米数","金额","重量_吨"];
                            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' });
                            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 ($.inArray(data[i].name, totalArray) > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, totalRow: true, width: 120,templet: "<div>{{d." + data[i].name + " ==null ?'':fixed(d." + data[i].name + ")}}</div>" });
                                }
                                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:120 });
                                            break;
                                        default:
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 120 });
                                    }
                                }
                            }
 
                            //设置表1数据
                            option.cols = [col];
                            option.data = data1.data[0];
 
                            //获取表2数据
                            option1.cols = [col];
                            option1.data = data1.data[1];
 
                            //设置表1:列表同一个单据只有第一条数据显示主表信息,其它记录只显示子表信息;合计数据
                            //设置数据:声明计算合计的变量
                            var HPieceQtyTotalSum = 0;
                            var HQtyTotalSum = 0;
                            var HMoneyTotalSum = 0;
                            var HWeightTotalSum = 0;
                            var HPieceQtySum = 0;
                            var HQtySum = 0;
                            var HMoneySum = 0;
                            var HWeightSum = 0;
                            var HPieceQtySum_YM = 0;
                            var HQtySum_YM= 0;
                            var HMoneySum_YM = 0;
                            var HWeightSum_YM = 0;
                            //获取子表列数据
                            var colList = [];
                            for (var i = 0; i < option.cols[0].length; i++) {
                                colList.push(option.cols[0][i].field);
                            }
                            //设置数据
                            var result = data1.data[0];
                            var temp = "";
                            for (var i = 0; i < result.length; i++) {
                                //计算表1的合计数据
                                HPieceQtySum += result[i]["件数"] * 1;
                                HQtySum += result[i]["米数"] * 1;
                                HMoneySum += result[i]["金额"] * 1;
                                HWeightSum += result[i]["重量_吨"] * 1;
 
                                //设置只显示单据的第一行主表信息,其他行只显示子表信息
                                if (temp != result[i]["hmainid"]) {
                                    temp = result[i]["hmainid"];
                                } else {
                                    var initIndex = $.inArray("hmainid", colList);
                                    var lastIndex = $.inArray("hsubid", colList);
                                    for (var j = initIndex + 1; j < lastIndex; j++) {
                                        var fieldName = colList[j];
                                        result[i][fieldName] = "";
                                    }
                                }
                            }
 
                            //设置表1:列表同一个单据只有第一条数据显示主表信息,其它记录只显示子表信息
                            //获取子表列数据
                            var colList1 = [];
                            for (var i = 0; i < option1.cols[0].length; i++) {
                                colList1.push(option1.cols[0][i].field);
                            }
                            //设置数据
                            var result1 = data1.data[1];
                            var temp1 = "";
                            for (var i = 0; i < result1.length; i++) {
                                //计算表2的合计数据
                                HPieceQtySum_YM += result1[i]["件数"] * 1;
                                HQtySum_YM += result1[i]["米数"] * 1;
                                HMoneySum_YM += result1[i]["金额"] * 1;
                                HWeightSum_YM += result1[i]["重量_吨"] * 1;
 
                                //设置只显示单据的第一行主表信息,其他行只显示子表信息
                                if (temp1 != result1[i]["hmainid"]) {
                                    temp1 = result1[i]["hmainid"];
                                } else {
                                    var initIndex = $.inArray("hmainid", colList1);
                                    var lastIndex = $.inArray("hsubid", colList1);
                                    for (var j = initIndex + 1; j < lastIndex; j++) {
                                        var fieldName = colList1[j];
                                        result1[i][fieldName] = "";
                                    }
                                }
                            }
 
                            //设置表1、表2处理后的数据
                            option.data = result;
                            option1.data = result1;
 
                            //渲染表1、表2
                            ins1 = table.render(option);
                            ins2 = table.render(option1);
                            DisPlay_HideColumn();
 
                            HPieceQtyTotalSum = HPieceQtySum + HPieceQtySum_YM;
                            HQtyTotalSum = HQtySum + HQtySum_YM;
                            HMoneyTotalSum = HMoneySum + HMoneySum_YM;
                            HWeightTotalSum = (HWeightSum.toFixed(2) * 1) + (HWeightSum_YM.toFixed(2) * 1);
 
                            $("#HPieceQtySum").val(fixed(HPieceQtySum*1));
                            $("#HQtySum").val(fixed(HQtySum.toFixed(6)*1));
                            $("#HMoneySum").val(fixed(HMoneySum.toFixed(6) * 1));
                            $("#HWeightSum").val(fixed(HWeightSum.toFixed(2) * 1));
                            $("#HPieceQtySum_YM").val(fixed(HPieceQtySum_YM*1));
                            $("#HQtySum_YM").val(fixed(HQtySum_YM.toFixed(6)*1));
                            $("#HMoneySum_YM").val(fixed(HMoneySum_YM.toFixed(6) * 1));
                            $("#HWeightSum_YM").val(fixed(HWeightSum_YM.toFixed(2) * 1));
                            $("#HPieceQtyTotalSum").val(fixed(HPieceQtyTotalSum*1));
                            $("#HQtyTotalSum").val(fixed(HQtyTotalSum.toFixed(6)*1));
                            $("#HMoneyTotalSum").val(fixed(HMoneyTotalSum.toFixed(6) * 1));
                            $("#HWeightTotalSum").val(fixed(HWeightTotalSum.toFixed(2) * 1));
 
 
 
                            //刷新按钮显示
                            var btns = document.getElementsByTagName("button");     //获取本页所有按钮对象
                            var HBillType = "Kf_SellOutEntryReport";
                            Display_HideButton(btns, HBillType, HModName, sessionStorage["HUserName"]);
 
                            //刷新表格数据
                            //DisPlay_HideColumn();
 
                            layer.close(ajaxLoad);
 
                            if ($("#Comparator").val() == 0 && $("#ColContent").val() == "") {
                                ColFilter();
                            }
 
                            //layer.alert("查询成功", { icon: 1 });
                        } else {
                            layer.close(ajaxLoad);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
 
            }
            //#endregion
 
            //#region 快速过滤
            function get_FastQuery(number) {
                var HDate = $("#HBeginDate").val();//开始日期
                var HDate1 = $("#HEndDate").val();//结束日期
                if (HDate == '') {
                    HDate = Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 1).setHours(7, 0, 0, 0), "yyyy-MM-dd hh") + ":00:00";//下达日期 开始日期
                } else {
                    HDate = $("#HBeginDate").val() + ":00:00";//下达日期 开始日期
                }
                if (HDate1 == '') {
                    HDate1 = Format(new Date(new Date()).setHours(7, 0, 0, 0), "yyyy-MM-dd hh") + ":00:00";//结束日期
                } else {
                    HDate1 = $("#HEndDate").val() + ":00:00";//结束日期
                }
 
                var HCusName = $("#HCusName").val();//客户名称
                var HEmpName = $("#HEmpName").val();//客户名称
 
                var HProductType = $("#HProductType").val();//产品类型
 
                //任意字段过滤
                var ColName = $("#ColName").val();//复选框
                var Comparator = $("#Comparator").val()
                var ColContent = $("#ColContent").val();
                var ColName1 = $("#ColName1").val();//复选框
                var Comparator1 = $("#Comparator1").val()
                var ColContent1 = $("#ColContent1").val();
                var ColName1 = $("#ColName2").val();//复选框
                var Comparator2 = $("#Comparator2").val()
                var ColContent2 = $("#ColContent2").val();
 
                if (ColName != 0 && Comparator != 0) {
                    var com = "";
                    switch (Comparator) {
                        case "7":
                            com = "like ''%" + ColContent + "%''";
                            break;
                        case "8":
                            com = "like ''%" + ColContent + "''";
                            break;
                        case "9":
                            com = "like ''" + ColContent + "%''";
                            break;
                        case "10":
                            com = "not like ''%" + ColContent + "%''";
                            break;
                        default:
                            com = "" + Comparator + "''" + ColContent + "''";
                            break;
                    }
                    sWhere += " and " + ColName + " " + com;
                }
                if (ColName1 != 0 && Comparator1 != 0) {
                    var com1 = "";
                    switch (Comparator1) {
                        case "7":
                            com1 = "like'%" + ColContent1 + "%'";
                            break;
                        case "8":
                            com1 = "like'%" + ColContent1 + "'";
                            break;
                        case "9":
                            com1 = "like'" + ColContent1 + "%'";
                            break;
                        case "10":
                            com1 = "not like'%" + ColContent1 + "%'";
                            break;
                        default:
                            com1 = "" + Comparator1 + "'" + ColContent1 + "'";
                            break;
                    }
                    sWhere += " and " + ColName1 + " " + com1;
                }
                if (ColName2 != 0 && Comparator2 != 0) {
                    var com2 = "";
                    switch (Comparator2) {
                        case "7":
                            com2 = "like'%" + ColContent2 + "%'";
                            break;
                        case "8":
                            com2 = "like'%" + ColContent2 + "'";
                            break;
                        case "9":
                            com2 = "like'" + ColContent2 + "%'";
                            break;
                        case "10":
                            com2 = "not like'%" + ColContent2 + "%'";
                            break;
                        default:
                            com2 = "" + Comparator + "'" + ColContent + "'";
                            break;
                    }
                    sWhere += " and " + ColName2 + " " + com2;
                }
                if (HDate) {
                    sWhere += " and CONVERT(varchar(100),日期, 120) >= ''" + HDate + "''";
                }
                if (HDate1) {
                    sWhere += " and CONVERT(varchar(100),日期, 120) <= ''" + HDate1 + "''";
                }
                if (HCusName) {
                    sWhere += " and 购货单位 like ''%" + HCusName + "%''";
                }
                if (HEmpName) {
                    sWhere += " and 业务员 like ''%" + HEmpName + "%''";
                }
 
                if (HProductType) {
                    if (HProductType=="样品") {
                        sWhere += " and 产品类型 = ''样品''";
                    } else if (HProductType == "非样品") {
                        sWhere += " and 产品类型 <> ''样品''";
                    } else if (HProductType == "全部") {
                        
                    }
                }
 
               /* sWhere += " and 组织内码 = " + sessionStorage["OrganizationID"];*/
 
                //根据用户过滤用户关联客户的记录
                sWhere += getSWhereByHUser();
 
                get_Display(sWhere);
 
                sWhere_Bak = sWhere;
 
                sWhere = "";//调用接口后清空sWhere缓存
            }
            //#endregion
 
            //#region 重置过滤条件方法
            function set_ClearQuery() {
                //初始化时间
                var HBeginDate = Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 1).setHours(8, 0, 0, 0), "yyyy-MM-dd hh");
                var HEndDate = Format(new Date(new Date()).setHours(8, 0, 0, 0), "yyyy-MM-dd hh");
                laydate.render({
                    elem: '#HBeginDate',
                    type: 'datetime',
                    fullPanel: true
                    , format: 'yyyy-MM-dd HH'
                    , value: HBeginDate
                });
                laydate.render({
                    elem: '#HEndDate',
                    type: 'datetime',
                    fullPanel: true
                    , format: 'yyyy-MM-dd HH'
                    , value: HEndDate
                });
                $("#HCusName").val("");
                $("#HEmpName").val("");
 
                $("#ColContent").val("");
                $("#ColName").val("0");
                $("#Comparator").val("0");
                $("#ColContent1").val("");
                $("#ColName1").val("0");
                $("#Comparator1").val("0");
                $("#ColContent2").val("");
                $("#ColName2").val("0");
                $("#Comparator2").val("0");
                form.render('select');
 
                sWhere = "";
            }
            //#endregion
 
            //#region 刷新
            function get_Refresh() {
                $("#btnSearch").trigger('click');
            }
            //#endregion
 
            //#region 导出Execel
            function get_Export() {
                var ModRightNameCheck = "Kf_SellOutEntryReport_ExportExcel";
 
                //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/LMES/getReportByModRightNameCheck", //方法所在页面和方法名
                    data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            exportAll();
                        } else {
                            layer.alert("当前模块没有导出权限!", { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
 
            //#region 常规导出Execel
            function get_Export_Normal() {
                var ModRightNameCheck = "Kf_SellOutEntryReport_ExportExcel";
 
               //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/LMES/getReportByModRightNameCheck", //方法所在页面和方法名
                    data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            table.exportFile(ins1.config.id, option.data, "xls");
                        } else {
                            layer.alert("当前模块没有导出权限!", { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
 
            //#region 常规导出Execel
            function get_Export1_Normal() {
                var ModRightNameCheck = "Kf_SellOutEntryReport_ExportExcel";
 
                //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/LMES/getReportByModRightNameCheck", //方法所在页面和方法名
                    data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            table.exportFile(ins2.config.id, option1.data, "xls");
                        } else {
                            layer.alert("当前模块没有导出权限!", { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
 
            //#region 隐藏列设置
            function get_HideColumn() {
                var colName = "";
                var contentUrl = "";
                for (var i = 1; i < option.cols[0].length; 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 显示列数据
            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 = ["单据ID", "HMouldID", "hsubid", "HManagerID", "源单主内码", "源单子内码"];//不需要显示的字段 可扩展
 
                            dataCol = data1.data[0].HGridString.split(',');
 
                            for (var i = 0; i < option.cols[0].length - 1; 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);
                            option1.cols[0] = option.cols[0];
                            table.render(option1);
                        } else {
                            table.render(option);
                            option1.cols[0] = option.cols[0];
                            table.render(option1);
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                })
            }
            //#endregion
 
            //#region 任意字段过滤:列名显示下拉框
            function ColFilter() {
                var Organization = '<option  value="0" selected="selected" ></option>';
                for (var i = 1; i < option.cols[0].length; i++) {
                    if (option.cols[0][i].hide != true) {
                        Organization += '<option  style="color:blue;" value="' + option.cols[0][i].field + '">' + option.cols[0][i].field + '</option>';
                    }
                }
                $("#ColName").empty();
                $("#ColName").append(Organization);
                $("#ColName1").empty();
                $("#ColName1").append(Organization);
                $("#ColName2").empty();
                $("#ColName2").append(Organization);
                form.render('select');
            }
            //#endregion
 
            //#region 根据用户获取用户关联客户的过滤条件
            function getSWhereByHUser() {
                var res = "";
                $.ajax({
                    type: "GET",
                    async: false,
                    url: GetWEBURL() + "/Xs_SeOrderBill/getCusIDListByUser", //方法所在页面和方法名
                    data: { "CurUserID": sessionStorage["Czybm"], "CurUserName": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            res = result.data;
                        } else {
                            res = result.data;
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function (err) {
                        res = " and 1 = 0";
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
 
                res = res.replaceAll("'", "''");
 
                return res;
            }
            //#endregion
 
            //#region 导出
            function oneTable(option) {
                var exportCols = ["购货单位", "产品名称", "件数", "米数", "单价", "税率%", "金额", "业务员"];
 
                //获取列数据,根据exportCols数组中列的顺序导出
                var colsList = [];
                for (var i = 0; i < exportCols.length; i++) {
                    colsList.push(exportCols[i]);
                }
                for (var i = 1; i < option.cols[0].length; i++) {
                    if ($.inArray(option.cols[0][i].title, exportCols) > -1) {
                        var index = $.inArray(option.cols[0][i].title, exportCols);
                        colsList[index] = option.cols[0][i];
                    }
                }
 
                //获取行数据
                var listData = [];                             //获取行数据
                var HPieceQtyTotalSum = 0;
                var HQtyTotalSum = 0;
                var HTaxMoneyTotalSum = 0;
                if (option.data.length > 0) {
                    var HEmpID = option.data[0]["HEmpID"];          //用于区分不同业务员
                    var HCusID = option.data[0]["HCusID"];          //用于区分不同客户
                    var HPieceQtySum = 0;                           //件数合计
                    var HQtySum = 0;                                //数量合计
                    var HTaxMoneySum = 0;                           //金额合计
                    for (var i = 0; i < option.data.length; i++) {
                        if (HEmpID != option.data[i]["HEmpID"] || HCusID != option.data[i]["HCusID"]) {
                            HPieceQtyTotalSum += HPieceQtySum;
                            HQtyTotalSum += HQtySum;
                            HTaxMoneyTotalSum += HTaxMoneySum;
 
                            var sumTemp = { "购货单位": "合计:", "产品名称": "", "件数": fixed(HPieceQtySum * 1) + "件", "米数": fixed(HQtySum.toFixed(6) * 1) + "米", "单价": "", "税率%": "", "金额": fixed(HTaxMoneySum.toFixed(6) * 1), "业务员": "" };
                            var emptyTemp = { "购货单位": "", "产品名称": "", "件数": "", "米数": "", "单价": "", "税率%": "", "金额": "", "业务员": "" };
                            var titleTemp = { "购货单位": "购货单位", "产品名称": "产品名称", "件数": "件数", "米数": "米数", "单价": "单价", "税率%": "税率%", "金额": "金额", "业务员": "业务员" };
                            listData.push(sumTemp);
                            listData.push(emptyTemp);
                            listData.push(emptyTemp);
                            listData.push(titleTemp);
 
                            //记录新客户的内码
                            HEmpID = option.data[i]["HEmpID"];
                            HCusID = option.data[i]["HCusID"];
 
                            //初始化件数合计、数量合计、金额合计
                            HPieceQtySum = 0;
                            HQtySum = 0;
                            HTaxMoneySum = 0;
                        }
                        listData.push(option.data[i]);
 
                        HPieceQtySum += option.data[i]["件数"] * 1;
                        HQtySum += option.data[i]["米数"] * 1;
                        HTaxMoneySum += option.data[i]["金额"] * 1;
 
                        if (i == option.data.length - 1) {
                            HPieceQtyTotalSum += HPieceQtySum;
                            HQtyTotalSum += HQtySum;
                            HTaxMoneyTotalSum += HTaxMoneySum;
                            HPieceQtyTotalSum = fixed(HPieceQtyTotalSum * 1);
                            HQtyTotalSum = fixed(HQtyTotalSum.toFixed(6) * 1);
                            HTaxMoneyTotalSum = fixed(HTaxMoneyTotalSum.toFixed(6) * 1);
 
                            var sumTemp = { "购货单位": "合计:", "产品名称": "", "件数": fixed(HPieceQtySum * 1) + "件", "米数": fixed(HQtySum.toFixed(6) * 1) + "米", "单价": "", "税率%": "", "金额": fixed(HTaxMoneySum.toFixed(6) * 1), "业务员": "" };
                            var emptyTemp = { "购货单位": "", "产品名称": "", "件数": "", "米数": "", "单价": "", "税率%": "", "金额": "", "业务员": "" };
                            var totalTemp = { "购货单位": "总合计:", "产品名称": "", "件数": HPieceQtyTotalSum + "件", "米数": HQtyTotalSum + "米", "单价": "", "税率%": "", "金额": HTaxMoneyTotalSum, "业务员": "" };
                            listData.push(sumTemp);
                            listData.push(emptyTemp);
                            listData.push(emptyTemp);
                            listData.push(totalTemp);
                        }
                    }
                }
 
                //设置sheet中的数据
                let news = [[]];
                for (var i = 0; i < colsList.length; i++) {
                    news[0].push(colsList[i].title);
                }
                for (var i = 0; i < listData.length; i++) {
                    news.push([listData[i][exportCols[0]], listData[i][exportCols[1]], listData[i][exportCols[2]], listData[i][exportCols[3]], listData[i][exportCols[4]], listData[i][exportCols[5]], listData[i][exportCols[6]], listData[i][exportCols[7]]]);
                }
 
                //创建sheet
                const sheet = XLSX.utils.aoa_to_sheet(news);
                return sheet;
            }
            function twoTable(option) {
                var exportCols = ["购货单位", "产品名称", "件数", "米数", "单价", "税率%", "金额", "业务员"];
 
                //获取列数据,根据exportCols数组中列的顺序导出
                var colsList = [];
                for (var i = 0; i < exportCols.length; i++) {
                    colsList.push(exportCols[i]);
                }
                for (var i = 1; i < option.cols[0].length; i++) {
                    if ($.inArray(option.cols[0][i].title, exportCols) > -1) {
                        var index = $.inArray(option.cols[0][i].title, exportCols);
                        colsList[index] = option.cols[0][i];
                    }
                }
 
                //获取行数据
                var listData = [];                             //获取行数据
                var HPieceQtyTotalSum = 0;
                var HQtyTotalSum = 0;
                var HTaxMoneyTotalSum = 0;
                if (option.data.length > 0) {
                    var HEmpID = option.data[0]["HEmpID"];          //用于区分不同业务员
                    var HCusID = option.data[0]["HCusID"];          //用于区分不同客户
                    var HPieceQtySum = 0;                           //件数合计
                    var HQtySum = 0;                                //数量合计
                    var HTaxMoneySum = 0;                           //金额合计
                    for (var i = 0; i < option.data.length; i++) {
                        if (HEmpID != option.data[i]["HEmpID"] || HCusID != option.data[i]["HCusID"]) {
                            HPieceQtyTotalSum += HPieceQtySum;
                            HQtyTotalSum += HQtySum;
                            HTaxMoneyTotalSum += HTaxMoneySum;
 
                            var sumTemp = { "购货单位": "合计:", "产品名称": "", "件数": fixed(HPieceQtySum * 1) + "件", "米数": fixed(HQtySum.toFixed(6) * 1) + "米", "单价": "", "税率%": "", "金额": fixed(HTaxMoneySum.toFixed(6) * 1), "业务员": "" };
                            var emptyTemp = { "购货单位": "", "产品名称": "", "件数": "", "米数": "", "单价": "", "税率%": "", "金额": "", "业务员": "" };
                            var titleTemp = { "购货单位": "购货单位", "产品名称": "产品名称", "件数": "件数", "米数": "米数", "单价": "单价", "税率%": "税率%", "金额": "金额", "业务员": "业务员" };
                            listData.push(sumTemp);
                            listData.push(emptyTemp);
                            listData.push(emptyTemp);
                            listData.push(titleTemp);
 
                            //记录新客户的内码
                            HEmpID = option.data[i]["HEmpID"];
                            HCusID = option.data[i]["HCusID"];
 
                            //初始化件数合计、数量合计、金额合计
                            HPieceQtySum = 0;
                            HQtySum = 0;
                            HTaxMoneySum = 0;
                        }
                        listData.push(option.data[i]);
 
                        HPieceQtySum += option.data[i]["件数"] * 1;
                        HQtySum += option.data[i]["米数"] * 1;
                        HTaxMoneySum += option.data[i]["金额"] * 1;
 
                        if (i == option.data.length - 1) {
                            HPieceQtyTotalSum += HPieceQtySum;
                            HQtyTotalSum += HQtySum;
                            HTaxMoneyTotalSum += HTaxMoneySum;
                            HPieceQtyTotalSum = fixed(HPieceQtyTotalSum * 1);
                            HQtyTotalSum = fixed(HQtyTotalSum.toFixed(6) * 1);
                            HTaxMoneyTotalSum = fixed(HTaxMoneyTotalSum.toFixed(6) * 1);
 
                            var sumTemp = { "购货单位": "合计:", "产品名称": "", "件数": fixed(HPieceQtySum * 1) + "件", "米数": fixed(HQtySum.toFixed(6) * 1) + "米", "单价": "", "税率%": "", "金额": fixed(HTaxMoneySum.toFixed(6) * 1), "业务员": "" };
                            var emptyTemp = { "购货单位": "", "产品名称": "", "件数": "", "米数": "", "单价": "", "税率%": "", "金额": "", "业务员": "" };
                            var totalTemp = { "购货单位": "总合计:", "产品名称": "", "件数": HPieceQtyTotalSum + "件", "米数": HQtyTotalSum + "米", "单价": "", "税率%": "", "金额": HTaxMoneyTotalSum, "业务员": "" };
                            listData.push(sumTemp);
                            listData.push(emptyTemp);
                            listData.push(emptyTemp);
                            listData.push(totalTemp);
                        }
                    }
                }
 
                //设置sheet中的数据
                let news = [[]];
                for (var i = 0; i < colsList.length; i++) {
                    news[0].push(colsList[i].title);
                }
                for (var i = 0; i < listData.length; i++) {
                    news.push([listData[i][exportCols[0]], listData[i][exportCols[1]], listData[i][exportCols[2]], listData[i][exportCols[3]], listData[i][exportCols[4]], listData[i][exportCols[5]], listData[i][exportCols[6]], listData[i][exportCols[7]]]);
                }
 
                //创建sheet
                const sheet = XLSX.utils.aoa_to_sheet(news);
                return sheet;
            }
            function exportAll() {
                $.ajax({
                    url: GetWEBURL() + '/Kf_SellOutEntryReport/list',
                    type: "GET",
                    data: { "sWhere": sWhere_Bak, "user": sessionStorage["HUserName"], "userid": sessionStorage["Czybm"] },
                    success: function (data1) {
                        if (data1.count == 1) {
                            var totalArray = ["件数", "米数", "金额"];
                            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' });
                            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 ($.inArray(data[i].name, totalArray) > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, totalRow: true, width: 120, templet: "<div>{{d." + data[i].name + " ==null ?'':fixed(d." + data[i].name + ")}}</div>" });
                                }
                                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: 120 });
                                            break;
                                        default:
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 120 });
                                    }
                                }
                            }
 
                            //设置表1导出数据
                            option_Bak.cols = [col];
                            option_Bak.data = data1.data[0];
 
                            //获取表2导出数据
                            option1_Bak.cols = [col];
                            option1_Bak.data = data1.data[1];
 
                            //获取sheet
                            let sheet1 = oneTable(option_Bak);
                            let sheet2 = twoTable(option1_Bak);
 
                            //创建excel文档
                            const wb = XLSX.utils.book_new();
                            XLSX.utils.book_append_sheet(wb, sheet1, "FDY");
                            XLSX.utils.book_append_sheet(wb, sheet2, "羊毛");
                            const workbookBlob = workbook2blob(wb);
 
                            // 导出最后的总表
                            var ExcelName = "销售出库明细报表" + Format(new Date(), "yyyy-MM-dd") + ".xlsx";
                            openDownloadDialog(workbookBlob, ExcelName);
                        } else {
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#region 设置导出参数
            function workbook2blob(workbook) {
                // 生成excel的配置项
                var wopts = {
                    // 要生成的文件类型
                    bookType: "xlsx",
                    // 是否生成Shared String Table, 官方解释是, 如果开启生成速度会下降, 但在低版本IOS设备上有更好的兼容性
                    bookSST: false,
                    type: "binary"
                };
                var wbout = XLSX.write(workbook, wopts);
                // 将字符串转ArrayBuffer
                function s2ab(s) {
                    var buf = new ArrayBuffer(s.length);
                    var view = new Uint8Array(buf);
                    for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
                    return buf;
                }
                let buf = s2ab(wbout);
                var blob = new Blob([buf], {
                    type: "application/octet-stream"
                });
                return blob;
            }
            //#endregion
            //#region
            function openDownloadDialog(blob, fileName) {
                if (typeof blob === "object" && blob instanceof Blob) {
                    blob = URL.createObjectURL(blob); // 创建blob地址
                }
                var aLink = document.createElement("a");
                aLink.href = blob;
                // HTML5add的属性, 指定保存文件名, 可以不要后缀, 注意, 有时候
                aLink.download = fileName || "";
                var event;
                if (window.MouseEvent) event = new MouseEvent("click");
                //   移动端
                else {
                    event = document.createEvent("MouseEvents");
                    event.initMouseEvent(
                        "click",
                        true,
                        false,
                        window,
                        0,
                        0,
                        0,
                        0,
                        0,
                        false,
                        false,
                        false,
                        false,
                        0,
                        null
                    );
                }
                aLink.dispatchEvent(event);
            }
            //#endregion
            //#endregion
 
        });
 
            //#endregion
 
        //#region 将数据增加千分位
        function fixed(str) {
            if (str !== '' && str != null) {
                if (str === 0) {  //当为0时,不用处理
                    return 0;
                } else {
                    var str1 = str + "";
                    var real = str1.split('.')[0];                  //整数部分
                    var realQty = real.length;
                    var dotQty = str1.length - realQty - 1;
 
                    if (dotQty > 0) {
                        return str.toFixed(dotQty).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
                    } else {
                        var temp = str.toFixed(1).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') + "";
                        temp = temp.split('.')[0];
                        return temp;
                    }
                }
            } else {
                return '';
            }
            return str;
        }
        //#endregion
 
            //以上是layui模块
    </script>
 
</body>
</html>