var mnu = ""; var selectedCourse; var selectedMissionClass; var selectedWeekNum; var selectedWeekday; var selectedCourseTimes; var selectedClassroom; //加载 $(function () { mnu = $.SystemGeneral.getUrlParam("MNU"); }) function reload() { try { if ($("#cgbTeacher").combogridX("getValue") != "") { var opts = $("#dgEducationSchedulingList").cmsXDataTable("options"); var formData = $.getDataGridParams("dgEducationSchedulingList"); selectedCourse = $("[comboname='cgbCoursematerial']").combogridX("getValue"); selectedMissionClass = $("[comboname='cgbEducationMissionClass']").combogridX("getValue"); selectedWeekNum = $("[comboname='ddlWeekNum']").combobox("getValue"); selectedWeekday = $("[comboname='ddlWeekDay']").combobox("getValue"); selectedCourseTimes = $("[comboname='ddlCourseTimes']").combobox("getValue"); selectedClassroom = $("[comboname='cgbClassroom']").combogridX("getValue"); if (selectedCourse == "") selectedCourse = nonSelect; if (selectedMissionClass == "") selectedMissionClass = nonSelect; if (selectedWeekNum == "") selectedWeekNum = nonSelect; if (selectedWeekday == "") selectedWeekday = nonSelect; if (selectedCourseTimes == "") selectedCourseTimes = nonSelect; if (selectedClassroom == "") selectedClassroom = nonSelect; opts.queryParams = formData || opts.queryParams; $.postWithLoading(opts.url, formData, function (data) { data = $.extend({}, { total: 0, rows: [] }, data); var bindData = [].concat(data.rows); bindCourseList(bindData); bindEducationMissionClassList(bindData); bindWeekNum(bindData); bindWeekday(bindData); bindCourseTimes(bindData); bindClassroom(bindData); $("#dgEducationSchedulingList").cmsXDataTable("loadData", data); }); } } catch (e) { } } function addAllItem(data) { var allItem = [{ Text: "全部", Value: nonSelect}]; return allItem.concat(data); } function bindCourseList(data) { var courseList = $.map(data, function (x) { return { CoursematerialID: x.CoursematerialID, CourseCode: x.CourseCode, CourseName: x.CourseName }; }).uniqueObj(function (x) { return x.CoursematerialID }) .sort(function (a, b) { if (a.CourseCode < b.CourseCode) return -1; if (a.CourseCode > b.CourseCode) return 1; return 0; }); $("[comboname='cgbCoursematerial']").combogridX("loadData", { total: courseList.length, rows: courseList }); $("[comboname='cgbCoursematerial']").combogridX("setValue", selectedCourse); } function bindEducationMissionClassList(data) { var missionClassList = $.map(data, function (x) { return { EducationMissionClassID: x.EducationMissionClassID, EducationMissionClassName: x.EducationMissionClassName }; }).uniqueObj(function (x) { return x.EducationMissionClassID }) .sort(function (a, b) { if (a.EducationMissionClassName < b.EducationMissionClassName) return -1; if (a.EducationMissionClassName > b.EducationMissionClassName) return 1; return 0; }); $("[comboname='cgbEducationMissionClass']").combogridX("loadData", { total: missionClassList.length, rows: missionClassList }); $("[comboname='cgbEducationMissionClass']").combogridX("setValue", selectedMissionClass); } function bindWeekNum(data) { var weekNumList = $.map(data, function (x) { return { Text: x.WeekNum.toString(), Value: x.WeekNum.toString() }; }).uniqueObj(function (x) { return x.Value }) .sort(function (a, b) { return parseInt(a.Value) - parseInt(b.Value) }); $("[comboname='ddlWeekNum']").combobox("loadData", addAllItem(weekNumList)); $("[comboname='ddlWeekNum']").combobox("setValue", selectedWeekNum); } function bindWeekday(data) { var weekdayList = $.map(data, function (x) { return { Value: x.Weekday, Text: x.WeekdayDesc }; }).uniqueObj(function (x) { return x.Value }) .sort(function (a, b) { return parseInt(a.Value) - parseInt(b.Value) }); $("[comboname='ddlWeekDay']").combobox("loadData", addAllItem(weekdayList)); $("[comboname='ddlWeekDay']").combobox("setValue", selectedWeekday); } function bindCourseTimes(data) { var courseTimesList = $.map(data.sort(function (a, b) { return a.StartHour - b.StartHour }), function (x) { return { Value: x.CoursesTimeID, Text: x.CoursesTimeName }; }).uniqueObj(function (x) { return x.Value }); $("[comboname='ddlCourseTimes']").combobox("loadData", addAllItem(courseTimesList)); $("[comboname='ddlCourseTimes']").combobox("setValue", selectedCourseTimes); } function bindClassroom(data) { var classroomList = $.map(data, function (x) { return { ClassroomID: x.ClassroomID, ClassroomName: x.ClassroomName }; }).uniqueObj(function (x) { return x.ClassroomID }) .sort(function (a, b) { if (a.ClassroomName < b.ClassroomName) return -1; if (a.ClassroomName > b.ClassroomName) return 1; return 0; }); $("[name='cgbClassroom']").combogridX("loadData", { total: classroomList.length, rows: classroomList }); $("[comboname='cgbClassroom']").combogridX("setValue", selectedClassroom); } function validChoose() { var d = []; $.each($("#dgEducationSchedulingList").cmsXDataTable("getSelections"), function (index) { d.push(this); }); return d; } function EducationScheduleAdjustment_Add() { var d = validChoose(); if (d.length == 0) { $.messager.alert("系统提示", "请选择需要调整的排课。"); return false; } if (d.length > 1) { $.messager.alert("系统提示", "只能选择单个记录进行调课,如需批量,请操作【批量调课】按钮。"); return false; } $.popupTopWindow('课时调整', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/AdjustmentEdit?EducationSchedulingWeekNumID=' + d[0].EducationSchedulingWeekNumID + "&UserID=" + $("#cgbTeacher").combogridX("getValue") + "&MNU=" + mnu, 800, 420, reload, null); } function EducationScheduleAdjustment_BatchAdd() { var d = validChoose(); if (d.length == 0) { $.messager.alert("系统提示", "请选择需要调整的排课。"); return false; } var classroomTypeID = d[0].ClassroomTypeID; var educationSchedulingWeekNumIDs = $.map(d, function (x) { return x.EducationSchedulingWeekNumID }).join(','); $.popupTopWindow('批量调课', CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedule/AdjustmentBatchEdit?MNU=' + mnu, 400, 320, EducationScheduleAdjustment_BatchAdd_Confirm, { classroomTypeID: classroomTypeID, educationSchedulingWeekNumIDs: educationSchedulingWeekNumIDs }); } function EducationScheduleAdjustment_BatchAdd_Confirm(data) { if (data) { var d = validChoose(); var fromUserID = $("#cgbTeacher").combogridX("getValue"); var toWeekNum = data.WeekNum; var toWeekday = data.Weekday; var toUserID = data.User; var toCoursesTimeID = data.CoursesTime; var toClassroomType = data.ClassroomType; var toClassroom = data.Classroom; if (toWeekNum == "" || toWeekNum == nonSelect) { toWeekNum = null; } if (toWeekday == "" || toWeekday == nonSelect) { toWeekday = null; } if (toUserID == "" || toUserID == nonSelect) { toUserID = null; } if (toCoursesTimeID == "" || toCoursesTimeID == nonSelect) { toCoursesTimeID = null; } if (toClassroomType == "" || toClassroomType == nonSelect) { toClassroomType = null; } if (toClassroom == "" || toClassroom == nonSelect) { toClassroom = null; } var formData = { educationSchedulingWeekNumIDs: $.map(d, function (x) { return x.EducationSchedulingWeekNumID }).join(','), fromUserID: fromUserID, toWeekNum: toWeekNum, toWeekday: toWeekday, toUserID: toUserID, toCoursesTimeID: toCoursesTimeID, toClassroomType: toClassroomType, toClassroom: toClassroom }; $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + "/EducationSchedule/AdjustmentBatchEdit", formData, function (data) { $.messager.alert("系统提示", data.Message.replace(/;/g, '
')); if (data.IsSuccess) { reload(); } }); } }