common_attendance.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. $(function(){
  2. setVisit();
  3. var road_manager;
  4. if(roleContains("STATION")){
  5. road_manager = getCurrentUser().road_manager_id;
  6. }
  7. if(roleContains("ROAD_MANAGER")){
  8. road_manager = getCurrentUser().organid;
  9. }
  10. setRoadManagerSelect("#center_manage",road_manager,true);
  11. $.jeDate("#sel_month",{
  12. isinitVal:true,
  13. format: 'YYYY/MM' // 分隔符可以任意定义,该例子表示只显示年月
  14. });
  15. // 初始化部门下的收费站
  16. getFsStationList(GV("#center_manage"),function(obj){
  17. $("#fs_station").html(obj);
  18. var dept;
  19. if(roleContains("STATION")){
  20. dept = getCurrentUser().organid;
  21. }
  22. $("#fs_station").val(dept);
  23. // 初始化收费站下的人数
  24. getFsEmployee(GV("#fs_station"),function(obj){
  25. $("#fs_employee").html(obj);
  26. // 检索
  27. getFsWorkInfo(0);
  28. });
  29. });
  30. // 当初始化月份值
  31. var months = month_method_2();
  32. // for(var i=0; i < months.length;i++){
  33. // $("#sel_month").append('<option value= "'+ months[i] +'">'+ months[i] +'</option>');
  34. // }
  35. // 当前月份初始化
  36. // $("#sel_month").val(months[months.length-1 ]);
  37. // 根据月份确定天数
  38. monthChange();
  39. $("#month_name").html( GV("#sel_month"));
  40. // 收费站中心选择
  41. $("#fs_station").change(function(){
  42. var fee_station_id = GV(this);
  43. if(fee_station_id == ''){
  44. $("#fs_employee").html('');
  45. }else{
  46. getFsEmployee(fee_station_id,function(obj){
  47. $("#fs_employee").html(obj);
  48. });
  49. }
  50. })
  51. // 导管中心选择
  52. $("#center_manage").change(function(){
  53. var center_manage_id = GV(this);
  54. if(center_manage_id == ''){
  55. $("#fs_station,#fs_employee").html('');
  56. }else{
  57. getFsStationList(center_manage_id,function(obj){
  58. $("#fs_station").html(obj);
  59. var dept;
  60. if(roleContains("STATION")){
  61. dept = getCurrentUser().organid;
  62. }
  63. $("#fs_station").val(dept);
  64. });
  65. }
  66. })
  67. // 查询
  68. $("#searchBtn").click(function(){
  69. $("#month_name").html( GV("#sel_month") )
  70. getFsWorkInfo(1);
  71. })
  72. // end
  73. /**
  74. * 检索出勤明细数据
  75. * @param {*} param
  76. */
  77. function getFsWorkInfo(flag){
  78. var param = {
  79. "start_time": timeTranslate( GV("#sel_month") ) ,
  80. "end_time": (GV("#sel_month")+"/25 23:00:00").replace("/","-").replace("/","-")
  81. }
  82. if(GV("#fs_employee")!=''){
  83. param[ 'user_id'] = GV("#fs_employee");
  84. }else if(GV("#fs_station")!=''){
  85. param[ 'dept_id' ] = GV("#fs_station");
  86. }else if(GV("#center_manage") != ''){
  87. param[ 'parent_dept_id' ] = GV("#center_manage");
  88. }
  89. post_common_service("statistics/fs/work/info",param,function(data){
  90. if(flag == 0 && $("#c-a-tbody").children().length > 0 ){
  91. return ;
  92. }
  93. // 月份变化
  94. monthChange();
  95. $("#c-a-tbody").empty();
  96. if(data.length >0){
  97. var seq = 1 ;
  98. for(var i=0;i< data.length;i++){
  99. if(data[i].userName != undefined){
  100. $("#c-a-tbody").append( getTableContent(data[i],seq++));
  101. }
  102. }
  103. }
  104. },function(error){
  105. });
  106. }
  107. })
  108. /**
  109. * 拼接表格内容
  110. * @param {*} obj
  111. * @param {*} seq
  112. */
  113. function getTableContent(obj,seq){
  114. var days = getDaysByDate(GV("#sel_month")+"/01");
  115. var map_class = {};
  116. for(var z=0; z < obj.subStatisticsFsWork.length ;z++){
  117. if(obj.subStatisticsFsWork[z].check_id !=undefined){
  118. map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] = 2;
  119. }else{
  120. if( map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] == null ){
  121. map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] = 1;
  122. }
  123. }
  124. }
  125. var class_html = [];
  126. for(var d=0;d<3;d++){
  127. var class_type = 3;
  128. if(d != 0){
  129. class_type = d ;
  130. }
  131. for(var i=26; i<=days; i++){
  132. if( map_class[i+"-"+class_type] !=undefined ){
  133. if( map_class[i+"-"+class_type]==1){
  134. class_html[d] += '<td>/</td>' ;
  135. }else{
  136. class_html[d] += '<td class="b-grey">/</td>' ;
  137. }
  138. }else{
  139. class_html[d] += '<td></td>' ;
  140. }
  141. }
  142. for(var i=1; i<=25; i++){
  143. if( map_class[i+"-"+class_type] !=undefined ){
  144. if( map_class[i+"-"+class_type]==1){
  145. class_html[d] += '<td>/</td>' ;
  146. }else{
  147. class_html[d] += '<td class="b-grey">/</td>' ;
  148. }
  149. }else{
  150. class_html[d] += '<td></td>' ;
  151. }
  152. }
  153. }
  154. var content = "<tr><td rowspan='3'>"+seq+"</td> <td rowspan='3'>"+obj.feeStationName+"</td> <td rowspan='3'>"+obj.userName+
  155. "</td> <td rowspan='3'>"+obj.positionName+"</td><td rowspan='3'>"+ obj.workno +"</td><td>夜班</td> "+class_html[0]+"<td rowspan='3'>"+
  156. obj.work_days+"</td><td rowspan='3'>"+convertT(obj.work_minutes)+"</td><td rowspan='3'></td> </tr>\
  157. <tr><td>早班</td> "+class_html[1]+" </tr>\
  158. <tr><td>中班</td> "+ class_html[2] +" </tr>" ;
  159. return content;
  160. }
  161. /**
  162. * 月份变化 , 天数变化
  163. */
  164. function monthChange(){
  165. $(".m28").show();
  166. $(".m"+getDaysByDate(GV("#sel_month")+'/01')).hide();
  167. }
  168. function setVisit(){
  169. if(roleContains("STATION")){
  170. $("#center_manage").attr("disabled","disabled");
  171. $("#fs_station").attr("disabled","disabled");
  172. }
  173. if(roleContains("ROAD_MANAGER")){
  174. $("#center_manage").attr("disabled","disabled");
  175. }
  176. }