change_attendance.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. // 初始化部门下的收费站
  12. getFsStationList(GV("#center_manage"),function(obj){
  13. $("#fs_station").html(obj);
  14. var dept;
  15. if(roleContains("STATION")){
  16. dept = getCurrentUser().organid;
  17. }
  18. $("#fs_station").val(dept);
  19. // 初始化收费站下的人数
  20. getFsEmployee(GV("#fs_station"),function(obj){
  21. $("#fs_employee").html(obj);
  22. // 检索
  23. getFsWorkInfo(0);
  24. });
  25. });
  26. $.jeDate("#sel_month",{
  27. isinitVal:true,
  28. format: 'YYYY/MM' // 分隔符可以任意定义,该例子表示只显示年月
  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. * 检索出勤明细数据
  76. * @param {*} param
  77. */
  78. function getFsWorkInfo(flag){
  79. var param = {
  80. "start_time": timeTranslate( GV("#sel_month") ) ,
  81. "end_time": (GV("#sel_month")+"/25 23:00:00").replace("/","-").replace("/","-")
  82. }
  83. if(GV("#fs_employee")!=''){
  84. param[ 'user_id'] = GV("#fs_employee");
  85. }else if(GV("#fs_station")!=''){
  86. param[ 'dept_id' ] = GV("#fs_station");
  87. }else if(GV("#center_manage") != ''){
  88. param[ 'parent_dept_id' ] = GV("#center_manage");
  89. }
  90. post_common_service("statistics/fs/unregular/work/info",param,function(data){
  91. if(flag == 0 && $("#ca-a-table").children().length > 0 ){
  92. return ;
  93. }
  94. // 月份变化
  95. monthChange();
  96. $("#ca-a-table").empty();
  97. if(data.length >0){
  98. for(var i=0;i< data.length;i++){
  99. if(data[i].userName != undefined){
  100. $("#ca-a-table").append( getTableContent(data[i],i+1));
  101. }
  102. }
  103. }
  104. },function(error){
  105. });
  106. }
  107. /**
  108. * 拼接表格内容
  109. * @param {*} obj
  110. * @param {*} seq
  111. */
  112. function getTableContent(obj,seq){
  113. var days = getDaysByDate(GV("#sel_month")+"/01");
  114. var map_class = {};
  115. for(var z=0; z < obj.subStatisticsFsWork.length ;z++){
  116. if(obj.subStatisticsFsWork[z].check_id !=undefined){
  117. map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] = 2;
  118. }else{
  119. if( map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] == null ){
  120. map_class[getD(obj.subStatisticsFsWork[z].work_date)+"-"+obj.subStatisticsFsWork[z].class_type] = 1;
  121. }
  122. }
  123. }
  124. var class_html = [];
  125. for(var d=0;d<3;d++){
  126. var class_type = 3;
  127. if(d != 0){
  128. class_type = d ;
  129. }
  130. for(var i=26; i<=days; i++){
  131. if( map_class[i+"-"+class_type] !=undefined ){
  132. if( map_class[i+"-"+class_type]==1){
  133. class_html[d] += '<td>/</td>' ;
  134. }else{
  135. class_html[d] += '<td class="b-grey">/</td>' ;
  136. }
  137. }else{
  138. class_html[d] += '<td></td>' ;
  139. }
  140. }
  141. for(var i=1; i<=25; i++){
  142. if( map_class[i+"-"+class_type] !=undefined ){
  143. if( map_class[i+"-"+class_type]==1){
  144. class_html[d] += '<td>/</td>' ;
  145. }else{
  146. class_html[d] += '<td class="b-grey">/</td>' ;
  147. }
  148. }else{
  149. class_html[d] += '<td></td>' ;
  150. }
  151. }
  152. }
  153. var content = "<tr><td rowspan='3'>"+seq+"</td> <td rowspan='3'>"+obj.feeStationName+"</td> <td rowspan='3'>"+obj.userName+
  154. "</td> <td rowspan='3'>"+obj.positionName+"</td><td rowspan='3'>"+ obj.workno +"</td><td>夜班</td> "+class_html[0]+"<td rowspan='3'>"+
  155. obj.work_days+"</td><td rowspan='3'>"+convertT(obj.work_minutes)+"</td><td rowspan='3'></td> </tr>\
  156. <tr><td>早班</td> "+class_html[1]+" </tr>\
  157. <tr><td>中班</td> "+ class_html[2] +" </tr>" ;
  158. return content;
  159. }
  160. /**
  161. * 月份变化 , 天数变化
  162. */
  163. function monthChange(){
  164. $(".m28").show();
  165. $(".m"+getDaysByDate(GV("#sel_month")+"/01")).hide();
  166. }
  167. function setVisit(){
  168. if(roleContains("STATION")){
  169. $("#center_manage").attr("disabled","disabled");
  170. $("#fs_station").attr("disabled","disabled");
  171. }
  172. if(roleContains("ROAD_MANAGER")){
  173. $("#center_manage").attr("disabled","disabled");
  174. }
  175. }