change_attendance.js 4.7 KB

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