You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
301 lines
9.9 KiB
JavaScript
301 lines
9.9 KiB
JavaScript
var calendar_list = new arrayHelper("strStart");
|
|
|
|
$(function () {
|
|
var selectdate = GetNowDate();
|
|
renderCalendar();
|
|
GetCalendarlist(selectdate);
|
|
|
|
//if ($(".fc-today-button").attr("disabled") == "disabled")
|
|
//{
|
|
// $(".fc-today-button").attr("disabled", false).removeClass(".fc-state-disabled");
|
|
// $(".fc-today-button").unbind("click").bind("click", function () { SetMyColor })
|
|
|
|
// // $("#calendar").fullCalendar('today', SetMyColor);
|
|
|
|
//}
|
|
|
|
SetMyColor();
|
|
$("#selectdate").click(function () {
|
|
var selectdstr = $("#selecteddate").val();
|
|
var selectdate = $.fullCalendar.parseDate(selectdstr, "yyyy-mm-dd");
|
|
$('#calendar').fullCalendar('gotoDate', selectdate.getFullYear(), selectdate.getMonth(), selectdate.getDate());
|
|
SetMyColor();
|
|
});
|
|
|
|
$("#calendar").fullCalendar('today', SetMyColor);
|
|
|
|
//$(".fc-next-button").unbind().bind("click", function () {
|
|
// var starttime = $('#calendar').fullCalendar('next');
|
|
// alert(starttime);
|
|
//});
|
|
$("#choseType").change(function () {
|
|
if ($(".mySelected").length == 0) {
|
|
GetCalendarlist(selectdate);
|
|
}
|
|
else {
|
|
selectdate = $(".mySelected").attr("data-date");
|
|
GetCalendarlist(selectdate);
|
|
}
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
//初始化日历控件
|
|
function renderCalendar() {
|
|
$('#calendar').fullCalendar({
|
|
header: {
|
|
left: 'prev,next today',
|
|
center: 'title',
|
|
right: false
|
|
},
|
|
defaultView: 'month', //默认视图
|
|
lang: 'zh-cn', //语言
|
|
selectable: false, //是否允许用户通过单击或拖动选择日历中的对象,包括天和时间。
|
|
selectHelper: false, //当点击或拖动选择时间时,显示默认加载的提示信息,该属性只在周/天视图里可用。
|
|
editable: false, //事件是否可编辑,可编辑是指可以移动, 改变大小等。
|
|
eventLimit: false, //是否显示更多按钮
|
|
handleWindowResize: false,
|
|
height: 410,
|
|
firstDay:0,
|
|
//点击日程表具体日期时的事件
|
|
dayClick: function (date, allDay, jsEvent, view) {
|
|
selectdate = date.format();
|
|
//选中样式
|
|
$(".mySelected").removeClass("mySelected");
|
|
$(".fc-bg td[data-date='" + selectdate + "']").addClass("mySelected");
|
|
// SetMyColor();
|
|
|
|
pageHelper.Init({
|
|
url: "/Student/Calendar/GetCalendarList",
|
|
type: "POST",
|
|
pageDiv: "#pages",
|
|
async: true,
|
|
data: {
|
|
// UserId: 3,
|
|
ChoseTime: selectdate,
|
|
ChoseType: $("#choseType").val()
|
|
|
|
},
|
|
bind: function (data) {
|
|
var html = "";
|
|
$(data.Data).each(function (index, dom) {
|
|
//每行html
|
|
var trHtml = "";
|
|
trHtml += "<tr>";
|
|
trHtml += "<td><div title=\"{0}\" class=\"ellipsis\">{0}</div></td>";
|
|
trHtml += "<td><div title=\"{1}\" class=\"ellipsis\">{1}</div></td>";
|
|
trHtml += "<td><div title=\"{2}\" class=\"ellipsis\">{2}</div></td>";
|
|
trHtml += "<td class='operate'>";
|
|
trHtml += "<a href=\"javascript:void(0)\" onclick=\"Details('" + dom.Id + "')\">查看</a>";
|
|
trHtml += "<a href=\"javascript:void(0)\" onclick=\"Update('" + dom.Id + "')\">编辑</a>";
|
|
trHtml += "<a href=\"javascript:void(0)\" onclick=\"Delete('" + dom.Id + "')\">删除</a>"
|
|
trHtml += "</td></tr>";
|
|
//拼接tbody
|
|
html += StringHelper.FormatStr(trHtml,
|
|
dom.CustomerName, //1 章节名称
|
|
|
|
dom.StrType,
|
|
dom.StrOrDate
|
|
);
|
|
});
|
|
$("#calendarList").html(html);
|
|
|
|
BindOrder(GetNowDate());
|
|
SetMyColor();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
//日程表绑定事件
|
|
events: function (start, end, timezone, callback) {
|
|
BindOrder(GetNowDate());
|
|
// callback(events);
|
|
SetMyColor();
|
|
},
|
|
viewDisplay: function (view)
|
|
{
|
|
var viewStart = $.fullCalendar.formatDate(view.start, "yyyy/MM/dd");
|
|
BindOrder(viewStart);
|
|
}
|
|
|
|
|
|
});
|
|
}
|
|
|
|
//获取日历列表
|
|
function GetCalendarlist(selectdate) {
|
|
pageHelper.Init({
|
|
url: "/Student/Calendar/GetCalendarList",
|
|
type: "POST",
|
|
pageDiv: "#pages",
|
|
async: false,
|
|
data: {
|
|
|
|
ChoseTime: selectdate,
|
|
ChoseType: $("#choseType").val()
|
|
|
|
},
|
|
bind: function (data) {
|
|
var html = "";
|
|
$(data.Data).each(function (index, dom) {
|
|
//每行html
|
|
var trHtml = "";
|
|
trHtml += "<tr>";
|
|
trHtml += "<td><div title=\"{0}\" class=\"ellipsis\">{0}</div></td>";
|
|
trHtml += "<td><div title=\"{1}\" class=\"ellipsis\">{1}</div></td>";
|
|
trHtml += "<td><div title=\"{2}\" class=\"ellipsis\">{2}</div></td>";
|
|
trHtml += "<td class='operate'>";
|
|
trHtml += "<a href=\"javascript:void(0)\" onclick=\"Details('" + dom.Id + "')\">查看</a>";
|
|
trHtml += "<a href=\"javascript:void(0)\" onclick=\"Update('" + dom.Id + "')\">编辑</a>";
|
|
trHtml += "<a href=\"javascript:void(0)\" onclick=\"Delete('" + dom.Id + "','"+selectdate+"')\">删除</a>"
|
|
trHtml += "</td></tr>";
|
|
//拼接tbody
|
|
html += StringHelper.FormatStr(trHtml,
|
|
dom.CustomerName, //1 客户姓名
|
|
dom.StrType, //服务类型
|
|
dom.StrOrDate //预约时间
|
|
|
|
);
|
|
});
|
|
$("#calendarList").html(html);
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
//取当前时间
|
|
function GetNowDate() {
|
|
var myDate = new Date();
|
|
myDate.toLocaleTimeString();
|
|
|
|
// myDate.toDateString();
|
|
return formatterDate(myDate);
|
|
}
|
|
|
|
//时间格式化
|
|
function formatterDate(date) {
|
|
var datetime = date.getFullYear()
|
|
+ "/"// "年"
|
|
+ ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : "0"
|
|
+ (date.getMonth() + 1))
|
|
+ "/"// "月"
|
|
+ (date.getDate() < 10 ? "0" + date.getDate() : date
|
|
.getDate());
|
|
return datetime;
|
|
}
|
|
|
|
//查看日程详情
|
|
function Details(Id) {
|
|
location.href = "/Student/Calendar/AddUpdateCalendarIndex?Id=" + Id + "&type=Details";
|
|
}
|
|
|
|
//更新日程安排
|
|
function Update(Id) {
|
|
location.href = "/Student/Calendar/AddUpdateCalendarIndex?Id=" + Id + "&type=Update";
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除日程安排
|
|
function Delete(Id, selectdate) {
|
|
|
|
dialogHelper.Confirm({
|
|
content: "确定删除该日程安排?",
|
|
success: function () {
|
|
$.ajax({
|
|
url: "/Student/Calendar/DelCalendar",
|
|
type: "POST",
|
|
async: true,
|
|
data: {
|
|
Id: Id
|
|
},
|
|
success: function (data) {
|
|
//弹出成功提示
|
|
//code ...
|
|
dialogHelper.Success({
|
|
content:"删除成功!"
|
|
});
|
|
//刷新当前页
|
|
if (selectdate != undefined) {
|
|
GetCalendarlist(selectdate);
|
|
BindOrder(selectdate);
|
|
}
|
|
else {
|
|
GetCalendarlist(GetNowDate());
|
|
BindOrder(GetNowDate());
|
|
}
|
|
SetMyColor();
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* @name 设置日历表时间
|
|
*/
|
|
function SetMyColor() {
|
|
//移除日历原有样式
|
|
$(".fc-today").removeClass("fc-today");
|
|
$(".fc-state-highlight").removeClass("fc-state-highlight");
|
|
//今天样式改变
|
|
var today = $("#hdToday").val();
|
|
$(".fc-bg td[data-date='" + today + "']").addClass("myToday");
|
|
//添加预约样式
|
|
$(calendar_list.GetList()).each(function (index, dom) {
|
|
$(".fc-bg td[data-date='" + dom.strStart + "']").addClass("myOrder");
|
|
});
|
|
//重复样式处理
|
|
$(".myOrder,.myToday").each(function (index, dom) {
|
|
var isToday = $(dom).hasClass("myToday");
|
|
var isSelected = $(dom).hasClass("mySelected");
|
|
var isOrder = $(dom).hasClass("myOrder");
|
|
if (isToday && isSelected && isOrder) {
|
|
//1.今天+选中+预约,显示选中
|
|
$(dom).removeClass("myToday").removeClass("myOrder");
|
|
} else if (isSelected && isOrder) {
|
|
//2.选中+预约,显示选中
|
|
$(dom).removeClass("myOrder");
|
|
} else if (isSelected && isToday) {
|
|
//3.选中+今天,显示选中
|
|
$(dom).removeClass("myToday");
|
|
} else if (isToday && isOrder) {
|
|
//4.今天+预约,显示当日
|
|
$(dom).removeClass("myOrder");
|
|
}
|
|
});
|
|
}
|
|
|
|
function BindOrder(start)
|
|
{
|
|
$.ajax({
|
|
url: "/Student/Calendar/GetCalendartoJson",
|
|
type: "POST",
|
|
dataType: 'json',
|
|
async: false,
|
|
data: { start: GetNowDate() },
|
|
success: function (data) {
|
|
calendar_list.RemoveAll();
|
|
$(data).each(function (index, dom) {
|
|
calendar_list.Add(dom);
|
|
});
|
|
},
|
|
error: function () {
|
|
dialogHelper.Error({ content: "读取预约信息错误!" });
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|