var bl = false; var flag = true; blur(); $(document).ready(function() { blur(); function blur() { 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"); console.log(ed); $.ajax({ type: "get", url: huayi.config.callcenter_url + "callcenterapi/api/sysworkoffdays/getlist", dataType: 'json', async: true, data: { "token": window.localStorage.getItem("token") }, success: function(data) { /*验证请求*/ //工作日 var arr = []; //console.log(data.data); var time; // $(data.data).each(function(i, n) { // time = n.offdate.substring(0, n.offdate.indexOf(' ')) // arr.push(time); // }); $(".fc-day").each(function(i, n) { var state = ''; $(n).children().find('.fc-day-content').append(state); // $(n).attr('id', n.); var a = $(this).attr("data-date") $(data.data).each(function(j, k) { time = k.offdate.substring(0, k.offdate.indexOf(' ')) $(n).attr("id", k.id); if(time == a) { if($(n).children().find('.redFont')) { $(n).children().find('.redFont').text('休'); $(n).children().find('.redFont').css('background-color', 'red'); $(n).children().find('.redFont').addClass("offday"); } } //arr.push(time); }); // $(arr).each(function(j, k) { // if(k == a) { // if($(n).children().find('.redFont')) { // $(n).children().find('.redFont').text('休'); // $(n).children().find('.redFont').css('background-color', 'red'); // $(n).children().find('.redFont').addClass("offday"); // // } // } // // }) }) callback(data.data); } }); }, dayClick: function(date, allDay, jsEvent, view) { $(this).children().children().find('.redFont').text(); var Time = $(this).attr("data-date"); var ID = $(this).attr("ID"); var type = 1; if($(this).children().children().find('.redFont').text() != "休") { layer.confirm('确定休息日吗?', { btn: ['是', '否'] //按钮 }, function() { $.ajax({ type: "post", url: huayi.config.callcenter_url + "callcenterapi/api/sysworkoffdays/setofforon", dataType: 'json', async: true, data: { offdate: Time, token: window.localStorage.getItem("token"), type: 0, id: ID }, success: function(data) { /*验证请求*/ if(data.state.toLowerCase() == "success") { layer.msg("修改成功"); blur(); } } }); }); } else { layer.confirm('确定设为工作日吗?', { btn: ['是', '否'] //按钮 }, function() { $.ajax({ type: "post", url: huayi.config.callcenter_url + "callcenterapi/api/sysworkoffdays/setofforon", dataType: 'json', async: true, data: { offdate: Time, token: window.localStorage.getItem("token"), type: 1, id: ID }, success: function(data) { /*验证请求*/ if(data.state.toLowerCase() == "success") { layer.msg("修改成功"); blur(); } } }); }); } } }); } });