ExaminationPlanClassroomGdss.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. var examinationPlanID;
  2. var isFromAddButton = false;
  3. var isFromEditButton = false;
  4. var saveConfirmMsg = "由于考试计划信息对考室安排和监考老师的安排有决定性作用,因此需要先提交考试计划信息后方能继续操作,是否确定提交?";
  5. var mnu;
  6. $(function () {
  7. mnu = $.SystemGeneral.getUrlParam("MNU");
  8. examinationPlanID = $.SystemGeneral.getUrlParam("ExaminationPlanID");
  9. WdatePicker({ el: $("#StartTime"), hmsMenuCfg: { H: [1, 2], m: [30, 2], s: [30, 4]} });
  10. WdatePicker({ el: $("#EndTime"), hmsMenuCfg: { H: [1, 2], m: [30, 2], s: [30, 4]} });
  11. });
  12. function buildingSelected() {
  13. if (checkDateTime()) {
  14. queryClassroom();
  15. }
  16. }
  17. function queryClassroom() {
  18. try {
  19. var buildingsInfoID = $("#BuildingsInfoID").combogridX("getValue");
  20. var date = $("#ExaminationDate").val();
  21. var stime = $("#StartTime").val();
  22. var etime = $("#EndTime").val();
  23. if ($dp) {
  24. if ($(this).attr("name") == "ExaminationDate") {
  25. date = $dp.cal.getNewDateStr();
  26. } else if ($(this).attr("name") == "StartTime") {
  27. stime = $dp.cal.getNewDateStr();
  28. } else if ($(this).attr("name") == "EndTime") {
  29. etime = $dp.cal.getNewDateStr();
  30. }
  31. }
  32. var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
  33. $("#ClassroomID").combogridX("reload", CMS_SystemConfig.VirtualDirectoryPath + "/ExaminationRoomSetting/AvailableListGdss?examinationPlanID="
  34. + examinationPlanID + "&buildingsInfoID=" + buildingsInfoID + "&examinationDate=" + date + "&startTime=" + stime + "&endTime=" + etime
  35. + "&studentCount=" + studentViewList.length);
  36. }
  37. catch (e) {
  38. }
  39. }
  40. function checkDateTime() {
  41. if ($("#ExaminationDate").val() == "") {
  42. $.messager.alert('系统信息', "考试日期必须填写。");
  43. return false;
  44. }
  45. if ($("#StartTime").val() == "") {
  46. $.messager.alert('系统信息', "开始时间必须填写。");
  47. return false;
  48. }
  49. if ($("#EndTime").val() == "") {
  50. $.messager.alert('系统信息', "结束时间必须填写。");
  51. return false;
  52. }
  53. var date = $("#ExaminationDate").val();
  54. date = date.replace(/-/g, "/");
  55. var stime = date + " " + $("#StartTime").val();
  56. var etime = date + " " + $("#EndTime").val();
  57. stime = new Date(stime);
  58. etime = new Date(etime);
  59. if (stime > etime) {
  60. $.messager.alert("系统提示", "开始时间不能大于结束时间");
  61. return false;
  62. }
  63. return true;
  64. }
  65. function ExaminationPlan_Save() {
  66. //var model = model;
  67. var buildingsInfoID = $("#BuildingsInfoID").combogridX("getValue");
  68. var classroomID = $("#ClassroomID").combogridX("getValue");
  69. var date = $("#ExaminationDate").val();
  70. var stime = $("#StartTime").val();
  71. var etime = $("#EndTime").val();
  72. if (classroomID == "" || classroomID == nonSelect || date == "" || stime == "" || etime == "") {
  73. $.messager.alert("系统提示", "请先填写或选择必填信息。");
  74. return false;
  75. }
  76. var teacherUserID = [];
  77. $.each($("#dgRoomTeacher").cmsXDataTable("getRows"), function (index) {
  78. teacherUserID.push(this.UserID);
  79. });
  80. var teacherUserIDs = teacherUserID.join(',');
  81. var studentUserID = [];
  82. $.each($("#dgStudent").cmsXDataTable("getRows"), function (index) {
  83. studentUserID.push(this.UserID);
  84. });
  85. var studentUserIDs = studentUserID.join(',')
  86. var examinationStudentList = $("#dgStudent").cmsXDataTable("getRows");
  87. if ($dp) {
  88. if ($(this).attr("name") == "ExaminationDate") {
  89. date = $dp.cal.getNewDateStr();
  90. } else if ($(this).attr("name") == "StartTime") {
  91. stime = $dp.cal.getNewDateStr();
  92. } else if ($(this).attr("name") == "EndTime") {
  93. etime = $dp.cal.getNewDateStr();
  94. }
  95. }
  96. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationPlan/CheckBeforeSave', { examinationPlanID: examinationPlanID, buildingsInfoID: buildingsInfoID, classroomID: classroomID, date: date, starttime: stime, endtime: etime, teacherIDs: teacherUserIDs, studentIDs: studentUserIDs }, function (data) {
  97. if (data.IsSuccess) {
  98. $.messager.confirm("系统提示", "存在学生与排课冲突,冲突信息查看链接<a style='color:red' href='" + data.Message + "'>冲突数据.xls</a>,并判断是否强行排考?", function (r) {
  99. if (r) {
  100. $(document.forms[0]).attr("action", CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationPlan/GdssSaveNotStudent');
  101. $(document.forms[0]).submit();
  102. } else {
  103. return;
  104. }
  105. });
  106. } else {
  107. $(document.forms[0]).submit();
  108. }
  109. });
  110. }
  111. //获取选中的数据
  112. function validChoose() {
  113. var d = [];
  114. $.each($("#dgRoomTeacher").cmsXDataTable("getSelections"), function (index) {
  115. d.push(this.UserID);
  116. });
  117. return d;
  118. }
  119. function ExaminationPlan_TeacherAdd() {
  120. if (!checkDateTime()) {
  121. return;
  122. }
  123. var date = $("#ExaminationDate").val();
  124. var stime = $("#StartTime").val();
  125. var etime = $("#EndTime").val();
  126. var schoolyearID = $("[name='SchoolyearID']").val();
  127. var classroomID = $("#ClassroomID").combogridX("getValue");
  128. if (classroomID == "" || classroomID == nonSelect) {
  129. $.messager.alert("系统提示", "请先选择考场再选择监考老师。");
  130. return;
  131. }
  132. $.popupTopWindow('新增监考老师', CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationTeacher/ExaminationTeacherSelectGdss?schoolyearID='
  133. + schoolyearID + '&classroomID=' + classroomID + '&examinationDate=' + date + '&startTime=' + stime + '&endTime=' + etime, 800, 600,
  134. ExaminationPlan_TeacherAdd_Confirm);
  135. }
  136. function ExaminationPlan_TeacherAdd_Confirm(teacherList) {
  137. if (!teacherList) return;
  138. var examinationTeacherList = $("#dgRoomTeacher").cmsXDataTable("getRows");
  139. $.each(teacherList, function () {
  140. var curUserID = this.UserID;
  141. if ($.grep(examinationTeacherList, function (x) { return x.UserID == curUserID }).length == 0) {
  142. examinationTeacherList.push(this);
  143. }
  144. });
  145. $("#dgRoomTeacher").cmsXDataTable("loadData", { rows: examinationTeacherList, total: examinationTeacherList.length });
  146. }
  147. function ExaminationPlan_TeacherDelete() {
  148. var d = validChoose();
  149. var teacherViewList = $("#dgRoomTeacher").cmsXDataTable("getRows");
  150. var i, j;
  151. var len = teacherViewList.length;
  152. for (i = len - 1; i >= 0; i--) {
  153. for (j = 0; j < d.length; j++) {
  154. if (teacherViewList[i].UserID == d[j]) {
  155. teacherViewList.splice(i, 1);
  156. break;
  157. }
  158. }
  159. }
  160. $("#dgRoomTeacher").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  161. }
  162. function validChooseStudent() {
  163. var d = [];
  164. $.each($("#dgStudent").cmsXDataTable("getSelections"), function (index) {
  165. d.push(this.UserID);
  166. });
  167. return d;
  168. }
  169. function ExaminationPlan_StudentAdd() {
  170. var curStudentCount = $("#dgStudent").cmsXDataTable("getRows").length;
  171. var studentOrderType = $("#StudentOrderType").combobox('getValue');
  172. $.popupTopWindow('添加学生', CMS_SystemConfig.VirtualDirectoryPath + '/ExaminationPlan/GdssStudentSelect?MNU=' + mnu + '&examinationPlanID=' + examinationPlanID, 800, 600, ExaminationPlan_StudentAdd_Confirm);
  173. }
  174. function ExaminationPlan_StudentAdd_Confirm(studentList) {
  175. if (!studentList) return;
  176. var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
  177. var addedStudentViewList = $.map(
  178. $.grep(studentList, function (x) { return $.grep(studentViewList, function (y) { return y.UserID == x.UserID; }).length == 0; }),
  179. function (x) {
  180. return {
  181. UserID: x.UserID,
  182. LoginID: x.LoginID,
  183. UserName: x.UserName
  184. };
  185. });
  186. var addedStudentIDs = $.map(addedStudentViewList, function (x) { return x.UserID; }).join(',');
  187. var newStudentViewList = addedStudentViewList.concat(studentViewList);
  188. $("#dgStudent").cmsXDataTable("loadData", { rows: newStudentViewList, total: newStudentViewList.length });
  189. queryClassroom();
  190. }
  191. function ExaminationPlan_StudentDelete() {
  192. var d = validChooseStudent();
  193. var studentViewList = $("#dgStudent").cmsXDataTable("getRows");
  194. var i, j;
  195. var len = studentViewList.length;
  196. for (i = len - 1; i >= 0; i--) {
  197. for (j = 0; j < d.length; j++) {
  198. if (studentViewList[i].UserID == d[j]) {
  199. studentViewList.splice(i, 1);
  200. break;
  201. }
  202. }
  203. }
  204. $("#dgStudent").cmsXDataTable("loadData", { rows: studentViewList, total: studentViewList.length });
  205. }