暫無描述

WorkforceManagement.js 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. var bl = false;
  2. var flag = true;
  3. var startDays, endDays, clickDay;
  4. $(document).ready(function() {
  5. helper.getDropList.getProlistDrop($('#sc_pro'))
  6. // helper.getDropList.getProlistDrop($('#sc_pro')).then(function(){
  7. // blur();
  8. // });
  9. blur();
  10. getPeopleList();
  11. $('#sc_btns').click(function() {
  12. blur();
  13. getPeopleList();
  14. })
  15. });
  16. function blur(userCode) {
  17. var rl = $('#RoleCode', top.document).val();
  18. var gcode = $('#GroupCode', top.document).val();
  19. $('#calendar').html("");
  20. var dates = new Date();
  21. var time = dates.getFullYear() + "-" + (dates.getMonth() + 1) + '-' + dates.getDate();
  22. var date = new Date();
  23. var d = date.getDate();
  24. var m = date.getMonth();
  25. var y = date.getFullYear();
  26. $('#calendar').fullCalendar({
  27. //height: 660,//设置日历的高度,包括header日历头部,默认未设置,高度根据aspectRatio值自适应。
  28. contentHeight: 650, //设置日历主体内容的高度,不包括header部分,默认未设置,高度根据aspectRatio值自适应。
  29. //aspectRatio: ,//设置日历单元格宽度与高度的比例。默认1.35
  30. header: {
  31. //left: 'month,agendaWeek,agendaDay',
  32. left: 'month',
  33. center: 'title',
  34. right: 'today, prev, next'
  35. },
  36. monthNames: ['年1月', '年2月', '年3月', '年4月', '年5月', '年6月', '年7月', '年8月', '年9月', '年10月', '年11月', '年12月'],
  37. monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
  38. dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
  39. dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
  40. titleFormat: {
  41. month: "yyyy MMMM"
  42. },
  43. firstDay: "1",
  44. editable: false,
  45. droppable: bl,
  46. weekMode: 'liquid',
  47. events: function(start, end, callback) {
  48. var st = $.fullCalendar.formatDate(start, "yyyy-MM-dd");
  49. var ed = $.fullCalendar.formatDate(end, "yyyy-MM-dd");
  50. startDays = $.fullCalendar.formatDate(start, "yyyy-MM-dd");
  51. endDays = $.fullCalendar.formatDate(end, "yyyy-MM-dd");
  52. console.log(st);
  53. console.log(ed);
  54. changeWorkType(userCode,st,ed)
  55. },
  56. dayClick: function(date, allDay, jsEvent, view) {
  57. $(this).addClass('fc-state-highlight');
  58. $(this).siblings().removeClass('fc-state-highlight');
  59. $(this).parent().siblings().children('td').removeClass('fc-state-highlight');
  60. var mydate = new Date(date);
  61. clickDay = formatterDate(mydate);
  62. getPeopleList(formatterDate(mydate), formatterDate(mydate))
  63. }
  64. });
  65. }
  66. //日历班别显示
  67. function changeWorkType(userCode,sd,ed){
  68. $.ajax({
  69. type: "get",
  70. url: huayi.config.callcenter_url + "signtokenapi/api/UserGroup/getusergrouplist",
  71. dataType: 'json',
  72. async: true,
  73. data: {
  74. usercode: userCode,
  75. projectid: $('#sc_pro').val(),
  76. startdate: sd,
  77. enddate: ed
  78. },
  79. success: function(data) {
  80. /*验证请求*/
  81. //工作日
  82. if(data.data && data.data.length > 0) {
  83. $(".fc-day").each(function(i, n) {
  84. var a = $(this).attr("data-date")
  85. $(data.data[0].dates).each(function(j, k) {
  86. $(n).attr("id", k.id);
  87. if(k == a) {
  88. if($(n).children().find('.fc-day-content').find('.redFont').length>0){
  89. if(data.data[0].groups[j] == '白班') {
  90. $(n).children().find('.fc-day-content').find('font').html('白');
  91. $(n).children().find('.fc-day-content').find('font').css('background','#5cb85c');
  92. } else if(data.data[0].groups[j] == '夜班') {
  93. $(n).children().find('.fc-day-content').find('font').html('夜');
  94. $(n).children().find('.fc-day-content').find('font').css('background','#249fea');
  95. } else if(data.data[0].groups[j] == '休息') {
  96. $(n).children().find('.fc-day-content').find('font').html('休');
  97. $(n).children().find('.fc-day-content').find('font').css('background','#d9534f');
  98. } else if(data.data[0].groups[j] == '全天') {
  99. $(n).children().find('.fc-day-content').find('font').html('天');
  100. $(n).children().find('.fc-day-content').find('font').css('background','#f8ac59');
  101. }else{
  102. $(n).children().find('.fc-day-content').find('font').remove()
  103. }
  104. }else{
  105. if(data.data[0].groups[j] == '白班') {
  106. var state = '<font class="redFont offday" style="font-weight: bold;background: #5cb85c;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">白</font>';
  107. $(n).children().find('.fc-day-content').append(state);
  108. } else if(data.data[0].groups[j] == '夜班') {
  109. var state = '<font class="redFont offday" style="font-weight: bold;background: #249fea;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">夜</font>';
  110. $(n).children().find('.fc-day-content').append(state);
  111. } else if(data.data[0].groups[j] == '休息') {
  112. var state = '<font class="redFont offday" style="font-weight: bold;background: #d9534f;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">休</font>';
  113. $(n).children().find('.fc-day-content').append(state);
  114. } else if(data.data[0].groups[j] == '全天') {
  115. var state = '<font class="redFont offday" style="font-weight: bold;background: #f8ac59;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">天</font>';
  116. $(n).children().find('.fc-day-content').append(state);
  117. }
  118. }
  119. }
  120. });
  121. })
  122. }
  123. // callback(data.data);
  124. }
  125. });
  126. }
  127. //初始化日期
  128. function formatterDate(date) {
  129. var datetime = date.getFullYear() +
  130. "-" // "年"
  131. +
  132. ((date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1)) +
  133. "-" // "月"
  134. +
  135. (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
  136. return datetime;
  137. }
  138. //获取人员列表及班别
  139. function getPeopleList(sd, ed) {
  140. $.ajax({
  141. type: "get",
  142. url: huayi.config.callcenter_url + "signtokenapi/api/UserGroup/getusergrouplist",
  143. dataType: 'json',
  144. async: true,
  145. data: {
  146. usercode: '',
  147. projectid: $('#sc_pro').val(),
  148. startdate: sd,
  149. enddate: ed,
  150. },
  151. success: function(data) {
  152. if(data.state.toLowerCase() == 'success') {
  153. $('.peopleList').html('');
  154. if(data.data.length > 0) {
  155. //人员列表
  156. $.each(data.data, function(i, n) {
  157. var strs = '<div class="feed-element" data-code="'+ n.usercode +'" onclick="getPersonWork(this)">' +
  158. '<a href="javaScript:;" class="pull-left">'
  159. if(n.head_img) {
  160. // strs += '<img alt="image" class="img-circle" src="' + n.head_img + '">'
  161. strs += '<img alt="image" class="img-headPic" src="' + n.head_img + '">'
  162. } else {
  163. // strs += ' <img alt="image" class="img-circle" src="../img/pro_default_user.png">'
  164. strs += ' <img alt="image" class="img-headPic" src="../img/pro_default_user.png">'
  165. // strs += ' <img alt="image" class="img-headPic" src="../img/pb_defult.png">'
  166. }
  167. strs += ' </a>' +
  168. '<div class="media-body ">' +
  169. '<small class="pull-right text-navy tooltip-demo">' +
  170. '<button type="button" class="btn btn-success" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A1">白 </button>' +
  171. '<button type="button" class="btn btn-primary" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A2">夜 </button>' +
  172. '<button type="button" class="btn btn-danger" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A3">休</button>' +
  173. '<button type="button" class="btn btn-warning" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A4">天</button>' +
  174. '</small>' +
  175. ' <strong>' + n.username + '</strong>' +
  176. '<br>' +
  177. '<small class="text-muted">' + n.usercode + '</small>' +
  178. '<div class="actions">'
  179. if(n.groups[0] == '白班') {
  180. strs += '<a class="btn btn-xs btn-success"><i class="fa fa-heart"></i>白</a>'
  181. } else if(n.groups[0] == '夜班') {
  182. strs += '<a class="btn btn-xs btn-primary"><i class="fa fa-heart"></i>夜</a>'
  183. } else if(n.groups[0] == '休息') {
  184. strs += '<a class="btn btn-xs btn-danger"><i class="fa fa-heart"></i>休</a>'
  185. } else if(n.groups[0] == '全天') {
  186. strs += '<a class="btn btn-xs btn-warning"><i class="fa fa-heart"></i>天</a>'
  187. }
  188. '</div>' +
  189. '</div>' +
  190. '</div>'
  191. $('.peopleList').append(strs);
  192. })
  193. } else {
  194. $('<div class="feed-element" style="text-align: center;border-bottom:0;"><strong>暂无人员。。。</strong></div>').appendTo($('.peopleList'))
  195. }
  196. }
  197. }
  198. });
  199. }
  200. //获取指定人员排班情况
  201. function getPersonWork(ele){
  202. $(ele).addClass('active').siblings().removeClass('active');
  203. var userCode=$(ele).attr('data-code')
  204. changeWorkType(userCode,startDays,endDays);
  205. }
  206. //班别设置 A1 白 A2夜班 A3 休息
  207. function setUserGroup(ele,event) {
  208. event.stopPropagation();
  209. var dates = new Date();
  210. if(!clickDay) {
  211. clickDay = formatterDate(dates)
  212. }
  213. layer.confirm('确定修改此员工班别吗?', {
  214. btn: ['是', '否'] //按钮
  215. }, function() {
  216. $.ajax({
  217. type: "post",
  218. url: huayi.config.callcenter_url + "signtokenapi/api/UserGroup/setusergroup",
  219. async: true,
  220. dataType: 'json',
  221. data: {
  222. usercode: $(ele).attr('data-code'),
  223. groupcode: $(ele).attr('data-type'),
  224. date: clickDay
  225. },
  226. success: function(data) {
  227. if(data.state.toLowerCase() == "success") {
  228. layer.msg("修改成功");
  229. getPeopleList(clickDay, clickDay);
  230. // blur();
  231. }
  232. }
  233. });
  234. });
  235. }