123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- var examinationPlanID;
- var examinationRoomLayoutID;
- var availableSeatCount;
- var totalSeat;
- var rowCount;
- var columnCount;
- $(function () {
- examinationPlanID = $.SystemGeneral.getUrlParam("ExaminationPlanID");
- examinationRoomLayoutID = $.SystemGeneral.getUrlParam("ExaminationRoomLayoutID");
- });
- function ExaminationPlan_ClassroomLayoutSave() {
- // if (!calculateSeatCount()) {
- // return;
- // }
- // var curStudentCount = $("#dgStudent").cmsXDataTable("getRows").length;
- // if (availableSeatCount < curStudentCount) {
- // $.messager.alert("系统提示", "教室只能容纳" + availableSeatCount + "人,目前选中了" + curStudentCount + "个学生,请先删除多出的学生后再保存。");
- // return;
- // } else {
- // $(document.forms[0]).submit();
- // }
- $(document.forms[0]).submit();
- var d = [];
- var windowID = $.SystemGeneral.getUrlParam("WindowID");
- var maxSelect = $.SystemGeneral.getUrlParam("MaxSelect");
- if (!maxSelect || isNaN(maxSelect)) maxSelect = 0;
- if (d.length == 0) {
- $.messager.alert("系统提示", "请选择教师。");
- return;
- }
- if (maxSelect > 0 && d.length > maxSelect) {
- $.messager.alert("系统提示", "只能选择" + maxSelect + "项记录。");
- return;
- }
- top.$("#" + windowID).data("resultData", d);
- top.$("#" + windowID).dialog("close");
- }
- function ExaminationPlan_TeacherAdd() {
- var classroomID = $("#ClassroomID").combogridX("getValue");
- if (classroomID == "" || classroomID == nonSelect) {
- $.messager.alert("系统提示", "请先选择考场再选择监考老师。");
- return;
- }
- $.popupTopWindow('新增监考老师', CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationTeacher/ExaminationAddTeacherSelect?classroomID=' + classroomID, 800, 600, ExaminationPlan_TeacherAdd_Confirm);
- }
- function ExaminationPlan_TeacherAdd_Confirm(teacherList) {
- if (!teacherList) return;
- var examinationTeacherList = $("#dgRoomTeacher").cmsXDataTable("getRows");
- $.each(teacherList, function () {
- var curUserID = this.UserID;
- if ($.grep(examinationTeacherList, function (x) { return x.UserID == curUserID }).length == 0) {
- examinationTeacherList.push(this);
- }
- });
- $("#dgRoomTeacher").cmsXDataTable("loadData", { rows: examinationTeacherList, total: examinationTeacherList.length });
- }
- //获取选中的数据
- function validChooseTeacher() {
- var d = [];
- $.each($("#dgRoomTeacher").cmsXDataTable("getSelections"), function (index) {
- d.push(this.UserID);
- });
- return d;
- }
- function validChooseStudent() {
- var d = [];
- $.each($("#dgStudent").cmsXDataTable("getSelections"), function (index) {
- d.push(this.UserID);
- });
- return d;
- }
- function ExaminationPlan_TeacherDelete() {
- var d = validChooseTeacher();
- var teacherViewList = $("#dgRoomTeacher").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]) {
- teacherViewList.splice(i, 1);
- break;
- }
- }
- }
- $("#dgRoomTeacher").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
- }
- function ClassroomSelected(data) {
- totalSeat = data.Totalseating;
- rowCount = data.RowCout;
- columnCount = data.ColumnCount;
- availableSeatCount = data.RemainSeatCount;
- }
- function Classroom_LoadSuccess(data) {
- var classroomID = $("#ClassroomID").combogridX("options").value;
- var curClassroom = $.grep(data.rows, function (x) { return x.ClassroomID == classroomID; });
- if (curClassroom.length > 0) {
- ClassroomSelected(curClassroom[0]);
- }
- }
- function calculateSeatCount() {
- if (!$(document.forms[0]).valid()) return false;
- if (!rowCount || !columnCount) {
- $.messager.alert("系统提示", "选中的教室还没有设置正确的行列数,请通知负责教室管理的老师进行设置。");
- return false;
- }
- var rowSpacing = parseFloat($("input[name='RowSpacing']").val());
- var columnSpacing = parseFloat($("input[name='ColumnSpacing']").val());
- //availableSeatCount = Math.ceil(columnCount / (columnSpacing + 1)) * Math.ceil(rowCount / (rowSpacing + 1));
- // availableSeatCount = 0;
- // if (rowSpacing > 0) {
- // availableSeatCount = Math.ceil(columnCount / (columnSpacing + 1));
- // for (var i = 0; i < Math.floor(rowCount / (rowSpacing + 1)); i++) {
- // for (var j = 0; j < (rowSpacing + 1); j++) {
- // if (i * 2 * rowSpacing + j + 1 > rowCount) break;
- // if (j < rowSpacing)
- // availableSeatCount += Math.ceil((columnCount - j - 1) / (columnSpacing + 1))
- // else
- // availableSeatCount += Math.ceil((columnCount - (rowSpacing * 2 - j - 1)) / (columnSpacing + 1))
- // }
- // }
- // } else {
- // availableSeatCount = Math.ceil(columnCount / (columnSpacing + 1)) * rowCount;
- // }
- return true;
- }
- function ExaminationPlan_StudentAdd() {
- if (!calculateSeatCount()) {
- return;
- }
- var curStudentCount = $("#dgStudent").cmsXDataTable("getRows").length;
- var studentOrderType = $("#StudentOrderType").combobox('getValue');
- $.popupTopWindow('添加学生', CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationPlan/AddStudentSelect', 800, 600, ExaminationPlan_StudentAdd_Confirm, { limit: availableSeatCount - curStudentCount, studentOrderType: studentOrderType });
- //, examinationPlanID: examinationPlanID
- }
- function ExaminationPlan_StudentAdd_Confirm(studentList) {
- if (!studentList) return;
- var studentOrderType = $("#StudentOrderType").combobox('getValue');
- var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
- var newStudentViewList = $.map(
- $.grep(studentList, function (x) { return $.grep(studentViewList, function (y) { return y.UserID == x.UserID; }).length == 0; }),
- function (x) {
- return {
- ExaminationRoomStudentID: Guid.NewGuid().ToString(),
- ExaminationRoomLayoutID: examinationRoomLayoutID,
- UserID: x.UserID,
- LoginID: x.LoginID,
- Name: x.UserName,
- Row: null,
- Column: null,
- Remark: '',
- RecordStatus: null,
- CreateTime: null,
- CreateUserID: null,
- ModifyUserID: null,
- ModifyTime: null
- };
- }
- ).concat(
- studentViewList
- ).sort(function (a, b) {
- if (studentOrderType == "2") {
- return a.LoginID - b.LoginID;
- } else {
- return 1;
- }
- });
- $("#dgStudent").cmsXDataTable("loadData", { rows: newStudentViewList, total: newStudentViewList.length });
- }
- function ExaminationPlan_StudentDelete() {
- var d = validChooseStudent();
- var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
- var i, j;
- var len = studentViewList.length;
- for (i = len - 1; i >= 0; i--) {
- for (j = 0; j < d.length; j++) {
- if (studentViewList[i].UserID == d[j]) {
- studentViewList.splice(i, 1);
- break;
- }
- }
- }
- $("#dgStudent").cmsXDataTable("loadData", { rows: studentViewList, total: studentViewList.length });
- }
|