ExaminationPlanClassroomLayout.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. var examinationPlanID;
  2. var examinationRoomLayoutID;
  3. var availableSeatCount;
  4. var totalSeat;
  5. var rowCount;
  6. var columnCount;
  7. $(function () {
  8. examinationPlanID = $.SystemGeneral.getUrlParam("ExaminationPlanID");
  9. examinationRoomLayoutID = $.SystemGeneral.getUrlParam("ExaminationRoomLayoutID");
  10. });
  11. function ExaminationPlan_ClassroomLayoutSave() {
  12. // if (!calculateSeatCount()) {
  13. // return;
  14. // }
  15. // var curStudentCount = $("#dgStudent").cmsXDataTable("getRows").length;
  16. // if (availableSeatCount < curStudentCount) {
  17. // $.messager.alert("系统提示", "教室只能容纳" + availableSeatCount + "人,目前选中了" + curStudentCount + "个学生,请先删除多出的学生后再保存。");
  18. // return;
  19. // } else {
  20. // $(document.forms[0]).submit();
  21. // }
  22. $(document.forms[0]).submit();
  23. }
  24. function ExaminationPlan_TeacherAdd() {
  25. var classroomID = $("#ClassroomID").combogridX("getValue");
  26. if (classroomID == "" || classroomID == nonSelect) {
  27. $.messager.alert("系统提示", "请先选择考场再选择监考老师。");
  28. return;
  29. }
  30. $.popupTopWindow('新增监考老师', CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationTeacher/ExaminationTeacherSelect?ExaminationPlanID=' + examinationPlanID + '&ClassroomID=' + classroomID, 800, 600, ExaminationPlan_TeacherAdd_Confirm);
  31. }
  32. function ExaminationPlan_TeacherAdd_Confirm(teacherList) {
  33. if (!teacherList) return;
  34. var examinationTeacherList = $("#dgRoomTeacher").cmsXDataTable("getRows");
  35. $.each(teacherList, function () {
  36. var curUserID = this.UserID;
  37. if ($.grep(examinationTeacherList, function (x) { return x.UserID == curUserID }).length == 0) {
  38. examinationTeacherList.push(this);
  39. }
  40. });
  41. $("#dgRoomTeacher").cmsXDataTable("loadData", { rows: examinationTeacherList, total: examinationTeacherList.length });
  42. }
  43. //获取选中的数据
  44. function validChooseTeacher() {
  45. var d = [];
  46. $.each($("#dgRoomTeacher").cmsXDataTable("getSelections"), function (index) {
  47. d.push(this.UserID);
  48. });
  49. return d;
  50. }
  51. function validChooseStudent() {
  52. var d = [];
  53. $.each($("#dgStudent").cmsXDataTable("getSelections"), function (index) {
  54. d.push(this.UserID);
  55. });
  56. return d;
  57. }
  58. function ExaminationPlan_TeacherDelete() {
  59. var d = validChooseTeacher();
  60. var teacherViewList = $("#dgRoomTeacher").cmsXDataTable("getRows");
  61. var i, j;
  62. var len = teacherViewList.length;
  63. for (i = len - 1; i >= 0; i--) {
  64. for (j = 0; j < d.length; j++) {
  65. if (teacherViewList[i].UserID == d[j]) {
  66. teacherViewList.splice(i, 1);
  67. break;
  68. }
  69. }
  70. }
  71. $("#dgRoomTeacher").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  72. }
  73. function ClassroomSelected(data) {
  74. totalSeat = data.Totalseating;
  75. rowCount = data.RowCout;
  76. columnCount = data.ColumnCount;
  77. availableSeatCount = data.RemainSeatCount;
  78. }
  79. function Classroom_LoadSuccess(data) {
  80. var classroomID = $("#ClassroomID").combogridX("options").value;
  81. var curClassroom = $.grep(data.rows, function (x) { return x.ClassroomID == classroomID; });
  82. if (curClassroom.length > 0) {
  83. ClassroomSelected(curClassroom[0]);
  84. }
  85. }
  86. function calculateSeatCount() {
  87. if (!$(document.forms[0]).valid()) return false;
  88. if (!rowCount || !columnCount) {
  89. $.messager.alert("系统提示", "选中的教室还没有设置正确的行列数,请通知负责教室管理的老师进行设置。");
  90. return false;
  91. }
  92. var rowSpacing = parseFloat($("input[name='RowSpacing']").val());
  93. var columnSpacing = parseFloat($("input[name='ColumnSpacing']").val());
  94. //availableSeatCount = Math.ceil(columnCount / (columnSpacing + 1)) * Math.ceil(rowCount / (rowSpacing + 1));
  95. // availableSeatCount = 0;
  96. // if (rowSpacing > 0) {
  97. // availableSeatCount = Math.ceil(columnCount / (columnSpacing + 1));
  98. // for (var i = 0; i < Math.floor(rowCount / (rowSpacing + 1)); i++) {
  99. // for (var j = 0; j < (rowSpacing + 1); j++) {
  100. // if (i * 2 * rowSpacing + j + 1 > rowCount) break;
  101. // if (j < rowSpacing)
  102. // availableSeatCount += Math.ceil((columnCount - j - 1) / (columnSpacing + 1))
  103. // else
  104. // availableSeatCount += Math.ceil((columnCount - (rowSpacing * 2 - j - 1)) / (columnSpacing + 1))
  105. // }
  106. // }
  107. // } else {
  108. // availableSeatCount = Math.ceil(columnCount / (columnSpacing + 1)) * rowCount;
  109. // }
  110. return true;
  111. }
  112. function ExaminationPlan_StudentAdd() {
  113. if (!calculateSeatCount()) {
  114. return;
  115. }
  116. var curStudentCount = $("#dgStudent").cmsXDataTable("getRows").length;
  117. var studentOrderType = $("#StudentOrderType").combobox('getValue');
  118. $.popupTopWindow('添加学生', CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationPlan/StudentSelect', 800, 600, ExaminationPlan_StudentAdd_Confirm, { limit: availableSeatCount - curStudentCount, studentOrderType: studentOrderType, examinationPlanID: examinationPlanID });
  119. }
  120. function ExaminationPlan_StudentAdd_Confirm(studentList) {
  121. if (!studentList) return;
  122. var studentOrderType = $("#StudentOrderType").combobox('getValue');
  123. var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
  124. var addedStudentViewList = $.map(
  125. $.grep(studentList, function (x) { return $.grep(studentViewList, function (y) { return y.UserID == x.UserID; }).length == 0; }),
  126. function (x) {
  127. return {
  128. ExaminationRoomStudentID: Guid.NewGuid().ToString(),
  129. ExaminationRoomLayoutID: examinationRoomLayoutID,
  130. UserID: x.UserID,
  131. LoginID: x.LoginID,
  132. Name: x.UserName,
  133. Row: null,
  134. Column: null,
  135. Remark: '',
  136. RecordStatus: null,
  137. CreateTime: null,
  138. CreateUserID: null,
  139. ModifyUserID: null,
  140. ModifyTime: null
  141. };
  142. });
  143. var addedStudentIDs = $.map(addedStudentViewList, function (x) { return x.UserID; }).join(',');
  144. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationPlan/CheckStudentSchedule',
  145. { examinationPlanID: examinationPlanID, studentUserIDs: addedStudentIDs },
  146. function (data) {
  147. if (data.IsSuccess) {
  148. var newStudentViewList = addedStudentViewList.concat(
  149. studentViewList
  150. ).sort(function (a, b) {
  151. if (studentOrderType == "2") {
  152. return a.LoginID - b.LoginID;
  153. } else {
  154. return 1;
  155. }
  156. });
  157. $("#dgStudent").cmsXDataTable("loadData", { rows: newStudentViewList, total: newStudentViewList.length });
  158. } else {
  159. $.messager.alert("系统提示", data.Message);
  160. }
  161. });
  162. }
  163. function ExaminationPlan_StudentDelete() {
  164. var d = validChooseStudent();
  165. var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
  166. var i, j;
  167. var len = studentViewList.length;
  168. for (i = len - 1; i >= 0; i--) {
  169. for (j = 0; j < d.length; j++) {
  170. if (studentViewList[i].UserID == d[j]) {
  171. studentViewList.splice(i, 1);
  172. break;
  173. }
  174. }
  175. }
  176. $("#dgStudent").cmsXDataTable("loadData", { rows: studentViewList, total: studentViewList.length });
  177. }