| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- var bl = false;
- var flag = true;
- var startDays, endDays, clickDay;
- $(document).ready(function() {
- helper.getDropList.getProlistDrop($('#sc_pro'))
- // helper.getDropList.getProlistDrop($('#sc_pro')).then(function(){
- // blur();
- // });
- blur();
- getPeopleList();
- $('#sc_btns').click(function() {
- blur();
- getPeopleList();
- })
- });
- function blur(userCode) {
- var rl = $('#RoleCode', top.document).val();
- var gcode = $('#GroupCode', top.document).val();
- $('#calendar').html("");
- var dates = new Date();
- var time = dates.getFullYear() + "-" + (dates.getMonth() + 1) + '-' + dates.getDate();
- var date = new Date();
- var d = date.getDate();
- var m = date.getMonth();
- var y = date.getFullYear();
- $('#calendar').fullCalendar({
- //height: 660,//设置日历的高度,包括header日历头部,默认未设置,高度根据aspectRatio值自适应。
- contentHeight: 650, //设置日历主体内容的高度,不包括header部分,默认未设置,高度根据aspectRatio值自适应。
- //aspectRatio: ,//设置日历单元格宽度与高度的比例。默认1.35
- header: {
- //left: 'month,agendaWeek,agendaDay',
- left: 'month',
- center: 'title',
- right: 'today, prev, next'
- },
- monthNames: ['年1月', '年2月', '年3月', '年4月', '年5月', '年6月', '年7月', '年8月', '年9月', '年10月', '年11月', '年12月'],
- monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
- dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
- titleFormat: {
- month: "yyyy MMMM"
- },
- firstDay: "1",
- editable: false,
- droppable: bl,
- weekMode: 'liquid',
- events: function(start, end, callback) {
- var st = $.fullCalendar.formatDate(start, "yyyy-MM-dd");
- var ed = $.fullCalendar.formatDate(end, "yyyy-MM-dd");
- startDays = $.fullCalendar.formatDate(start, "yyyy-MM-dd");
- endDays = $.fullCalendar.formatDate(end, "yyyy-MM-dd");
- console.log(st);
- console.log(ed);
- changeWorkType(userCode,st,ed)
- },
- dayClick: function(date, allDay, jsEvent, view) {
- $(this).addClass('fc-state-highlight');
- $(this).siblings().removeClass('fc-state-highlight');
- $(this).parent().siblings().children('td').removeClass('fc-state-highlight');
- var mydate = new Date(date);
- clickDay = formatterDate(mydate);
- getPeopleList(formatterDate(mydate), formatterDate(mydate))
- }
- });
- }
- //日历班别显示
- function changeWorkType(userCode,sd,ed){
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "signtokenapi/api/UserGroup/getusergrouplist",
- dataType: 'json',
- async: true,
- data: {
- usercode: userCode,
- projectid: $('#sc_pro').val(),
- startdate: sd,
- enddate: ed
- },
- success: function(data) {
- /*验证请求*/
- //工作日
- if(data.data && data.data.length > 0) {
- $(".fc-day").each(function(i, n) {
- var a = $(this).attr("data-date")
- $(data.data[0].dates).each(function(j, k) {
- $(n).attr("id", k.id);
- if(k == a) {
- if($(n).children().find('.fc-day-content').find('.redFont').length>0){
- if(data.data[0].groups[j] == '白班') {
- $(n).children().find('.fc-day-content').find('font').html('白');
- $(n).children().find('.fc-day-content').find('font').css('background','#5cb85c');
- } else if(data.data[0].groups[j] == '夜班') {
- $(n).children().find('.fc-day-content').find('font').html('夜');
- $(n).children().find('.fc-day-content').find('font').css('background','#249fea');
- } else if(data.data[0].groups[j] == '休息') {
- $(n).children().find('.fc-day-content').find('font').html('休');
- $(n).children().find('.fc-day-content').find('font').css('background','#d9534f');
- } else if(data.data[0].groups[j] == '全天') {
- $(n).children().find('.fc-day-content').find('font').html('天');
- $(n).children().find('.fc-day-content').find('font').css('background','#f8ac59');
- }else{
- $(n).children().find('.fc-day-content').find('font').remove()
- }
- }else{
- if(data.data[0].groups[j] == '白班') {
- var state = '<font class="redFont offday" style="font-weight: bold;background: #5cb85c;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">白</font>';
- $(n).children().find('.fc-day-content').append(state);
- } else if(data.data[0].groups[j] == '夜班') {
- var state = '<font class="redFont offday" style="font-weight: bold;background: #249fea;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">夜</font>';
- $(n).children().find('.fc-day-content').append(state);
- } else if(data.data[0].groups[j] == '休息') {
- var state = '<font class="redFont offday" style="font-weight: bold;background: #d9534f;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">休</font>';
- $(n).children().find('.fc-day-content').append(state);
- } else if(data.data[0].groups[j] == '全天') {
- var state = '<font class="redFont offday" style="font-weight: bold;background: #f8ac59;color: #fff;padding: 4px;font-size: 15px;border-radius: 5px;">天</font>';
- $(n).children().find('.fc-day-content').append(state);
- }
- }
-
- }
- });
- })
- }
- // callback(data.data);
- }
- });
- }
- //初始化日期
- function formatterDate(date) {
- var datetime = date.getFullYear() +
- "-" // "年"
- +
- ((date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1)) +
- "-" // "月"
- +
- (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
- return datetime;
- }
- //获取人员列表及班别
- function getPeopleList(sd, ed) {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "signtokenapi/api/UserGroup/getusergrouplist",
- dataType: 'json',
- async: true,
- data: {
- usercode: '',
- projectid: $('#sc_pro').val(),
- startdate: sd,
- enddate: ed,
- },
- success: function(data) {
- if(data.state.toLowerCase() == 'success') {
- $('.peopleList').html('');
- if(data.data.length > 0) {
- //人员列表
- $.each(data.data, function(i, n) {
- var strs = '<div class="feed-element" data-code="'+ n.usercode +'" onclick="getPersonWork(this)">' +
- '<a href="javaScript:;" class="pull-left">'
- if(n.head_img) {
- // strs += '<img alt="image" class="img-circle" src="' + n.head_img + '">'
- strs += '<img alt="image" class="img-headPic" src="' + n.head_img + '">'
- } else {
- // strs += ' <img alt="image" class="img-circle" src="../img/pro_default_user.png">'
- strs += ' <img alt="image" class="img-headPic" src="../img/pro_default_user.png">'
- // strs += ' <img alt="image" class="img-headPic" src="../img/pb_defult.png">'
- }
- strs += ' </a>' +
- '<div class="media-body ">' +
- '<small class="pull-right text-navy tooltip-demo">' +
- '<button type="button" class="btn btn-success" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A1">白 </button>' +
- '<button type="button" class="btn btn-primary" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A2">夜 </button>' +
- '<button type="button" class="btn btn-danger" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A3">休</button>' +
- '<button type="button" class="btn btn-warning" onclick="setUserGroup(this,event)" data-code="' + n.usercode + '" data-type="A4">天</button>' +
- '</small>' +
- ' <strong>' + n.username + '</strong>' +
- '<br>' +
- '<small class="text-muted">' + n.usercode + '</small>' +
- '<div class="actions">'
- if(n.groups[0] == '白班') {
- strs += '<a class="btn btn-xs btn-success"><i class="fa fa-heart"></i>白</a>'
- } else if(n.groups[0] == '夜班') {
- strs += '<a class="btn btn-xs btn-primary"><i class="fa fa-heart"></i>夜</a>'
- } else if(n.groups[0] == '休息') {
- strs += '<a class="btn btn-xs btn-danger"><i class="fa fa-heart"></i>休</a>'
- } else if(n.groups[0] == '全天') {
- strs += '<a class="btn btn-xs btn-warning"><i class="fa fa-heart"></i>天</a>'
- }
- '</div>' +
- '</div>' +
- '</div>'
- $('.peopleList').append(strs);
- })
- } else {
- $('<div class="feed-element" style="text-align: center;border-bottom:0;"><strong>暂无人员。。。</strong></div>').appendTo($('.peopleList'))
- }
- }
- }
- });
- }
- //获取指定人员排班情况
- function getPersonWork(ele){
- $(ele).addClass('active').siblings().removeClass('active');
- var userCode=$(ele).attr('data-code')
- changeWorkType(userCode,startDays,endDays);
- }
- //班别设置 A1 白 A2夜班 A3 休息
- function setUserGroup(ele,event) {
- event.stopPropagation();
- var dates = new Date();
- if(!clickDay) {
- clickDay = formatterDate(dates)
- }
- layer.confirm('确定修改此员工班别吗?', {
- btn: ['是', '否'] //按钮
- }, function() {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "signtokenapi/api/UserGroup/setusergroup",
- async: true,
- dataType: 'json',
- data: {
- usercode: $(ele).attr('data-code'),
- groupcode: $(ele).attr('data-type'),
- date: clickDay
- },
- success: function(data) {
- if(data.state.toLowerCase() == "success") {
- layer.msg("修改成功");
- getPeopleList(clickDay, clickDay);
- // blur();
- }
- }
- });
- });
- }
|