fuchengshen
2022-07-04 343ba87e09501be7a63abde000a43e13a5b4f03e
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
'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();