qinbo
2021-09-16 47e10b936ccf6f1cf54a6cf69362474a2ec238c1
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
 
 
<div class="input-group input-group-lg append_test"  >
  <span style="width: 50px;" class="fa fa-globe input-group-addon dropdown-toggle" data-toggle="dropdown" ><span>&nbsp;&nbsp;</span><span id="current">小时:</span></span>
  <input type='text' class="form-control date" id='appDate' name="appDate"/>
    <ul class="dropdown-menu">
          
      <div class="layui-form">
          <div class="layui-form-item">
            <div class="layui-inline">
              <div class="layui-input-inline">
                <input type="radio" name="datatype" value="hour" title="小时数据" checked>
                <input type="text" class="layui-input" id="datatype_hour" placeholder="yyyy-MM-dd HH">
              </div>
            </div>
            <div class="layui-inline">
              <div class="layui-input-inline">
                <input type="radio" name="datatype" value="day" title="天数据" >
                  <input type="text" class="layui-input" id="datatype_day" placeholder="yyyy-MM-dd">
              </div>
            </div>
          </div>
        </div>
    
  </ul>
</div>
 
 
 
<!-- <div class="btn-group append_test">
    
    <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
       
        <!-- <span class="fa fa-globe" id="current"> 小时: -->
          <input type='button' class="form-control" id='' name="" value="" />
          
    </button>
    <button type="button" class="btn btn-primary">
      <!-- <input type="text" class="layui-input" id="appDate" placeholder="yyyy-MM-dd"> -->
      <!-- <input type='text' class="form-control date" id='appDate' name="appDate"/> -->
    </button>
    
    
</div> -->
 
<script>
  $(document).ready(function() {
        initDayHour();
    
 
        //console.log("i am jquery");
        //var currentHour = getDefaultDateTime();
        //$('#currentHour').text(currentHour);
 
 
        $('input[type=radio][name=datatype]').change(function() {
            if (this.value == 'hour') {
                //alert("Allot Thai Gayo Bhai");
                $('#current').text("小时:");
                initDayHour();
            }
            else if (this.value == 'day') {
                //alert("Transfer Thai Gayo");
                $('#current').text("天:");
                initDay();
            }
            reloadTop10();
        });
 
 
 
      
 
    })
 
    function initDayHour(){
      try {
        $("#appDate").datetimepicker('remove');
      } catch (error) {
        
      }
      
      $("#appDate").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 () {
            //設置可选的最后日期為當前日期
            //$("#start_time").datetimepicker("setEndDate", getToday())
            reloadTop10();
        });  
 
        $("#appDate").datetimepicker("setDate", new Date());
    }
 
    function initDay(){
      try {
        $("#appDate").datetimepicker('remove');
      } catch (error) {
        
      }
      $("#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 () {
            //設置可选的最后日期為當前日期
            //$("#start_time").datetimepicker("setEndDate", getToday())
            reloadTop10();
        });  
 
        $("#appDate").datetimepicker("setDate", new Date());
 
    }
 
    function applyDateType(){
      var dateType = $('input[type=radio][name=datatype]').val();
      return dateType;
    }
 
    function reloadTop10(){
      var leftAndRight = mars3d.widget.getClass("widgetsTS/widget_Overall/widget.js");
      if(leftAndRight){
        if(leftAndRight.viewWindowLeft){
          leftAndRight.viewWindowLeft.loadTop10();
        }
      }
    }
 
    function getAppDateTime(){
      return $('#appDate').val();
    }
</script>