'use script'; //开发环境建议开启严格模式
|
|
function getDefaultDateTimeLocal() {
|
var date = new Date;
|
date.setHours(date.getHours() - 2);
|
var year = date.getFullYear();//年
|
var month = date.getMonth();//月
|
var day = date.getDate();//日
|
var hours = date.getHours();//时
|
return year + "-" +
|
((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
|
(day > 9 ? day : ("0" + day)) + " " +
|
(hours > 9 ? hours : ("0" + hours)) + ":00:00";
|
}
|
|
|
function getDefaultDateLocal() {
|
var date = new Date;
|
date.setDate(date.getDate() - 1);
|
var year = date.getFullYear();//年
|
var month = date.getMonth();//月
|
var day = date.getDate();//日
|
var hours = date.getHours();//时
|
return year + "-" +
|
((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
|
(day > 9 ? day : ("0" + day)) + " 00:00:00";
|
}
|
|
function applyDateType() {
|
var dateType = $('input[type=radio][name=datatype]').val();
|
return dateType;
|
}
|
|
function getAppDateTime() {
|
return $('#appDate').val();
|
}
|
|
function searchTime() {
|
//此处可以绑定页面dom事件
|
$('input[type=radio][name=datatype]').change(function () {
|
let value = $("input[type=radio][name=datatype]:checked").val()
|
if (value == 'hour') {
|
$('#current').text("小时");
|
$('#appDate').hide()
|
$('#appDateHour').show()
|
/* var tmpDatetime = $('#appDateHour').val();
|
tmpDatetime = tmpDatetime.replace(/\:/g, "").replace(/-/g, "").replace(/\s+/g, "");
|
tableDatas.queryDataTStart = $('#appDateHour').val();
|
tableDatas.queryDataTEnd = $('#appDateHour').val().substring(0, 14) + "15:00";
|
tableDatas.DefaultDateTimeStart = $('#appDateHour').val().substring(0, 11) + "00:00:00";
|
tableDatas.queryDataTStartGeo = tmpDatetime; */
|
}
|
else if (value == 'day') {
|
$('#current').text("天");
|
$('#appDate').show()
|
$('#appDateHour').hide()
|
// var tmpDatetime = $('#appDate').val() + " 00:00:00";
|
// tmpDatetime = tmpDatetime.replace(/\:/g, "").replace(/-/g, "").replace(/\s+/g, "");
|
// tableDatas.queryDataTStart = $('#appDate').val() + " 00:00:00";
|
// tableDatas.queryDataTEnd = $('#appDate').val() + " 00:15:00";
|
// tableDatas.DefaultDateTimeStart = $('#appDate').val().substring(0, 8) + "01 00:00:00";
|
// tableDatas.queryDataTStartGeo = tmpDatetime;
|
}
|
//tableDatas.queryDataType = value;
|
//reLoadLayers();
|
//refreshWidgets();
|
});
|
|
$("#appDate").datetimepicker({
|
bootcssVer: 3, //bootstrap-datetimepicker+bootstrap v3,但这个插件使用的时候,并没有和V3相匹配,仍然调用的是bootstrap V2的图标 把bootcssVer的值直接设为3,否则datetimepicker不会显示出上、下个月的箭头
|
format: 'yyyy-mm-dd',
|
minView: 'month',//设置时间选择为年月日 去掉时分秒选择
|
todayBtn: true, //如果此值为true 或 "linked",则在日期时间选择器组件的底部显示一个 "Today" 按钮用以选择当前日期。如果是true的话,"Today" 按钮仅仅将视图转到当天的日期,如果是"linked",当天日期将会被选中。
|
clearBtn: true,
|
language: 'zh-CN',
|
autoclose: true, //当选择一个日期之后是否立即关闭此日期时间选择器。
|
keyboardNavigation: true, //是否允许通过方向键改变日期。
|
forceParse: true, //当选择器关闭的时候,是否强制解析输入框中的值。
|
initialDate: new Date(),
|
todayHighlight: 1 //如果为true, 高亮当前日期
|
}).on("changeDate", function () {
|
/*
|
var tmpDatetime = $('#appDate').val() + " 00:00:00";
|
tmpDatetime = tmpDatetime.replace(/\:/g, "").replace(/-/g, "").replace(/\s+/g, "");
|
|
tableDatas.queryDataTStart = $('#appDate').val() + " 00:00:00";
|
tableDatas.queryDataTEnd = $('#appDate').val() + " 00:15:00";
|
tableDatas.DefaultDateTimeStart = $('#appDate').val().substring(0, 8) + "01 00:00:00";
|
tableDatas.queryDataTStartGeo = tmpDatetime;
|
*/
|
//reLoadLayers();
|
//refreshWidgets();
|
|
});
|
$("#appDate").datetimepicker("setDate", new Date(getDefaultDateLocal()));
|
$("#appDate").datetimepicker("setEndDate", new Date(this.defaultDate));
|
|
$("#appDateHour").datetimepicker({
|
bootcssVer: 3, //bootstrap-datetimepicker+bootstrap v3,但这个插件使用的时候,并没有和V3相匹配,仍然调用的是bootstrap V2的图标 把bootcssVer的值直接设为3,否则datetimepicker不会显示出上、下个月的箭头
|
format: 'yyyy-mm-dd hh:00:00',
|
minView: 'day',//设置时间选择为年月日 去掉时分秒选择
|
todayBtn: true, //如果此值为true 或 "linked",则在日期时间选择器组件的底部显示一个 "Today" 按钮用以选择当前日期。如果是true的话,"Today" 按钮仅仅将视图转到当天的日期,如果是"linked",当天日期将会被选中。
|
clearBtn: true,
|
language: 'zh-CN',
|
autoclose: true, //当选择一个日期之后是否立即关闭此日期时间选择器。
|
keyboardNavigation: true, //是否允许通过方向键改变日期。
|
forceParse: true, //当选择器关闭的时候,是否强制解析输入框中的值。
|
initialDate: new Date(),
|
todayHighlight: 1 //如果为true, 高亮当前日期
|
}).on("changeDate", function () {
|
|
/* var tmpDatetime = $('#appDateHour').val();
|
tmpDatetime = tmpDatetime.replace(/\:/g, "").replace(/-/g, "").replace(/\s+/g, "");
|
|
tableDatas.queryDataTStart = $('#appDateHour').val();
|
tableDatas.queryDataTEnd = $('#appDateHour').val().substring(0, 14) + "15:00";
|
tableDatas.DefaultDateTimeStart = $('#appDateHour').val().substring(0, 11) + "00:00:00";
|
tableDatas.queryDataTStartGeo = tmpDatetime;
|
*/
|
//reLoadLayers();
|
//refreshWidgets();
|
});
|
$("#appDateHour").datetimepicker("setDate", new Date(getDefaultDateTimeLocal()));
|
$('#appDateHour').datetimepicker('setEndDate', new Date(this.defaultDateTime));
|
}
|
searchTime();
|