var mnu = "";
//加载
$(function () {
mnu = $.SystemGeneral.getUrlParam("MNU");
})
//获取选中的数据
function validSchedulingChoose() {
var d = [];
$.each($("#dgSchedulingList").cmsXDataTable("getSelections"), function (index) {
d.push(this);
});
return d;
}
//添加时间安排
function Scheduling_Add() {
var schoolyearID = $("#SchoolyearID").combobox("getValue");
var classroom = $("#ClassroomID").combogridX("getValue");
if (classroom == nonSelect || classroom == "") {
$.messager.alert('系统信息', "请先选择教室再添加时间安排。");
} else {
$.popupTopWindow('添加时间安排', CMS_SystemConfig.VirtualDirectoryPath + '/ClassroomExcessiveUse/SchedulingEdit?MNU=' + mnu + '&schoolyearID=' + schoolyearID + '&classroom=' + classroom, 600, 400, Scheduling_Add_Confirm);
}
}
function Scheduling_Add_Confirm(scheduling) {
if (!scheduling) return;
var schedulingList = $("#dgSchedulingList").cmsXDataTable("getRows");
if ($.grep(schedulingList, function (row, index) {
if (scheduling.Weekday == row.Weekday && scheduling.CoursesTimeID == row.CoursesTimeID) {
for (var i = 0; i < row.WeekNumList.length; i++) {
if (scheduling.WeekNumList.contains(row.WeekNumList[i])) {
return true;
}
}
}
return false;
}).length == 0) {
schedulingList.push({
ClassroomExcessiveUseSchedulingID: Guid.NewGuid().ToString(),
WeekNumList: scheduling.WeekNumList,
Weekday: scheduling.Weekday,
WeekdayDesc: scheduling.WeekdayDesc,
CoursesTimeID: scheduling.CoursesTimeID,
StartTimes: scheduling.StartTimes,
EndTimes: scheduling.EndTimes,
StartHour: scheduling.StartHour,
StartMinute: scheduling.StartMinute,
EndHour: scheduling.EndHour,
EndMinute: scheduling.EndMinute,
TimeDesc: scheduling.TimeDesc
});
$("#dgSchedulingList").cmsXDataTable("loadData", { rows: schedulingList, total: schedulingList.length });
} else {
$.messager.alert('系统信息', "请检查输入的时间安排,不要重复添加。");
}
}
function Scheduling_Delete() {
var d = validSchedulingChoose();
var schedulingList = $("#dgSchedulingList").cmsXDataTable("getRows");
var i, j;
var len = schedulingList.length;
for (i = len - 1; i >= 0; i--) {
for (j = 0; j < d.length; j++) {
if (schedulingList[i].ClassroomExcessiveUseSchedulingID == d[j].ClassroomExcessiveUseSchedulingID) {
schedulingList.splice(i, 1);
break;
}
}
}
$("#dgSchedulingList").cmsXDataTable("loadData", { rows: schedulingList, total: schedulingList.length });
}
function Scheduling_Edit(rowindex, rowdata) {
$.popupTopWindow('添加时间安排', CMS_SystemConfig.VirtualDirectoryPath + '/ClassroomExcessiveUse/SchedulingEdit?MNU=' + mnu, 600, 300, Scheduling_Edit_Confirm, rowdata);
}
function Scheduling_Edit_Confirm(scheduling) {
if (!scheduling) return;
var schedulingList = $("#dgSchedulingList").cmsXDataTable("getRows");
if ($.grep(schedulingList, function (row, index) {
if (scheduling.Weekday == row.Weekday && scheduling.CoursesTimeID == row.CoursesTimeID && scheduling.ClassroomExcessiveUseSchedulingID != row.ClassroomExcessiveUseSchedulingID) {
for (var i = 0; i < row.WeekNumList.length; i++) {
if (scheduling.WeekNumList.contains(row.WeekNumList[i])) {
return true;
}
}
}
return false;
}).length == 0) {
var curSchedulingList = $.grep(schedulingList, function (row, index) { return scheduling.ClassroomExcessiveUseSchedulingID == row.ClassroomExcessiveUseSchedulingID; });
if (curSchedulingList.length == 0) return;
var curScheduling = curSchedulingList[0];
curScheduling.WeekNumList = scheduling.WeekNumList;
curScheduling.Weekday = scheduling.Weekday;
curScheduling.WeekdayDesc = scheduling.WeekdayDesc;
curScheduling.CoursesTimeID = scheduling.CoursesTimeID;
curScheduling.StartTimes = scheduling.StartTimes;
curScheduling.EndTimes = scheduling.EndTimes;
curScheduling.StartHour = scheduling.StartHour;
curScheduling.StartMinute = scheduling.StartMinute;
curScheduling.EndHour = scheduling.EndHour;
curScheduling.EndMinute = scheduling.EndMinute;
curScheduling.TimeDesc = scheduling.TimeDesc;
$("#dgSchedulingList").cmsXDataTable("loadData", { rows: schedulingList, total: schedulingList.length });
} else {
$.messager.alert('系统信息', "请检查输入的时间安排,不要重复添加。");
}
}
function ClassroomExcessiveUse_Save() {
$(document.forms[0]).submit();
}
function popupClassroomReport(classroomID) {
var schoolYearID = $("#SchoolyearID").combobox("getValue");
var fullUrl = CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fClassroomSchedulingView&BuildingsInfoID_RAP=&ClassroomID_RAP=" + classroomID + "&SchoolyearID_RAP=" + schoolYearID;
$.popupTopWindowOutsite('教室课表', fullUrl, 1024, 600);
}
function FormSuccess(data) {
$('a').removeAttr('disabled', 'disabled');
$('#loading').hide();
if (data.IsSuccess) {
$.messager.alert('系统信息', data.Message, null, function () {
var dialogId = $.SystemGeneral.getUrlParam('WindowID');
dialogId = (dialogId == null || dialogId == '') ? 'sysWindow' : dialogId;
try {
top.$('#' + dialogId).window('close');
} catch (e) {
}
var tab = top.$('#index_center_tabs').tabs('getSelected');
var $iframe = tab.panel('body').find("iframe");
if ($iframe[0].contentWindow.reload)
$iframe[0].contentWindow.reload();
});
} else {
var classroomID = $("#ClassroomID").combogridX("getValue");
var classroomName = $("#ClassroomID").combogridX("getText");
var reportLink = "点击下列链接查看相关教室的课表:
";
reportLink += '';
reportLink += classroomName + "课表";
reportLink += " ";
$.messager.alert("系统提示", data.Message + reportLink);
}
}