change_attendance.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. $(function(){
  2. // 初始化部门下的收费站
  3. getFsStationList(GV("#center_manage"),function(obj){
  4. $("#fs_station").html(obj);
  5. // 初始化收费站下的人数
  6. getFsEmployee(GV("#fs_station"),function(obj){
  7. $("#fs_employee").html(obj);
  8. // 检索
  9. getFsWorkInfo();
  10. });
  11. });
  12. // 当前月份初始化
  13. $("#sel_month").val(getM()-1);
  14. // 根据月份确定天数
  15. monthChange();
  16. $("#month_name").html( $("#sel_month").find("option:selected").text());
  17. // 收费站中心选择
  18. $("#fs_station").change(function(){
  19. var fee_station_id = GV(this);
  20. if(fee_station_id == ''){
  21. $("#fs_employee").html('');
  22. }else{
  23. getFsEmployee(fee_station_id,function(obj){
  24. $("#fs_employee").html(obj);
  25. });
  26. }
  27. })
  28. // 导管中心选择
  29. $("#center_manage").change(function(){
  30. var center_manage_id = GV(this);
  31. if(center_manage_id == ''){
  32. $("#fs_station,#fs_employee").html('');
  33. }else{
  34. getFsStationList(center_manage_id,function(obj){
  35. $("#fs_station").html(obj);
  36. });
  37. }
  38. })
  39. // 查询
  40. $("#searchBtn").click(function(){
  41. $("#month_name").html( $("#sel_month").find("option:selected").text() )
  42. getFsWorkInfo();
  43. })
  44. // end
  45. })
  46. /**
  47. * 检索出勤明细数据
  48. * @param {*} param
  49. */
  50. function getFsWorkInfo(){
  51. var param = {
  52. "start_time": "2017-"+(GV("#sel_month")-1)+"-25 23:00:00" ,
  53. "end_time": "2017-"+GV("#sel_month")+"-25 23:00:00"
  54. }
  55. if(GV("#fs_employee")!=''){
  56. param[ 'user_id'] = GV("#fs_employee");
  57. }else if(GV("#fs_station")!=''){
  58. param[ 'dept_id' ] = GV("#fs_station");
  59. }else if(GV("#center_manage") != ''){
  60. param[ 'parent_dept_id' ] = GV("#center_manage");
  61. }
  62. post_common_service("statistics/fs/unregular/work/info",param,function(data){
  63. // 月份变化
  64. monthChange();
  65. $("#ca-a-table").empty();
  66. if(data.length >0){
  67. for(var i=0;i< data.length;i++){
  68. if(data[i].userName != undefined){
  69. $("#ca-a-table").append( getTableContent(data[i],i+1));
  70. }
  71. }
  72. }
  73. },function(error){
  74. });
  75. }
  76. /**
  77. * 拼接表格内容
  78. * @param {*} obj
  79. * @param {*} seq
  80. */
  81. function getTableContent(obj,seq){
  82. var days = getDays(GV("#sel_month")-1);
  83. var map_class = {};
  84. for(var z=0; z < obj.subStatisticsFsWork.length ;z++){
  85. if(obj.subStatisticsFsWork[z].check_id !=undefined){
  86. map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] = 2;
  87. }else{
  88. map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] = 1;
  89. }
  90. }
  91. var class_html = [];
  92. for(var d=0;d<3;d++){
  93. var class_type = 3;
  94. if(d != 0){
  95. class_type = d ;
  96. }
  97. for(var i=26; i<=days; i++){
  98. if( map_class[i+"-"+class_type] !=undefined ){
  99. if( map_class[i+"-"+class_type]==1){
  100. class_html[d] += '<td>/</td>' ;
  101. }else{
  102. class_html[d] += '<td class="b-grey">/</td>' ;
  103. }
  104. }else{
  105. class_html[d] += '<td></td>' ;
  106. }
  107. }
  108. for(var i=1; i<=25; i++){
  109. if( map_class[i+"-"+class_type] !=undefined ){
  110. if( map_class[i+"-"+class_type]==1){
  111. class_html[d] += '<td>/</td>' ;
  112. }else{
  113. class_html[d] += '<td class="b-grey">/</td>' ;
  114. }
  115. }else{
  116. class_html[d] += '<td></td>' ;
  117. }
  118. }
  119. }
  120. var content = "<tr><td rowspan='3'>"+seq+"</td> <td rowspan='3'>"+obj.feeStationName+"</td> <td rowspan='3'>"+obj.userName+
  121. "</td> <td rowspan='3'>"+obj.positionName+"</td><td rowspan='3'>"+ obj.workno +"</td><td>夜班</td> "+class_html[0]+"<td rowspan='3'>"+
  122. obj.work_days+"</td><td rowspan='3'>"+convertT(obj.work_minutes)+"</td><td rowspan='3'></td> </tr>\
  123. <tr><td>早班</td> "+class_html[1]+" </tr>\
  124. <tr><td>中班</td> "+ class_html[2] +" </tr>" ;
  125. return content;
  126. }
  127. /**
  128. * 月份变化 , 天数变化
  129. */
  130. function monthChange(){
  131. $(".m28").show();
  132. $(".m"+getDays(GV("#sel_month")-1)).hide();
  133. }