chenrj-PC\chenrj 8 лет назад
Родитель
Сommit
b4ebedad0d

+ 12 - 5
VisualInspection/js/statistics/change_attendance.js

@@ -12,8 +12,15 @@ $(function(){
         });
     });
 
+
+    // 当初始化月份值
+    var months = month_method_2();
+    for(var i=0; i < months.length;i++){
+        $("#sel_month").append('<option value= "'+ months[i]  +'">'+ months[i] +'</option>');
+    }
+
     // 当前月份初始化
-    $("#sel_month").val(getM()-1);
+    $("#sel_month").val(months[months.length-1 ]);
 
     // 根据月份确定天数
     monthChange();
@@ -59,8 +66,8 @@ $(function(){
 function getFsWorkInfo(){
 
     var param = {
-        "start_time": "2017-"+(GV("#sel_month")-1)+"-25 23:00:00" ,
-        "end_time": "2017-"+GV("#sel_month")+"-25 23:00:00"
+           "start_time": timeTranslate( GV("#sel_month") ) ,
+            "end_time": (GV("#sel_month")+"/25 23:00:00").replace("/","-").replace("/","-")
     }
     
     if(GV("#fs_employee")!=''){
@@ -92,7 +99,7 @@ function getFsWorkInfo(){
  * @param {*} seq 
  */
 function getTableContent(obj,seq){
-    var days = getDays(GV("#sel_month")-1);
+    var days = getDaysByDate(GV("#sel_month")+"/01");
     var map_class = {};
     for(var z=0; z < obj.subStatisticsFsWork.length ;z++){
         if(obj.subStatisticsFsWork[z].check_id !=undefined){
@@ -146,5 +153,5 @@ function getTableContent(obj,seq){
  */
 function monthChange(){
     $(".m28").show();
-    $(".m"+getDays(GV("#sel_month")-1)).hide();
+    $(".m"+getDaysByDate(GV("#sel_month")+"/01")).hide();
 }

+ 13 - 5
VisualInspection/js/statistics/common_attendance.js

@@ -12,8 +12,15 @@ $(function(){
         });
     });
 
+    // 当初始化月份值
+    var months = month_method_2();
+    for(var i=0; i < months.length;i++){
+        $("#sel_month").append('<option value= "'+ months[i]  +'">'+ months[i] +'</option>');
+    }
+
+
     // 当前月份初始化
-    $("#sel_month").val(getM()-1);
+    $("#sel_month").val(months[months.length-1 ]);
 
     // 根据月份确定天数
     monthChange();
@@ -50,6 +57,7 @@ $(function(){
         getFsWorkInfo();
     })
     // end
+
     /**
      * 检索出勤明细数据
      * @param {*} param 
@@ -57,8 +65,8 @@ $(function(){
     function getFsWorkInfo(){
 
         var param = {
-            "start_time": "2017-"+(GV("#sel_month")-1)+"-25 23:00:00" ,
-            "end_time": "2017-"+GV("#sel_month")+"-25 23:00:00"
+            "start_time": timeTranslate( GV("#sel_month") ) ,
+            "end_time": (GV("#sel_month")+"/25 23:00:00").replace("/","-").replace("/","-")
         }
         
         if(GV("#fs_employee")!=''){
@@ -92,7 +100,7 @@ $(function(){
  * @param {*} seq 
  */
 function getTableContent(obj,seq){
-    var days = getDays(GV("#sel_month")-1);
+    var days = getDaysByDate(GV("#sel_month")+"/01");
     var map_class = {};
     for(var z=0; z < obj.subStatisticsFsWork.length ;z++){
         if(obj.subStatisticsFsWork[z].check_id !=undefined){
@@ -146,5 +154,5 @@ function getTableContent(obj,seq){
  */
 function monthChange(){
     $(".m28").show();
-    $(".m"+getDays(GV("#sel_month")-1)).hide();
+    $(".m"+getDaysByDate(GV("#sel_month")+'/01')).hide();
 }

+ 45 - 0
VisualInspection/js/statistics/common_statistic.js

@@ -136,6 +136,33 @@ function getDays(mouth,datet){
     return days ;
 }
 
+/**
+ * 根据月份,判断当前月份天数
+ * param: datet String 年份
+ * return:days( 28,29,30,31 )
+ */
+function getDaysByDate(datet){
+    //构造当前日期对象
+    var date = new Date(datet);
+    //获取年份
+    var year = date.getFullYear();
+    var mouth = date.getMonth() +1 ;
+    //定义当月的天数;
+    var days ;
+    //当月份为二月时,根据闰年还是非闰年判断天数
+    if(mouth == 2){
+            days= year % 4 == 0 ? 29 : 28;
+    }
+    else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
+        //月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
+        days= 31;
+    }
+    else{
+        days= 30;   
+    }
+    return days ;
+}
+
 
 var months = new Array();
 var m = new Date().getMonth();
@@ -200,4 +227,22 @@ function month_method_2(){
 // 数字前面补0
 function PrefixInteger(num, length) {
     return (Array(length).join('0') + num).slice(-length);
+}
+
+/**
+ * 
+ * @param {*} str  ep:2017/06
+ * returns 2017-05-25 23:00:00
+ */
+function timeTranslate(str){
+    var strs = str.split("/") ;
+    var year = strs[0];
+    var month = strs[1];
+    var month2 = month - 1 ;
+    var year2 = year ;
+    if( month2 == 0 ){
+        year2 = year2 - 1 ;
+        month2 = 12 ;
+    }
+    return year2 + "-"+month2 + "-25 23:00:00" ;
 }

+ 3 - 3
VisualInspection/view/statistics/change_attendance.html

@@ -8,7 +8,7 @@
                 <label for="exampleInputAccount1" class="col-sm-1">月份</label>
                 <div class="col-sm-2">
                     <select class="form-control" id="sel_month">
-                        <option value="1">一月</option>
+                        <!--<option value="1">一月</option>
                         <option value="2">二月</option>
                         <option value="3">三月</option>
                         <option value="4">四月</option>
@@ -19,7 +19,7 @@
                         <option value="9">九月</option>
                         <option value="10">十月</option>
                         <option value="11">十一月</option>
-                        <option value="12">十二月</option>
+                        <option value="12">十二月</option>-->
                     </select>
                 </div>
                 <label for="exampleInputAccount1" class="col-sm-1">部门</label>
@@ -50,7 +50,7 @@
 
 
 
-    <div class="table-title"><span id="month_name"></span><span>份机动人员顶岗明细统计表</span></div>
+    <div class="table-title"><span id="month_name"></span><span>份机动人员顶岗明细统计表</span></div>
 
     <div class="row">
           

+ 3 - 3
VisualInspection/view/statistics/common_attendance.html

@@ -8,7 +8,7 @@
                 <label for="exampleInputAccount1" class="col-sm-1">月份</label>
                 <div class="col-sm-2">
                     <select class="form-control" id="sel_month">
-                        <option value="1">一月</option>
+                        <!--<option value="1">一月</option>
                         <option value="2">二月</option>
                         <option value="3">三月</option>
                         <option value="4">四月</option>
@@ -19,7 +19,7 @@
                         <option value="9">九月</option>
                         <option value="10">十月</option>
                         <option value="11">十一月</option>
-                        <option value="12">十二月</option>
+                        <option value="12">十二月</option>-->
                     </select>
                 </div>
                 <label for="exampleInputAccount1" class="col-sm-1">部门</label>
@@ -50,7 +50,7 @@
 
 
 
-    <div class="table-title"><span id="month_name"></span><span>份正常出勤明细统计表</span></div>
+    <div class="table-title"><span id="month_name"></span><span>份正常出勤明细统计表</span></div>
 
     <div class="row">