date1.html
6.44 KB
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
<!--日期20170629-->
<script src="__PUBLIC__/static/date/daterangepicker-1.3.7.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="__PUBLIC__/static/date/daterangepicker-bs3.css" />
<link rel="stylesheet" type="text/css" media="all" href="__PUBLIC__/static/date/daterangepicker-1.3.7.css" />
<link href="__PUBLIC__/static/font/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/static/date/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/date/moment.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/date/daterangepicker-1.3.7.js"></script>
<!--日期end-->
<style type="text/css">
.page-content {
vertical-align: middle;
display: inline-block;
*display: inline;
*zoom: 1;
}
.reportrange {
line-height: 30px;
height: 30px;
padding: 0;
position: relative;
}
.reportrange i {
margin-left: 10px;
}
.caret {
float: none;
position: absolute;
right: 5px;
top: 5px;
}
.fa-calendar::before {
content: "\f073";
}
.dateRange {
background-color: #fff;
}
.tabmenu .tab .active a,
.tabmenu .tab .active a:hover {
padding: 7px 19px 26px;
}
.next i.fa {
margin-right: -20px;
}
.item-title .subject {
height: 47px;
}
.ncsc-default-table thead th {
height: auto;
}
.flexigrid .bDiv a.btn{
height: 25px;
}
.reportrange i{
vertical-align: middle;
}
.reportrange span{
font-size: 12px;
vertical-align: middle;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
//统计有当前页有多少个日期控件
var num=0;
$(".reportrangeBox").each(function(){
num+=1;
});
//循环不可合并在一起
//重复日期控件代码
var str="";
for (var i = 1; i <= num; i++) {
str += "<div class='reportrange reportrange"+i+" pull-left dateRange dn' style='width:330px'>";
str += "<i class='glyphicon glyphicon-calendar fa fa-calendar'></i>";
str += "<span></span>";
str += "<b class='caret'></b>";
str += "</div>";
$(".reportrangeBox").html(str);
}
//因此重复的代码
for(var i=1;i<=num;i++){
$(".reportrange"+i).eq(i-1).removeClass("dn");
}
//给每个日期控件添加事件
for (var i = 1; i <= num; i++) {
reportrange(i);
}
//循环结束
//设置日期菜单被选项 --开始--
var dateOption;
if ("${riqi}" == 'day') {
dateOption = "今日";
} else if ("${riqi}" == 'yday') {
dateOption = "昨日";
} else if ("${riqi}" == 'week') {
dateOption = "最近7日";
} else if ("${riqi}" == 'month') {
dateOption = "最近30日";
} else if ("${riqi}" == 'year') {
dateOption = "最近一年";
} else {
dateOption = "自定义";
}
$(".daterangepicker").find("li").each(function() {
if ($(this).hasClass("active")) {
$(this).removeClass("active");
}
if (dateOption == $(this).html()) {
$(this).addClass("active");
}
});
//设置日期菜单被选项 --结束--
});
function reportrange(num) {
// $('#reportrange'+num+' span').text(1);
// $('#reportrange'+num+' span').html(moment().subtract('hours', 168).format('YYYY-MM-DD HH:mm:ss') + ' - ' + moment().format('YYYY-MM-DD HH:mm:ss'));
// $("#add_time_begin"+num).val(moment().subtract('hours', 168).format('YYYY-MM-DD HH:mm:ss'));
// $("#add_time_end"+num).val(moment().format('YYYY-MM-DD HH:mm:ss'));
var getinputdate;
if ($("#add_time_begin" + num).val()!="" && $("#add_time_end" + num).val()!="")
{
getinputdate = $("#add_time_begin" + num).val() + " - " + $("#add_time_end" + num).val();
}
$('.reportrange' + num + ' span').html("");
$('.reportrange' + num + ' span').html(getinputdate);
$("#timegap"+num).val(getinputdate);
$('.reportrange' + num).daterangepicker({
startDate: moment().subtract('day', 7).format('YYYY-MM-DD HH:mm:ss'),//开始时间
endDate: moment().format('YYYY-MM-DD HH:mm:ss'),//结束时间
//minDate: '01/01/2012', //最小时间
//maxDate: moment(), //最大时间
dateLimit: {
days: 7200
}, //起止时间的最大间隔
showDropdowns: true,
showWeekNumbers: false, //是否显示第几周
timePicker: true, //是否显示小时和分钟
timePickerIncrement: 60, //时间的增量,单位为分钟
timePicker12Hour: false, //是否使用12小时制来显示时间
ranges: {
//'最近1小时': [moment().subtract('hours',1), moment()],
'今日': [moment().startOf('day'), moment().format('YYYY-MM-DD 23:59:59')],
'昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
'最近7日': [moment().subtract('days', 6), moment().format('YYYY-MM-DD 23:59:59')],
'最近30日': [moment().subtract('days', 29), moment().format('YYYY-MM-DD 23:59:59')]
},
beginTime:'#add_time_begin'+num+'',//开始时间的元素id
endTime:'#add_time_end'+num+'',//结束时间的元素id
showTime:'.reportrange'+num+' span',//显示时间的元素id
timegap:'#timegap'+num+'',//开始时间到结束时间的元素id
opens: 'right', //日期选择框的弹出位置
buttonClasses: ['btn btn-default'],
applyClass: 'btn-small btn-primary blue',
cancelClass: 'btn-small',
format: 'YYYY-MM-DD HH:mm:ss', //控件中from和to 显示的日期格式
separator: ' to ',
locale: {
applyLabel: '确定',
cancelLabel: '清除',
fromLabel: '起始时间',
toLabel: '结束时间',
customRangeLabel: '自定义',
daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
'七月', '八月', '九月', '十月', '十一月', '十二月'
],
firstDay: 1
}
}, function(start, end, label) { //格式化日期显示框
$("#add_time_begin" + num).val(start.format('YYYY-MM-DD HH:mm:ss'));
$("#add_time_end" + num).val(end.format('YYYY-MM-DD HH:mm:ss'));
$('.reportrange' + num + ' span').html(start.format('YYYY-MM-DD HH:mm:ss') + ' - ' + end.format('YYYY-MM-DD HH:mm:ss'));
// $("#timegap"+num).val(start.format('YYYY-MM-DD HH:mm:ss') + ' - ' + end.format('YYYY-MM-DD HH:mm:ss'));
$("#timegap"+num).val($("#add_time_begin" + num).val() + ' - ' + $("#add_time_end" + num).val());
});
}
</script>
<div class="reportrangeBox">
<!--<div class="reportrange pull-left dateRange dn" style="width:300px">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
<span></span>
<b class="caret"></b>
</div>-->
</div>