12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256 |
- var currentItem = null;
- var currentCell = null;
- var currentSchedulingWeekList = null;
- var usedClassroomList = new Array();
- var teacherScheduleContinuousCount = 0;
- var classScheduleContinuousCount = 0;
- var classCourseScheduleContinuousCount = 0;
- var mnu = "";
- var colorGroup = ["timeSpanCell1", "timeSpanCell2", "timeSpanCell3"];
- var isZoomOuted = false;
- var zoomRate = 5;
- var schedulingClassSelectedWeekList = [];
- $(function () {
- mnu = $.SystemGeneral.getUrlParam("MNU");
- $(".middleBar").mousedown(middleStartDrag);
- $(document).mousemove(middleDragging);
- });
- function EducationScheduling_ZoomOut() {
- if (!isZoomOuted) {
- $(".schedulingHeaderCell").width($(".schedulingHeaderCell").width() * zoomRate);
- $(".schedulingHeader").width($(".schedulingHeader").width() * zoomRate);
- $(".schedulingRow").width($(".schedulingRow").width() * zoomRate);
- $(".schedulingCell").width($(".schedulingCell").width() * zoomRate);
- $(".schedulingCellHeader").height($(".schedulingCellHeader").height() * zoomRate);
- $(".schedulingRow").height($(".schedulingRow").height() * zoomRate);
- $(".schedulingCell").height($(".schedulingCell").height() * zoomRate);
- $(".schedulingItem").each(function (i, x) {
- $(x).width($(x).width() * zoomRate);
- $(x).height($(x).height() * zoomRate);
- });
- isZoomOuted = true;
- }
- }
- function EducationScheduling_ZoomIn() {
- if (isZoomOuted) {
- $(".schedulingHeaderCell").width($(".schedulingHeaderCell").width() / zoomRate);
- $(".schedulingHeader").width($(".schedulingHeader").width() / zoomRate);
- $(".schedulingRow").width($(".schedulingRow").width() / zoomRate);
- $(".schedulingCell").width($(".schedulingCell").width() / zoomRate);
- $(".schedulingCellHeader").height($(".schedulingCellHeader").height() / zoomRate);
- $(".schedulingRow").height($(".schedulingRow").height() / zoomRate);
- $(".schedulingCell").height($(".schedulingCell").height() / zoomRate);
- $(".schedulingItem").each(function (i, x) {
- $(x).width($(x).width() / zoomRate);
- $(x).height($(x).height() / zoomRate);
- });
- isZoomOuted = false;
- }
- }
- var mouseXStart;
- var vmiddleBar;
- var isDragging = false;
- function middleStartDrag(event) {
- mouseXStart = $(".middleBar").offset().left;
- vmiddleBar = $(".middleBar").clone();
- vmiddleBar.removeClass("middleBar");
- vmiddleBar.css("border-style", "dashed");
- vmiddleBar.mouseup(middleEndDrag);
- vmiddleBar.appendTo(".popupWindowContent");
- isDragging = true;
- }
- function middleDragging(event) {
- if (isDragging) {
- event = event || window.event;
- event.cancelBubble = true;
- var x = event.clientX || event.originalEvent.layerX;
- var offset = $(".middleBar").offset();
- if ((mouseXStart - x) <= offset.left
- && (x - mouseXStart) <= $("#scheduleContainer").width()) {
- offset.left = offset.left - (mouseXStart - x);
- vmiddleBar.offset(offset);
- }
- return false;
- }
- }
- function middleEndDrag(event) {
- if (vmiddleBar) {
- event = event || window.event;
- var x = event.clientX || event.originalEvent.layerX;
- var middleBarOffset = $(".middleBar").offset();
- var containerWidth = $("#scheduleContainer").width();
- var containerOffset = $("#scheduleContainer").offset();
- if ((mouseXStart - x) <= middleBarOffset.left && (x - mouseXStart) <= containerWidth) {
- middleBarOffset.left = middleBarOffset.left - (mouseXStart - x);
- } else if ((mouseXStart - x) > middleBarOffset.left) {
- middleBarOffset.left = 1;
- } else if ((x - mouseXStart) > containerWidth) {
- middleBarOffset.left = containerWidth - 3;
- }
- $("#leftContainer").width(middleBarOffset.left);
- $(".middleBar").offset(middleBarOffset);
- $("#scheduleContainer").width(containerWidth + (mouseXStart - x) - 2);
- if ($("#scheduleContainer").width() - 100 > 0) {
- $(".schedulingHeaderContainer").width($("#scheduleContainer").width() - 100);
- $(".schedulingCellContainer").width($(".schedulingHeaderContainer").width());
- } else {
- $(".schedulingHeaderContainer").width(1);
- $(".schedulingCellContainer").width(1);
- }
- containerOffset.left = middleBarOffset.left + 2;
- $("#scheduleContainer").offset(containerOffset);
- vmiddleBar.css("display", "none");
- $(".popupWindowContent").remove(vmiddleBar);
- vmiddleBar = null;
- isDragging = false;
- }
- }
- function popupTeacherReport(userID) {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var fullUrl = CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fTeacherSchedulingView&CollegeID_RAP=&UserID_RAP=" + userID + "&SchoolyearID_RAP=" + schoolYearID;
- $.popupTopWindowOutsite('教师课表', fullUrl, 1024, 600);
- }
- function popupClassroomReport(ClassroomID) {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var fullUrl = CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fClassroomSchedulingView&BuildingsInfoID_RAP=&ClassroomID_RAP=" + ClassroomID + "&SchoolyearID_RAP=" + schoolYearID;
- $.popupTopWindowOutsite('教室课表', fullUrl, 1024, 600);
- }
- function showClassroomScheduleView(classroomID) {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- $.popupTopWindowOutsite('教室课表', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/ClassroomScheduleView?SchoolyearID=' + schoolYearID + '&ClassroomID=' + classroomID, 800, 400);
- }
- function EducationScheduling_Submit() {
- var collegeID = $("#CollegeDropdown").combobox("getValue");
- $.popupTopWindow('提交课表', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/Submit', 300, 200, reload, {
- collegeID: collegeID
- });
- }
- function gridLoaded() {
- //加载中间内容
- loadScheduleContainer();
- }
- function loadScheduleContainer() {
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/GetContinuousLimitView', null, function (data) {
- teacherScheduleContinuousCount = data.TeacherScheduleContinuousCount;
- classScheduleContinuousCount = data.ClassScheduleContinuousCount;
- classCourseScheduleContinuousCount = data.ClassCourseScheduleContinuousCount;
- loadScheduleData();
- });
- }
- function getCoursesTimeList(schedulingData) {
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/CoursesTime/ListAll', null, function (courseTimeData) {
- drawScheduleContainer(courseTimeData, schedulingData);
- });
- }
- function checkWeekTimeOverflowAndSetWeekList(weekList) {
- var workhours = parseInt(currentCell.attr("workhours"));
- weekList = $.grep(weekList, function (x) { return x.Times >= workhours });
- if (weekList.length == 0) {
- $.messager.alert("系统提示", "该时段需要排" + workhours.toString() + "个学时,该任务班的剩余学时不足,不能排课。");
- return false;
- }
- currentSchedulingWeekList = weekList;
- var isDup = false;
- //只有同一个排课班才需要判断周次冲突
- $.each(currentCell.find('.schedulingItem'), function (i, x) {
- if (currentItem.EducationSchedulingClassID == $(x).attr("EducationSchedulingClassID")) {
- var weeklyNumList = eval($(x).attr("WeeklyNums"));
- $.each(currentSchedulingWeekList, function (n, w) {
- if (weeklyNumList.contains(w.Week)) {
- $.messager.alert("系统提示", "上课周次冲突。");
- isDup = true;
- return false;
- }
- });
- }
- });
- if (isDup) {
- return false;
- }
- return true;
- }
- function getScheduledItemRemainWeekNums(scheduleItem, allScheduled) {
- var weekList = $.map(scheduleItem.CourseProcessViewList, function (x) {
- return {
- Week: x.Week,
- Times: x.Times,
- CourseProcessTeacherViewList: x.CourseProcessTeacherViewList,
- StaffNames: x.StaffNames,
- ClassroomTypeID: x.ClassroomTypeID,
- ClassroomTypeName: x.ClassroomTypeName,
- ClassroomID: x.ClassroomID,
- ClassroomName: x.ClassroomName
- };
- });
- $.each(allScheduled, function (i, x) {
- var weeklyNumList = eval($(x).attr("WeeklyNums"));
- var workhours = parseInt($(x).parent().attr("workhours"));
- var teacherTeachingViewList = eval(unescape($(x).attr("TeacherTeachingViewList")));
- weekList = $.map(weekList, function (m) {
- var newTimes = m.Times;
- if (weeklyNumList.contains(m.Week)
- && $.map(m.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(teacherTeachingViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')) {
- newTimes = newTimes - workhours;
- }
- return {
- Week: m.Week,
- Times: newTimes,
- CourseProcessTeacherViewList: m.CourseProcessTeacherViewList,
- StaffNames: m.StaffNames,
- ClassroomTypeID: m.ClassroomTypeID,
- ClassroomTypeName: m.ClassroomTypeName,
- ClassroomID: m.ClassroomID,
- ClassroomName: m.ClassroomName
- };
- });
- });
- weekList = $.grep(weekList, function (x) { return x.Times > 0; });
- return weekList;
- }
- //输入一个列表上的排课班,和已排有这个排课班的格子匹配,获取这个排课班剩余可以排的周次
- function getScheduleItemWeekNums(scheduleItem, allScheduled, splitWeeks) {
- var weekList = $.map(scheduleItem.CourseProcessViewList, function (x) {
- return {
- Week: x.Week,
- Times: x.Times,
- CourseProcessTeacherViewList: x.CourseProcessTeacherViewList,
- StaffNames: x.StaffNames,
- ClassroomTypeID: x.ClassroomTypeID,
- ClassroomTypeName: x.ClassroomTypeName,
- ClassroomID: x.ClassroomID,
- ClassroomName: x.ClassroomName
- };
- });
- if (!splitWeeks && schedulingClassSelectedWeekList[scheduleItem.EducationSchedulingClassID] != null) {
- weekList = $.grep(weekList, function (x) { return schedulingClassSelectedWeekList[scheduleItem.EducationSchedulingClassID].contains(x.Week); });
- }
- $.each(allScheduled, function (i, x) {
- var weeklyNumList = eval($(x).attr("WeeklyNums"));
- var workhours = parseInt($(x).parent().attr("workhours"));
- var teacherTeachingViewList = eval(unescape($(x).attr("TeacherTeachingViewList")));
- // var classroomTypeID = $(x).attr("ClassroomTypeID");
- // var classroomID = $(x).attr("ClassroomID");
- weekList = $.map(weekList, function (m) {
- var newTimes = m.Times;
- if (weeklyNumList.contains(m.Week)
- && $.map(m.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(teacherTeachingViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')
- // && m.ClassroomTypeID == classroomTypeID
- // && m.ClassroomID == classroomID
- ) {
- newTimes = newTimes - workhours;
- }
- return {
- Week: m.Week,
- Times: newTimes,
- CourseProcessTeacherViewList: m.CourseProcessTeacherViewList,
- StaffNames: m.StaffNames,
- ClassroomTypeID: m.ClassroomTypeID,
- ClassroomTypeName: m.ClassroomTypeName,
- ClassroomID: m.ClassroomID,
- ClassroomName: m.ClassroomName
- };
- });
- });
- weekList = $.grep(weekList, function (x) { return x.Times > 0; })
- .sort(function (a, b) { return a.Times - b.Times; });
- var weekListMap = {};
- var weekListGroup = [];
- for (var i = 0; i < weekList.length; i++) {
- var existModifyGroup = $.grep(weekListGroup, function (x) {
- return x.CourseProcessTeacherViewList.length == weekList[i].CourseProcessTeacherViewList.length
- && $.map(x.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(weekList[i].CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')
- && x.ClassroomTypeID == weekList[i].ClassroomTypeID
- && x.ClassroomID == weekList[i].ClassroomID
- && x.Times <= weekList[i].Times
- });
- if (existModifyGroup.length > 0) {
- $.each(weekListGroup, function (n, x) {
- if ($.map(x.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(weekList[i].CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')
- && x.ClassroomTypeID == weekList[i].ClassroomTypeID
- && x.ClassroomID == weekList[i].ClassroomID
- && x.Times <= weekList[i].Times) {
- x.WeekNums.push(weekList[i].Week);
- }
- });
- }
- var existGroup = $.grep(weekListGroup, function (x) {
- return x.CourseProcessTeacherViewList.length == weekList[i].CourseProcessTeacherViewList.length
- && $.map(x.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(weekList[i].CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')
- && x.ClassroomTypeID == weekList[i].ClassroomTypeID
- && x.ClassroomID == weekList[i].ClassroomID
- && x.Times == weekList[i].Times
- });
- if (existGroup.length == 0) {
- weekListGroup.push({
- CourseProcessTeacherViewList: weekList[i].CourseProcessTeacherViewList,
- ClassroomTypeID: weekList[i].ClassroomTypeID,
- ClassroomTypeName: weekList[i].ClassroomTypeName,
- ClassroomID: weekList[i].ClassroomID,
- ClassroomName: weekList[i].ClassroomName,
- Times: weekList[i].Times,
- TeacherNameColumn: $.map(weekList[i].CourseProcessTeacherViewList, function (x) { return x.Name + '(' + x.TeachingMethodName + ')'; }).join(','),
- WeekNums: [weekList[i].Week]
- });
- }
- }
- $.each(weekListGroup, function (i, x) { x.WeekNumString = getWeekNumString(x.WeekNums); });
- if (weekListGroup.length == 0) {
- $.messager.alert("系统提示", "任务班的周学时已经排满。");
- return;
- }
- if (weekListGroup) {
- if (splitWeeks) {
- if (weekListGroup.length > 1) {
- $.popupTopWindow('选择排课组', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/SelectGroup', 650, 320, preSelectWeek, {
- weekList: weekList,
- weekListGroup: weekListGroup
- });
- } else {
- preSelectWeek({
- weekList: weekList,
- weekListGroup: weekListGroup[0]
- });
- }
- } else {
- if (weekListGroup.length > 1) {
- $.popupTopWindow('选择排课组', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/SelectGroup', 650, 320, selectGroupConfirm, {
- weekList: weekList,
- weekListGroup: weekListGroup
- });
- } else {
- selectGroupConfirm({
- weekList: weekList,
- weekListGroup: weekListGroup[0]
- });
- }
- }
- }
- }
- function selectGroupConfirm(weekListGroupData) {
- if (!weekListGroupData) return;
- var weekday = currentCell.attr("weekday");
- var courseTimeID = currentCell.attr("coursesTimeID");
- weekList = $.grep(weekListGroupData.weekList, function (x) {
- return x.CourseProcessTeacherViewList.length == weekListGroupData.weekListGroup.CourseProcessTeacherViewList.length
- && $.map(x.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(weekListGroupData.weekListGroup.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')
- && x.ClassroomTypeID == weekListGroupData.weekListGroup.ClassroomTypeID
- && x.ClassroomID == weekListGroupData.weekListGroup.ClassroomID
- && x.Times >= weekListGroupData.weekListGroup.Times
- });
- if (!checkWeekTimeOverflowAndSetWeekList(weekList)) {
- resetSelection();
- return;
- }
- checkTeacherIsOnWork(weekday, courseTimeID);
- }
- function isTeacherOverflow(teacherWorkTimeList, weekday) {
- var teacherDayClasses = new Array();
- var isOverflow = false;
- $.each(teacherWorkTimeList, function (i, x) {
- var teacherDayClass = $.grep(teacherDayClasses, function (y) { return y.UserID == x.UserID && y.WeekNum == x.WeekNum; });
- if (teacherDayClass.length == 0) {
- teacherDayClasses.push({
- UserID: x.UserID,
- Name: x.Name,
- WeekNum: x.WeekNum,
- WorkTime: x.WorkTime
- });
- } else {
- $.each(teacherDayClasses, function (o, y) {
- if (y.UserID == x.UserID && y.WeekNum == x.WeekNum) {
- y.WorkTime += x.WorkTime;
- }
- });
- }
- });
- //再循环一次,加入待排课程的上课时间
- var cellworkhours = parseInt(currentCell.attr("workhours"));
- $.each(currentSchedulingWeekList, function (i, x) {
- $.each(x.CourseProcessTeacherViewList, function (n, w) {
- var teacherDayClass = $.grep(teacherDayClasses, function (y) { return y.UserID == w.UserID && y.WeekNum == x.Week; });
- if (teacherDayClass.length == 0) {
- teacherDayClasses.push({
- UserID: w.UserID,
- Name: w.Name,
- WeekNum: x.Week,
- WorkTime: cellworkhours
- });
- } else {
- $.each(teacherDayClasses, function (o, y) {
- if (y.UserID == w.UserID && y.WeekNum == x.Week) {
- y.WorkTime += cellworkhours;
- }
- if (y.WorkTime > teacherScheduleContinuousCount) {
- isOverflow = true;
- }
- });
- }
- });
- });
- return isOverflow;
- }
- function schedulingCellClicked() {
- if ($(event.srcElement).hasClass("scheduleItemTeacherLink")) {
- return;
- }
- if (currentItem != null) {
- currentCell = $(this);
- var weekday = currentCell.attr("weekday");
- var courseTimeID = currentCell.attr("coursesTimeID");
- var allScheduled = $('.schedulingItem[EducationSchedulingClassID=' + currentItem.EducationSchedulingClassID + ']');
- //先看当前时间点是否可以排课
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/Arrangements/IsOnWork', {
- weekday: weekday,
- courseTimeID: courseTimeID
- }, function (data) {
- if (!data) {
- $.messager.alert("系统提示", "该时间点不是工作时间,不能排课,请与校历管理员联系咨询。");
- } else {
- //选教室之前,需要判断是否可以排在这一格
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/IsCourseOnWork', {
- coursematerialID: currentItem.CoursematerialID,
- weekday: weekday,
- courseTimeID: courseTimeID
- }, function (data) {
- if (!data.IsSuccess) {
- $.messager.confirm("系统提示", data.Message + "是否继续将课程排在该节次?", function (r) {
- if (r) {
- getScheduleItemWeekNums(currentItem, allScheduled, false);
- } else {
- resetSelection();
- }
- });
- } else {
- getScheduleItemWeekNums(currentItem, allScheduled, false);
- }
- });
- }
- })
- } else {
- if ($(this).children('.schedulingItem').length == 0) {
- var selectedItems = $('.schedulingItemSelected');
- selectedItems.removeClass('schedulingItemSelected');
- }
- }
- }
- function checkTeacherIsOnWork(weekday, courseTimeID) {
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/IsTeacherOnWork', {
- educationScheduleClassID: currentItem.EducationSchedulingClassID,
- schedulingWeekListStr: JSON.stringify(currentSchedulingWeekList),
- weekday: weekday,
- courseTimeID: courseTimeID
- }, function (data) {
- isContinue = true;
- if (!data.IsSuccess) {
- $.messager.confirm("系统提示", data.Message + "是否继续将课程排在该节次?", function (r) {
- if (r) {
- checkIsBusy(weekday, courseTimeID);
- } else {
- resetSelection();
- }
- });
- } else {
- checkIsBusy(weekday, courseTimeID);
- }
- });
- }
- function checkIsBusy(weekday, courseTimeID) {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/IsEducationSchedulingClassCanAddManualSchedule', {
- educationScheduleClassID: currentItem.EducationSchedulingClassID,
- schedulingWeekListStr: JSON.stringify(currentSchedulingWeekList),
- schoolYearID: schoolYearID,
- weekday: weekday,
- courseTimeID: courseTimeID
- }, function (data) {
- if (data.IsSuccess) {
- checkTeacherWorktimeLimit(schoolYearID, weekday);
- }
- else {
- var reportLink = "";
- if (data.Message.indexOf('教师') >= 0) {
- reportLink += "点击下列链接查看相关教师的课表:<br>";
- $.each(data.Data, function (i, x) {
- reportLink += '<a href="#this" onclick="javascript:popupTeacherReport(\'' + x.Key + '\');" style="color: #0000ff;">';
- reportLink += x.Value + "课表";
- reportLink += "</a> ";
- });
- }
- $.messager.alert("系统提示", data.Message + reportLink);
- resetSelection();
- return;
- }
- });
- }
- function checkTeacherWorktimeLimit(schoolYearID, weekday) {
- //再判断教师连续工作时间、班级连续工作时间是否超限
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/GetTeacherContinuousWorkTime', {
- educationScheduleClassID: currentItem.EducationSchedulingClassID,
- schedulingWeekListStr: JSON.stringify(currentSchedulingWeekList),
- schoolYearID: schoolYearID,
- weekday: weekday
- }, function (teacherWorkTimeList) {
- if (isTeacherOverflow(teacherWorkTimeList, weekday)) {
- var reportLink = "";
- var teacherList = [];
- $.each(teacherWorkTimeList, function (i, x) {
- if (!teacherList.contains(x.UserID)) {
- teacherList.push(x.UserID);
- reportLink += '<a href="#this" onclick="javascript:popupTeacherReport(\'' + x.UserID + '\');" style="color: #0000ff;">';
- reportLink += x.Name + "课表";
- reportLink += "</a> ";
- }
- });
- $.messager.confirm("系统提示", "教师连续工作时间超限,是否继续将课程排在该节次?点击下列链接查看相关教师的课表:<br>" + reportLink, function (r) {
- if (r) {
- checkCourseContinuousLimit(weekday);
- } else {
- resetSelection();
- }
- });
- }
- else {
- checkCourseContinuousLimit(weekday);
- }
- });
- }
- function checkCourseContinuousLimit(weekday) {
- var weekCourseTimes = new Array();
- var currentCellWorkhours = parseInt(currentCell.attr("workhours"));
- var courses = $('.schedulingCell[weekday=' + weekday + '] .schedulingItem');
- $.each(courses, function (i, x) {
- var weekNums = eval($(x).attr("WeeklyNums"));
- var workhours = parseInt($(x).parent().attr("workhours"));
- $.each(weekNums, function (n, w) {
- var isContain = false;
- $.each(weekCourseTimes, function (m, v) {
- if (v.WeekNum == w) {
- isContain = true;
- v.Times += workhours;
- }
- });
- if (isContain == false) {
- weekCourseTimes.push({ WeekNum: w, Times: workhours });
- }
- });
- });
- $.each(currentSchedulingWeekList, function (n, w) {
- var isContain = false;
- $.each(weekCourseTimes, function (m, v) {
- if (v.WeekNum == w.Week) {
- isContain = true;
- v.Times += currentCellWorkhours;
- }
- });
- if (isContain == false) {
- weekCourseTimes.push({ WeekNum: w.Week, Times: currentCellWorkhours });
- }
- });
- if ($.grep(weekCourseTimes, function (x) { return x.Times > classScheduleContinuousCount; }).length > 0) {
- $.messager.confirm("系统提示", "班级连续上课时间超限。是否继续将课程排在该节次?", function (r) {
- if (r) {
- checkCourseScheduleContinuousLimit(weekday);
- } else {
- resetSelection();
- }
- });
- } else {
- checkCourseScheduleContinuousLimit(weekday);
- }
- }
- function checkCourseScheduleContinuousLimit(weekday) {
- var weekCourseTimes = new Array();
- var currentCellWorkhours = parseInt(currentCell.attr("workhours"));
- var courses = $('.schedulingCell[weekday=' + weekday + '] .schedulingItem[CoursematerialID=' + currentItem.CoursematerialID + ']');
- $.each(courses, function (i, x) {
- var weekNums = eval($(x).attr("WeeklyNums"));
- var workhours = parseInt($(x).parent().attr("workhours"));
- var coursematerialID = $(x).attr("CoursematerialID");
- $.each(weekNums, function (n, w) {
- var isContain = false;
- $.each(weekCourseTimes, function (m, v) {
- if (v.WeekNum == w && v.CoursematerialID == coursematerialID) {
- isContain = true;
- v.Times += workhours;
- }
- });
- if (isContain == false) {
- weekCourseTimes.push({ WeekNum: w, CoursematerialID: coursematerialID, Times: workhours });
- }
- });
- });
- $.each(currentSchedulingWeekList, function (n, w) {
- var isContain = false;
- $.each(weekCourseTimes, function (m, v) {
- if (v.WeekNum == w.Week && v.CoursematerialID == currentItem.CoursematerialID) {
- isContain = true;
- v.Times += currentCellWorkhours;
- }
- });
- if (isContain == false) {
- weekCourseTimes.push({ WeekNum: w.Week, CoursematerialID: currentItem.CoursematerialID, Times: currentCellWorkhours });
- }
- });
- if ($.grep(weekCourseTimes, function (x) { return x.Times > classCourseScheduleContinuousCount; }).length > 0) {
- $.messager.confirm("系统提示", "班级连续上同一课程时间超限。是否继续将课程排在该节次?", function (r) {
- if (r) {
- loadClassroom();
- } else {
- resetSelection();
- }
- });
- } else {
- loadClassroom();
- }
- }
- function loadClassroom() {
- var fixClassroomID = currentSchedulingWeekList[0].ClassroomID;
- var fixClassroomName = currentSchedulingWeekList[0].ClassroomName;
- if (fixClassroomID) {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var collegeID = $("#CollegeDropdown").combobox("getValue");
- var schedulingWeekListStr = $.map(currentSchedulingWeekList, function (x) { return x.Week; }).join(',');
- var weekday = currentCell.attr("weekday");
- var courseTimeID = currentCell.attr("coursesTimeID");
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/IsClassroomIsAvailable', {
- collegeID: collegeID,
- schoolYearID: schoolYearID,
- schedulingWeekListStr: schedulingWeekListStr,
- weekday: weekday,
- courseTimeID: courseTimeID,
- classroomID: fixClassroomID
- }, function (data) {
- if (data.IsSuccess) {
- addSchdulingCellItemWithClassroom({ ClassroomID: fixClassroomID, Name: fixClassroomName });
- } else {
- var reportLink = "";
- if (data.Data) {
- reportLink += '点击下列链接查看教室课表:<br>';
- reportLink += '<a href="#this" onclick="javascript:popupClassroomReport(\'' + fixClassroomID + '\');" style="color: #0000ff;">';
- reportLink += fixClassroomName + "课表";
- reportLink += "</a> ";
- }
- $.messager.alert("系统提示", data.Message + reportLink);
- }
- }
- );
- }
- else {
- popupClassroomSelector();
- }
- }
- function drawScheduleContainer(courseTimeData, schedulingData) {
- var container = $('#scheduleContainer');
- drawSchedulingCells(container, courseTimeData);
- drawSchedulingData(container, schedulingData);
- $(".schedulingCell").click(schedulingCellClicked);
- }
- function popupClassroomSelector() {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var collegeID = $("#CollegeDropdown").combobox("getValue");
- var weekday = currentCell.attr("weekday");
- var courseTimeID = currentCell.attr("coursesTimeID");
- var availableClassroomList = $.grep(usedClassroomList, function (x) { return x.weekday == weekday && x.courseTimeID == courseTimeID });
- var classroomTypeID = currentSchedulingWeekList[0].ClassroomTypeID;
- $.popupTopWindow('选择教室', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/Setting', 650, 320, addSchdulingCellItemWithClassroom, {
- schoolYearID: schoolYearID,
- collegeID: collegeID,
- weekday: weekday,
- courseTimeID: courseTimeID,
- classroomTypeID: classroomTypeID,
- studentNum: currentItem.StudentNum,
- schedulingWeekList: $.map(currentSchedulingWeekList, function (x) { return x.Week; }),
- usedClassroomIDList: $.map(availableClassroomList, function (x) { return x.classroomID; })
- });
- }
- function addSchdulingCellItemWithClassroom(classroom) {
- if (classroom) {
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var weekday = currentCell.attr("weekday");
- var courseTimeID = currentCell.attr("coursesTimeID");
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/AddScheduling', {
- schoolYearID: schoolYearID,
- educationSchedulingClassID: currentItem.EducationSchedulingClassID,
- weekListStr: $.map(currentSchedulingWeekList, function (x) { return x.Week }).join(','),
- teacherStr: JSON.stringify(currentSchedulingWeekList[0].CourseProcessTeacherViewList),
- weekday: weekday,
- courseTimeID: courseTimeID,
- classroomID: classroom.ClassroomID
- }, function (data) {
- if (!data.IsSuccess) {
- $.messager.alert("系统提示", "排课失败:" + data.Message);
- }
- else {
- schedulingClassSelectedWeekList[currentItem.EducationSchedulingClassID] = null;
- currentItem = null;
- currentCell = null;
- currentSchedulingWeekList = null;
- usedClassroomList = new Array();
- teacherScheduleContinuousCount = 0;
- classScheduleContinuousCount = 0;
- classCourseScheduleContinuousCount = 0;
- reload();
- // var schedulingItem = {
- // EducationSchedulingClassID: currentItem.EducationSchedulingClassID,
- // TeachingModeName: currentItem.TeachingModeName,
- // CoursematerialID: currentItem.CoursematerialID,
- // CoursematerialName: currentItem.CoursematerialName,
- // ClassroomTypeID: currentItem.ClassroomTypeID,
- // ClassroomID: classroom.ClassroomID,
- // ClassroomName: classroom.Name,
- // WeekNumList: currentSchedulingWeekList,
- // WeeklyNumString: currentItem.WeeklyNumString,
- // TaskGroupName: currentItem.TaskGroupName,
- // TeacherNames: currentItem.TeacherNames,
- // CourseProcessViewList: currentItem.CourseProcessViewList,
- // StudentCount: currentItem.StudentNum
- // };
- // usedClassroomList.push({ weekday: weekday, courseTimeID: courseTimeID, classroomID: classroom.ClassroomID });
- // var listSchedulingClassList = $("#dgEducationSchedulingClassList").cmsXDataTable("getRows");
- // $.each(listSchedulingClassList, function () {
- // if (this.EducationSchedulingClassID == currentItem.EducationSchedulingClassID) {
- // this.RemainCourseTime -= currentSchedulingWeekList.length;
- // }
- // });
- // $("#dgEducationSchedulingClassList").cmsXDataTable("loadData", { rows: listSchedulingClassList, total: listSchedulingClassList.length });
- // var html = drawSchedulingCellItem(currentCell, schedulingItem);
- // resetSelection();
- }
- });
- }
- }
- function resetSelection() {
- currentCell = null;
- currentItem = null;
- currentSchedulingWeekList = null;
- $("#dgEducationSchedulingClassList").find('tr.row>td').removeClass('selectedSchedulingClass');
- }
- function drawSchedulingCells(container, courseTimeData) {
- var html = new Array();
- html.push('<div class="schedulingHeaderCellHeader"></div>');
- html.push('<div class="schedulingHeaderContainer">');
- html.push('<div class="schedulingHeader">');
- html.push('<div class="schedulingHeaderCell">星期一</div>');
- html.push('<div class="schedulingHeaderCell">星期二</div>');
- html.push('<div class="schedulingHeaderCell">星期三</div>');
- html.push('<div class="schedulingHeaderCell">星期四</div>');
- html.push('<div class="schedulingHeaderCell">星期五</div>');
- html.push('<div class="schedulingHeaderCell">星期六</div>');
- html.push('<div class="schedulingHeaderCell">星期日</div>');
- html.push('</div>');
- html.push('</div>');
- var timesSegment = $.map(courseTimeData, function (x) { return x.TimesSegment; }).unique().sort();
- var schedulingCellHeaderContainerHtml = new Array();
- var schedulingCellContainerHtml = new Array();
- schedulingCellHeaderContainerHtml.push('<div class="schedulingCellHeaderContainer">');
- schedulingCellContainerHtml.push('<div class="schedulingCellContainer">');
- $.each(courseTimeData, function () {
- var colorStyleString = '';
- var i;
- for (i = 0; i < timesSegment.length; i++) {
- if (timesSegment[i] == this.TimesSegment) {
- colorStyleString = " " + colorGroup[i % colorGroup.length];
- }
- }
- schedulingCellHeaderContainerHtml.push('<div class="schedulingCellHeader' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '">');
- schedulingCellHeaderContainerHtml.push(this.StartDate + "-" + this.EndDate);
- schedulingCellHeaderContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingRow">');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="1">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="2">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="3">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="4">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="5">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="6">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('<div class="schedulingCell' + colorStyleString + '" coursesTimeID="' + this.CoursesTimeID + '" workhours="' + this.Workhours + '" weekday="0">');
- schedulingCellContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('</div>');
- });
- schedulingCellHeaderContainerHtml.push('</div>');
- schedulingCellContainerHtml.push('</div>')
- html.push("<div>");
- html.push(schedulingCellHeaderContainerHtml.join(''));
- html.push(schedulingCellContainerHtml.join(''));
- html.push("</div>");
- container.html(html.join(''));
- var containerWith = $(document).width() - $("#scheduleContainer").position().left - $(".schedulingCellHeader").width() - 18;
- var containerHeight = $(document).height() - $("#scheduleContainer").position().top - $(".schedulingCellHeader").height();
- var mainContainer = $(".schedulingCellContainer").parent();
- //mainContainer.css("line-height", containerHeight + "px");
- mainContainer.height(containerHeight);
- $(".schedulingCellHeaderContainer").width($(".schedulingCellHeader").width() + 2);
- $(".schedulingCellHeaderContainer").height(containerHeight);
- $(".schedulingHeaderContainer").width(containerWith);
- $(".schedulingHeaderContainer").css("margin-left", "100px");
- $(".schedulingRow").width($(".schedulingHeader").width() - 16);
- $(".schedulingCellContainer").width(containerWith);
- $(".schedulingCellContainer").height(containerHeight);
- $(".schedulingCellContainer").css("margin-left", ($(".schedulingCellHeader").width() + 2) + "px");
- $(".schedulingCellContainer").scroll(function () {
- $(".schedulingHeaderContainer").scrollLeft($(".schedulingCellContainer").scrollLeft());
- $(".schedulingCellHeaderContainer").scrollTop($(".schedulingCellContainer").scrollTop());
- });
- }
- function drawSchedulingData(container, schedulingData) {
- $.each(schedulingData, function () {
- var queryString = '.schedulingCell';
- queryString += '[coursesTimeID="' + this.CoursesTimeID + '"]';
- queryString += '[weekday="' + this.Weekday + '"]';
- var currentCell = container.find(queryString);
- drawSchedulingCellItem(currentCell, this);
- });
- }
- function drawSchedulingCellItem(cell, schedulingItem) {
- var html = new Array();
- var itemCount = cell.children('.schedulingItem').length;
- var eachWidth = cell.width() / (itemCount + 1);
- var tooltip = "";
- var text = "";
- var availableSchedulingClass = $("#dgEducationSchedulingClassList").cmsXDataTable("getRows");
- var isAvailable = true;
- if ($.grep(availableSchedulingClass, function (x) { return x.EducationSchedulingClassID == schedulingItem.EducationSchedulingClassID; }).length == 0) {
- isAvailable = false;
- }
- if (!schedulingItem.IsCanEdit) {
- isAvailable = false;
- }
- cell.children('.schedulingItem').width(eachWidth);
- html.push(cell.html());
- html.push('<div class="schedulingItem');
- if (!isAvailable) {
- html.push(' disabledItem');
- }
- html.push('" style="width: ' + eachWidth + 'px;" ClassroomID="' + schedulingItem.ClassroomID
- + '" ClassroomTypeID="' + schedulingItem.ClassroomTypeID
- + '" EducationSchedulingID="' + schedulingItem.EducationSchedulingID
- + '" CoursematerialID="' + schedulingItem.CoursematerialID
- + '" EducationSchedulingClassID="' + schedulingItem.EducationSchedulingClassID
- + '" WeeklyNums = "' + JSON.stringify(schedulingItem.WeekNumList)
- + '" StudentCount = "' + schedulingItem.StudentCount
- + '" TeachingModeID="' + schedulingItem.TeachingModeID
- + '" TeacherTeachingViewList="' + escape(JSON.stringify(schedulingItem.TeacherTeachingViewList))
- + '">');
- if (!schedulingItem.TeachingModeName || schedulingItem.TeachingModeName == "") {
- tooltip += schedulingItem.CoursematerialName;
- } else {
- tooltip += '【' + schedulingItem.TeachingModeName + '】' + schedulingItem.CoursematerialName;
- }
- tooltip += '(' + schedulingItem.TaskGroupName + ')';
- tooltip += '<br>';
- text = tooltip;
- if (schedulingItem.ClassroomName) {
- text += '<a href="#this" style="color: #0000ff" class="scheduleItemClassroomLink" onclick=showClassroomScheduleView("' + schedulingItem.ClassroomID + '");>'
- text += schedulingItem.ClassroomName;
- text += '</a>'
- tooltip += schedulingItem.ClassroomName;
- }
- text += ',';
- tooltip += ',';
- text += schedulingItem.WeeklyNumString;
- tooltip += schedulingItem.WeeklyNumString;
- text += '<br>';
- tooltip += '<br>';
- if (schedulingItem.TeacherNames) {
- tooltip += schedulingItem.TeacherNames;
- text += schedulingItem.TeracherNamesWithLink;
- }
- html.push('<div title="' + tooltip.replace(/<br>/g, " ") + '" class="schedulingItemTitle">');
- html.push(text);
- html.push('</div>');
- html.push('</div>');
- cell.html(html.join(''));
- setSchedulingItemUsed(schedulingItem);
- cell.children('.schedulingItem:not(.disabledItem)').click(function () {
- selectScheduleItem($(this));
- });
- cell.children('.schedulingItem').on('contextmenu', function (e) {
- e.preventDefault();
- var isDisable = false;
- if ($(this).hasClass('disabledItem')) {
- isDisable = true;
- }
- if (!isDisable) {
- selectScheduleItem($(this));
- } else {
- var selectedItems = $('.schedulingItemSelected');
- selectedItems.removeClass('schedulingItemSelected');
- }
- $("#popupMenu").css('display', 'block');
- if (!isDisable) {
- $("#popupMenu div:not(.commonMenu)").css('display', 'block');
- } else {
- $("#popupMenu div:not(.commonMenu)").css('display', 'none');
- }
- $("#popupMenu").offset({
- left: e.pageX,
- top: e.pageY
- });
- });
- }
- function selectScheduleItem(scheduleItem) {
- if ($(event.srcElement).hasClass("scheduleItemTeacherLink")) {
- return;
- }
- if ($(event.srcElement).hasClass("scheduleItemClassroomLink")) {
- return;
- }
- if (currentItem != null) return;
- var selectedItems = $('.schedulingItemSelected');
- selectedItems.removeClass('schedulingItemSelected');
- scheduleItem.addClass('schedulingItemSelected');
- }
- function setSchedulingItemUsed(schedulingItem) {
- var data = $("#dgEducationSchedulingClassList").cmsXDataTable("options").data.rows;
- var i;
- var allScheduled = $('.schedulingItem[EducationSchedulingClassID=' + schedulingItem.EducationSchedulingClassID + ']');
- var remainWeekNum = $.map(getScheduledItemRemainWeekNums(schedulingItem, allScheduled), function (x) { return x.Week });
- for (i = 0; i < data.length; i++) {
- if (data[i].EducationSchedulingClassID == schedulingItem.EducationSchedulingClassID) {
- if (remainWeekNum.length == 0) {
- $("#dgEducationSchedulingClassList").find('tr.row[xRowIndex=' + i + ']>td').addClass('finishedSchedulingClass');
- } else {
- $("#dgEducationSchedulingClassList").find('tr.row[xRowIndex=' + i + ']>td').addClass('usedSchedulingClass');
- }
- return;
- }
- }
- }
- function clearSchedulingItemUsed(schedulingItem) {
- var usedCells = $('.schedulingItem[EducationSchedulingClassID=' + schedulingItem.EducationSchedulingClassID + ']');
- var data = $("#dgEducationSchedulingClassList").cmsXDataTable("options").data.rows;
- var i;
- for (i = 0; i < data.length; i++) {
- if (data[i].EducationSchedulingClassID == schedulingItem.EducationSchedulingClassID) {
- $("#dgEducationSchedulingClassList").find('tr.row[xRowIndex=' + i + ']>td').removeClass('finishedSchedulingClass');
- if (usedCells.length == 0) {
- $("#dgEducationSchedulingClassList").find('tr.row[xRowIndex=' + i + ']>td').removeClass('usedSchedulingClass');
- }
- return;
- }
- }
- }
- function selectItem(rowIndex, rowData) {
- if (rowData.IsCanEdit) {
- if (currentItem != null && currentItem.EducationSchedulingClassID == rowData.EducationSchedulingClassID) {
- resetSelection();
- } else {
- $(this).find('tr.row>td').removeClass('selectedSchedulingClass');
- $(this).find('tr.row[xRowIndex=' + rowIndex + ']>td').addClass('selectedSchedulingClass');
- currentItem = rowData;
- }
- }
- }
- function EducationScheduling_Close() {
- top.$('#' + windowID).window('close');
- }
- function EducationScheduling_WeekModify() {
- var selectedItems = $('.schedulingItemSelected');
- if (selectedItems.length > 1) {
- $.messager.alert("系统提示", "不能同时操作多条记录。");
- return;
- }
- var educationSchedulingID = selectedItems.attr("EducationSchedulingID");
- var weekNums = eval(selectedItems.attr("WeeklyNums"));
- $.popupTopWindow('编辑上课周次', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/WeekModify', 200, 500, popupClose, {
- EducationSchedulingID: educationSchedulingID,
- WeeklyNums: weekNums
- });
- }
- function popupClose() {
- if (top.$.data(this, "isSuccess")) {
- top.$.data(this, "isSuccess", false)
- reload();
- }
- }
- function EducationScheduling_ModifyTeacher() {
- var selectedItems = $('.schedulingItemSelected');
- if (selectedItems.length == 0) {
- $.messager.alert("系统提示", "请选择需要修改的排课记录。");
- return;
- }
- if (selectedItems.length > 1) {
- $.messager.alert("系统提示", "不能同时操作多条记录。");
- return;
- }
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var educationSchedulingID = selectedItems.attr('EducationSchedulingID');
- var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/EducationSchedule/SetTeacher?EducationSchedulingID=" + educationSchedulingID
- + "&SchoolYearID=" + schoolYearID;
- $.popupTopWindow('设置教师', redirectTo, 800, 300, popupClose, null);
- }
- function EducationScheduling_ModifyClassroom() {
- var selectedItems = $('.schedulingItemSelected');
- if (selectedItems.length == 0) {
- $.messager.alert("系统提示", "请选择需要修改的排课记录。");
- return;
- }
- if (selectedItems.length > 1) {
- $.messager.alert("系统提示", "不能同时操作多条记录。");
- return;
- }
- var cell = selectedItems.parent(".schedulingCell");
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var collegeID = $("#CollegeDropdown").combobox("getValue");
- var weekday = cell.attr("weekday");
- var courseTimeID = cell.attr("coursesTimeID");
- var classroomTypeID = selectedItems.attr("ClassroomTypeID");
- var studentCount = selectedItems.attr("StudentCount");
- var availableClassroomList = $.grep(usedClassroomList, function (x) { return x.weekday == weekday && x.courseTimeID == courseTimeID });
- var weekNums = eval(selectedItems.attr("WeeklyNums"));
- var courseTimeID = cell.attr("coursesTimeID");
- $.popupTopWindow('选择教室', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/Setting', 650, 320, modifyClassroom, {
- schoolYearID: schoolYearID,
- collegeID: collegeID,
- weekday: weekday,
- courseTimeID: courseTimeID,
- classroomTypeID: classroomTypeID,
- studentNum: studentCount,
- schedulingWeekList: weekNums,
- usedClassroomIDList: $.map(availableClassroomList, function (x) { return x.classroomID; })
- });
- }
- function modifyClassroom(classroom) {
- if (classroom) {
- var selectedItems = $('.schedulingItemSelected');
- var classroomID = classroom.ClassroomID;
- var educationSchedulingID = selectedItems.attr('EducationSchedulingID');
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/ChangeClassroom', { educationSchedulingID: educationSchedulingID, classroomID: classroomID }, function (data) {
- if (!data.IsSuccess) {
- $.messager.alert("系统提示", "修改教室失败:" + data.Message);
- }
- else {
- reload();
- }
- });
- }
- }
- function EducationScheduling_DeleteItem() {
- var selectedItems = $('.schedulingItemSelected');
- $.each(selectedItems, function (i, w) {
- var cell = $(w).parent();
- var itemCount = cell.children('.schedulingItem').length;
- var eachWidth = cell.width() / (itemCount - 1);
- var weekday = cell.attr("weekday");
- var courseTimeID = selectedItems.parent().attr("coursesTimeID");
- var workhours = parseInt(selectedItems.parent().attr("workhours"));
- var schoolYearID = $("#SchoolYearDropdown").combobox("getValue");
- var weekNums = eval($(w).attr("WeeklyNums"));
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/DelScheduling', {
- educationSchedulingID: $(w).attr('EducationSchedulingID')
- }, function (data) {
- if (!data.IsSuccess) {
- $.messager.alert("系统提示", "删除失败:" + data.Message);
- }
- else {
- usedClassroomList = $.grep(usedClassroomList, function (x) {
- return !(x.weekday == weekday && x.courseTimeID == courseTimeID && x.classroomID == $(w).attr("ClassroomID"));
- });
- cell.children('.schedulingItem').width(eachWidth);
- var classdata = $("#dgEducationSchedulingClassList").cmsXDataTable("options").data.rows;
- var schedulingItem = $.grep(classdata, function (v) { return v.EducationSchedulingClassID == $(w).attr('EducationSchedulingClassID'); });
- $(w).remove();
- if (schedulingItem.length > 0) {
- var listSchedulingClassList = $("#dgEducationSchedulingClassList").cmsXDataTable("getRows");
- $.each(listSchedulingClassList, function () {
- if (this.EducationSchedulingClassID == schedulingItem[0].EducationSchedulingClassID) {
- this.RemainCourseTime += weekNums.length * workhours;
- }
- });
- $("#dgEducationSchedulingClassList").cmsXDataTable("loadData", { rows: listSchedulingClassList, total: listSchedulingClassList.length });
- clearSchedulingItemUsed(schedulingItem[0]);
- }
- }
- });
- });
- }
- function isScheduleEnable(rowIndex, rowData) {
- if (!rowData.IsCanEdit) {
- var rowObj = $("#dgEducationSchedulingClassList").find('tr.row[xRowIndex=' + rowIndex + ']');
- return "color: #cccccc;";
- } else {
- return "";
- }
- }
- function EducationSchedulingClass_SelectWeeks(rowIndex, rowData) {
- if (rowData.IsCanEdit) {
- $("#dgEducationSchedulingClassList").find('tr.row>td').removeClass('selectedSchedulingClass');
- $("#dgEducationSchedulingClassList").find('tr.row[xRowIndex=' + rowIndex + ']>td').addClass('selectedSchedulingClass');
- currentItem = rowData;
- }
- var allScheduled = $('.schedulingItem[EducationSchedulingClassID=' + currentItem.EducationSchedulingClassID + ']');
- getScheduleItemWeekNums(rowData, allScheduled, true);
- }
- function preSelectWeek(weekListGroupData) {
- if (!weekListGroupData) return;
- var selectedWeekList = $.grep(weekListGroupData.weekList, function (x) {
- return x.CourseProcessTeacherViewList.length == weekListGroupData.weekListGroup.CourseProcessTeacherViewList.length
- && $.map(x.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',') == $.map(weekListGroupData.weekListGroup.CourseProcessTeacherViewList, function (w) { return w.UserID + '|' + w.TeachingMethod.toString(); }).join(',')
- && x.ClassroomTypeID == weekListGroupData.weekListGroup.ClassroomTypeID
- && x.ClassroomID == weekListGroupData.weekListGroup.ClassroomID
- && x.Times >= weekListGroupData.weekListGroup.Times
- })
- var selectedWeekNumList = $.map(selectedWeekList, function (x) { return x.Week; });
- $.popupTopWindow('选择周次', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/PreSelectWeeks', 200, 500, preSelectWeekConfirm, selectedWeekNumList);
- }
- function preSelectWeekConfirm(selectedWeekList) {
- schedulingClassSelectedWeekList[currentItem.EducationSchedulingClassID] = selectedWeekList;
- }
- (function ($) {
- $('.easyui-menu').menu('hide');
- $(document).keydown(function (e) {
- if (e.keyCode == 46) {
- EducationScheduling_DeleteItem();
- }
- });
- $(document).on('contextmenu', function (e) {
- $("#popupMenu").css('display', 'block');
- if ($(e.srcElement).parent().hasClass("row") && !$(e.srcElement).hasClass("finishedSchedulingClass")) {
- var rowIndex = parseInt($(e.srcElement).parent().attr("xRowIndex"));
- var rowData = $("#dgEducationSchedulingClassList").cmsXDataTable("getRows")[rowIndex];
- if (rowData.IsCanEdit) {
- $("#popupMenu div").css('display', 'none');
- $("#popupMenu div.schedulingClassMenu").css('display', 'block');
- $("#popupMenu div.commonMenu").css('display', 'block');
- $("#popupMenu div.editWeek").unbind();
- $("#popupMenu div.editWeek").click(function () {
- EducationSchedulingClass_SelectWeeks(rowIndex, rowData);
- $('#popupMenu').css('display', 'none');
- });
- } else {
- $("#popupMenu div:not(.commonMenu)").css('display', 'none');
- }
- $("#popupMenu").offset({
- left: e.pageX,
- top: e.pageY
- });
- } else if (!$(e.srcElement).parents().hasClass('schedulingItem') && !$(e.srcElement).parents().hasClass("row") && !$(e.srcElement).hasClass('scheduleMenu')) {
- $("#popupMenu div:not(.commonMenu)").css('display', 'none');
- $("#popupMenu").offset({
- left: e.pageX,
- top: e.pageY
- });
- } else {
- $("#popupMenu div.schedulingClassMenu").css('display', 'none');
- $("#popupMenu").offset({
- left: e.pageX,
- top: e.pageY
- });
- }
- e.preventDefault();
- });
- $(document).click(function () {
- $("#popupMenu").css('display', 'none');
- });
- })(jQuery);
|