【angularjs】利用時間控件進行時間篩選

業務如圖:

代碼如下:

html:

                <label>時間:</label>
                <sit-datepicker sit-value="vm.value1" style="display:inline-block;vertical-align:middle"> </sit-datepicker>
                <label>至</label>
                <sit-datepicker sit-value="vm.value2" style="display:inline-block;vertical-align:middle"> </sit-datepicker>

js:

              var d = new Date();
              d.setDate(1);
              //self.value1 = d.format('yyyy-MM-dd');
              //self.value2 = getCurrentMonthLast().format('yyyy-MM-dd');

              // self.value1 = d;
              //self.value2 = getCurrentMonthLast();

              //獲取年月日 20180318 wt
              var GetDate_yyyyMMdd = function () {
                  var nowDate = new Date();
                  var year = nowDate.getFullYear().toString();
                  var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
                  var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
                  return year + "-" + month + "-" + day;
              }
              //獲取時分秒 20180318 wt
              var GetDate_HHmmss = function () {
                  var nowDate = new Date();
                  var hour = nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate.getHours();
                  var minute = nowDate.getMinutes() < 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes();
                  var second = nowDate.getSeconds() < 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds();
                  return hour.toString() + ":" + minute + ":" + second;
              }
                  if (typeof (self.value1) != "undefined" && self.value1 != "" && typeof (self.value2) != "undefined" && self.value2 != "") {
                      strWhere = strWhere + " and estimated_start_time >= '" + self.value1.format('yyyy-MM-dd') + ' 00:00:00' + "' and estimated_start_time <= '" + self.value2.format('yyyy-MM-dd') + ' 23:59:59' + "' ";
                  }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章