!DOCTYPE html>
html>
head>
meta charset='utf-8' />
!-- 日歷插件 -->
link href='/public/school/table/fullcalendar.min.css' rel='stylesheet' />
link href='/public/school/table/fullcalendar.print.min.css' rel='stylesheet' media='print' />
script src='/public/school/table/moment.min.js'>/script>
script src='/public/school/table/jquery.min.js'>/script>
script src='/public/school/table/fullcalendar.min.js'>/script>
!-- fullcalendar語言包 -->
script src='/public/school/table/locale-all.js'>/script>
!-- layui -->
link rel="stylesheet" href="/public/school/layui/css/layui.css" rel="external nofollow" media="all">
link rel="stylesheet" href="/public/school/style/admin.css" rel="external nofollow" media="all">
script src="/public/school/layui/layui.js">/script>
!-- bootstrap -->
link rel='stylesheet' />
script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'>/script>
script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js'>/script>
/head>
script>
//獲取當前日期
var myDate = new Date();
var defaultDate = myDate.getFullYear() +'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()
$(document).ready(function() {
$('#calendar').fullCalendar({
header: { //頂部顯示信息
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth'
},
defaultDate: defaultDate, //默認顯示日期
navLinks: true, // can click day/week names to navigate views
defaultView:'agendaWeek', //初始化時的默認視圖默認顯示周
allDaySlot: false, //是否顯示all-day
slotLabelFormat:'H:mm', //左側時間顯示格式
minTime : '06:00:00', //左側時間從幾點開始
maxTime : '22:00:00', //左側時間從幾點結束
locale: 'zh-cn', //顯示中文
selectable: true, //設置是否可被單擊或者拖動選擇
eventLimit: true, //如果數(shù)據(jù)過多超過日歷格子顯示的高度時,多出去的數(shù)據(jù)不會將格子擠開,而是顯示為 +...more ,點擊后才會完整顯示所有的數(shù)據(jù)
// 點擊課程信息事件,并彈窗
eventClick: function(calEvent, jsEvent, view) {
console.log('cycle_id:' + calEvent.id); //點擊的課程周期id
console.log('sel_type:' + calEvent.sel_type); //點擊的課程周期類型 1單次 2重復
// 彈出一個頁面
layer.open({
type: 2,
title: '課程表信息',
shadeClose: true,
shade: [0.5, '#000'],
maxmin: true, //開啟最大化最小化按鈕
area: ['900px', '650px'],
content: "/school/Course_Table/cycleInfo.html?cycle_id="+calEvent.id,
end: function () {
// 刷新父窗口
location.reload();
}
});
},
// 點擊空白區(qū)域,獲取選擇的日期時間范圍,并彈窗
select: function(startDate, endDate) {
selDate = startDate.format('YYYY-MM-DD'); //選中的開始日期
layer.open({
type: 2,
title: '周期排課',
shadeClose: true,
shade: [0.5, '#000'],
maxmin: true, //開啟最大化最小化按鈕
area: ['900px', '650px'],
content: "/school/Course_Table/addCycle2.html?selDate="+selDate,
end: function () {
// 刷新父窗口
location.reload();
}
});
},
// 日期顯示格式
views: {
month: {
titleFormat: 'YYYY年MM月'
},
agenda: {
titleFormat: 'YYYY年MM月DD日'
},
week: {
titleFormat: 'YYYY年MM月DD日'
},
},
// 鼠標移上的提示 使用bootstorp的提示
eventRender: function(eventObj, $el) {
$el.popover({
content: eventObj.description,
trigger: 'hover',
placement: 'top',
container: 'body'
});
},
// 獲取要顯示的數(shù)據(jù) 返回的是json格式
events: function(start,end,timezone, callback) {
$.ajax({
url: "{:url('courseTable')}",
dataType: 'json',
type:"POST",
success: function(data) {
if (data.status == 0) {
callback(data.msg);
}else{
layer.msg('網(wǎng)絡錯誤');
}
},
error:function () {
layer.msg('網(wǎng)絡錯誤');
}
});
}
});
});
/script>
style>
body {
/*margin: 40px 10px;*/
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#calendar {
max-width: 1200px;
margin: 0 auto;
}
/style>
/head>
body>
div class="layui-fluid" style="margin: 10px">
div class="layui-card">
div class="layui-card-body">
div id='calendar'>/div>
/div>
/div>
/div>
script type="text/javascript">
//加載layui
layui.use(['layer','element','form'], function(){
var layer = layui.layer
,element = layui.element
,form = layui.form;
});
/script>
/body>
/html>
以上所述是小編給大家介紹的php使用fullcalendar日歷插件的教程詳解整合,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!