var url = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Edit"; var mnu = ""; //加载 $(function () { mnu = $.SystemGeneral.getUrlParam("MNU"); }) function typevalidChoose() { var d = []; $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) { d.push(this.SelectCourseType); }); return d; } function statusValidChoose() { var d = []; $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) { d.push(this.RecordStatusCode); }); return d; } //获取选中的数据 function validChoose() { var d = []; $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) { d.push(this.ID); }); return d; } function teachingvalidChoose() { var d = []; $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) { d.push(this.TeacherName); }); return d; } function classroomvalidChoose() { var d = []; $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) { d.push(this.ClassroomName); }); return d; } function validTeacherChoose() { var d = []; $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) { d.push(this); }); return d; } function reload() { $("#dgSelectCourseResultList").cmsXDataTable("load", $.getDataGridParams("dgSelectCourseResultList")); } //学生名单 function StudentList(rowindex, rowdata) { var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/StudentList?ID=" + rowdata.ID + "&Type=" + rowdata.SelectCourseType + "&MNU=" + mnu; //var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Student"; $.popupTopWindow('学生名单', redirectTo, 800, 550, null, null); } //修改教师 function addTeachers() { var d = validChoose(); var t = typevalidChoose(); if (d == "") { $.messager.alert("系统信息", "请选择单个记录。"); return; } if (d.length > 1) { $.messager.alert("系统信息", "只能选择单个记录进行修改。"); return; } if (t == 0) { var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Edit?ID=" + d + "&Type=" + t + "&MNU=" + mnu; $.popupTopWindow('修改教师', redirectTo, 750, 550, null, null); } else if (t == 1) { var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/EditFreeSelection?ID=" + d + "&Type=" + t + "&MNU=" + mnu; $.popupTopWindow('修改教师', redirectTo, 750, 550, null, null); } } //弹出添加教师页面 function SelectCourseResult_AddTeacher() { $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/Common/TeacherSelect?FromMNU=' + mnu, 650, 480, AddTeachers_Confirm); } function SelectCourseResult_Save() { $(document.forms[0]).submit(); } function AddTeachers_Confirm(teacherList) { if (!teacherList) return; var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows"); $.each(teacherList, function (index, value) { if ($.grep(teacherViewList, function (row, index) { return value.UserID == row.UserID; }).length == 0) { teacherViewList.push({ ExecutableOptionalCourseID: $("#ExecutableOptionalCourseID").val(), ExecutableFreeSelectionCouseID: $("#ExecutableFreeSelectionCouseID").val(), UserID: value.UserID, LoginID: value.StaffCode, Name: value.Name, CollegeID: value.CollegeID, CollegeName: value.CollegeName, BirthDate: value.BirthDate, TeacherType: value.TeacherType, TeacherTypeName: value.TeacherTypeName, IncumbencyState: value.IncumbencyState, IncumbencyStateName: value.IncumbencyStateName, Title: value.Title, TitleName: value.TitleName, TeachingMethod: null, TeachingMethodDesc: null }); } }); $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length }); } function SelectCourseResult_DelTeacher() { var d = validTeacherChoose(); var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows"); var i, j; var len = teacherViewList.length; for (i = len - 1; i >= 0; i--) { for (j = 0; j < d.length; j++) { if (teacherViewList[i].UserID == d[j].UserID) { teacherViewList.splice(i, 1); break; } } } $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length }); } //开班 function AddMission() { var d = validChoose().join(','); var t = typevalidChoose().join(','); var teacher = teachingvalidChoose().join(','); var classroom = classroomvalidChoose().join(','); var status = statusValidChoose().join(','); var teacherStr = ""; var classroomStr = ""; if (d.length == 0) { $.messager.alert("系统提示", "请选择您要进行开班的任务班信息。"); return; } for (var i = 0; i < teacher.split(',').length; i++) { if (teacher.split(',')[i] == null || teacher.split(',')[i] == "") { teacherStr = "检测到选中的数据授课老师为空,是否继续开班?"; // $.messager.confirm("系统提示", "检测到选中的数据授课老师为空,是否继续开班?", function (r) { // if (r) { // submitTeachingPlan(d, t.split(',')[0]); // } // else { // return; // } // }); } } for (var i = 0; i < classroom.split(',').length; i++) { if (classroom.split(',')[i] == null || classroom.split(',')[i] == "") { classroomStr = "检测到选中的数据教室为空,是否继续开班?"; // $.messager.confirm("系统提示", "检测到选中的数据教室为空,是否继续开班?", function (r) { // if (r) { // submitTeachingPlan(d, t.split(',')[0]); // } // else { // return; // } // }); } } // for (var i = 0; i < status.split(',').length; i++) { // if (status.split(',')[i].trim() != opened && status.split(',')[i].trim() != cancleCreate) { // $.messager.alert("系统提示", "只能对“已开放”状态的数据进行开班,请核查!"); // return; // } // } $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/SelectCourseResult/CheckEnouthNum', { IDs: d }, function (data) { if (data.IsSuccess) { if (data.Data) { $.messager.defaults = { ok: "继续开班", cancel: "不开班" }; $.messager.confirm("选择提示", "检测到选中的选修学生人数未达到人数下限,是否继续开班?", function (r) { if (r) { submitTeachingPlan(d, t.split(',')[0]); } else { return; } }); $.messager.defaults = { ok: "确定", cancel: "取消" }; } else if (teacherStr != "") { $.messager.confirm("系统提示", teacherStr, function (r) { if (r) { submitTeachingPlan(d, t.split(',')[0]); } else { return; } }); } else if (classroomStr != "") { $.messager.confirm("系统提示", classroomStr, function (r) { if (r) { submitTeachingPlan(d, t.split(',')[0]); } else { return; } }); } else { submitTeachingPlan(d, t.split(',')[0]); } } else submitTeachingPlan(d, t.split(',')[0]); }); } //导出 function Export() { $(document.forms[0]).submit(); } function submitTeachingPlan(teachingPlanIDs, Types) { $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/SelectCourseResult/GenerateEducationMissionClassSubminit', { teachingPlanIDs: teachingPlanIDs, Types: Types }, function (data) { if (data.IsSuccess == true) { $("#dgSelectCourseResultList").cmsXDataTable('load'); } $.messager.alert("系统提示", data.Message); }); } //院系所 function SelectCollegeComboGrid() { reload(); } //取消开班 function CancelMission() { var d = validChoose().join(','); var status = statusValidChoose().join(','); if (d.length == 0) { $.messager.alert("系统提示", "请选择您要进行开班的任务班信息。"); return; } for (var i = 0; i < status.split(',').length; i++) { if (status.split(',')[i].trim() != opened) { $.messager.alert("系统提示", "只能对“已开放”状态的数据进行取消开班,请核查!"); return; } } $.messager.confirm("系统提示", "您确定要取消开班吗?", function (r) { if (r) { $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/SelectCourseResult/CancelEducationMissionClass', { teachingPlanIDs: d }, function (data) { if (data == "取消开班成功!") { $.messager.alert("系统提示", data); $("#dgSelectCourseResultList").cmsXDataTable('load'); } else { $.messager.alert("系统提示", data); } }); } }); }