SelectCourseResult.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. var url = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Edit";
  2. var mnu = "";
  3. //加载
  4. $(function () {
  5. mnu = $.SystemGeneral.getUrlParam("MNU");
  6. })
  7. function typevalidChoose() {
  8. var d = [];
  9. $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) {
  10. d.push(this.SelectCourseType);
  11. });
  12. return d;
  13. }
  14. function statusValidChoose() {
  15. var d = [];
  16. $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) {
  17. d.push(this.RecordStatusCode);
  18. });
  19. return d;
  20. }
  21. //获取选中的数据
  22. function validChoose() {
  23. var d = [];
  24. $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) {
  25. d.push(this.ID);
  26. });
  27. return d;
  28. }
  29. function teachingvalidChoose() {
  30. var d = [];
  31. $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) {
  32. d.push(this.TeacherName);
  33. });
  34. return d;
  35. }
  36. function classroomvalidChoose() {
  37. var d = [];
  38. $.each($("#dgSelectCourseResultList").cmsXDataTable("getSelections"), function (index) {
  39. d.push(this.ClassroomName);
  40. });
  41. return d;
  42. }
  43. function validTeacherChoose() {
  44. var d = [];
  45. $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) {
  46. d.push(this);
  47. });
  48. return d;
  49. }
  50. function reload() {
  51. $("#dgSelectCourseResultList").cmsXDataTable("load", $.getDataGridParams("dgSelectCourseResultList"));
  52. }
  53. //学生名单
  54. function StudentList(rowindex, rowdata) {
  55. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/StudentList?ID=" + rowdata.ID + "&Type=" + rowdata.SelectCourseType + "&MNU=" + mnu;
  56. //var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Student";
  57. $.popupTopWindow('学生名单', redirectTo, 800, 550, null, null);
  58. }
  59. //修改教师
  60. function addTeachers() {
  61. var d = validChoose();
  62. var t = typevalidChoose();
  63. if (d == "") {
  64. $.messager.alert("系统信息", "请选择单个记录。");
  65. return;
  66. }
  67. if (d.length > 1) {
  68. $.messager.alert("系统信息", "只能选择单个记录进行修改。");
  69. return;
  70. }
  71. if (t == 0) {
  72. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Edit?ID=" + d + "&Type=" + t + "&MNU=" + mnu;
  73. $.popupTopWindow('修改教师', redirectTo, 750, 550, null, null);
  74. }
  75. else if (t == 1) {
  76. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/EditFreeSelection?ID=" + d + "&Type=" + t + "&MNU=" + mnu;
  77. $.popupTopWindow('修改教师', redirectTo, 750, 550, null, null);
  78. }
  79. }
  80. //弹出添加教师页面
  81. function SelectCourseResult_AddTeacher() {
  82. $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/Common/TeacherSelect?FromMNU=' +
  83. mnu, 650, 480, AddTeachers_Confirm);
  84. }
  85. function SelectCourseResult_Save() {
  86. $(document.forms[0]).submit();
  87. }
  88. function AddTeachers_Confirm(teacherList) {
  89. if (!teacherList) return;
  90. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  91. $.each(teacherList, function (index, value) {
  92. if ($.grep(teacherViewList, function (row, index) { return value.UserID == row.UserID; }).length == 0) {
  93. teacherViewList.push({
  94. ExecutableOptionalCourseID: $("#ExecutableOptionalCourseID").val(),
  95. ExecutableFreeSelectionCouseID: $("#ExecutableFreeSelectionCouseID").val(),
  96. UserID: value.UserID,
  97. LoginID: value.StaffCode,
  98. Name: value.Name,
  99. CollegeID: value.CollegeID,
  100. CollegeName: value.CollegeName,
  101. BirthDate: value.BirthDate,
  102. TeacherType: value.TeacherType,
  103. TeacherTypeName: value.TeacherTypeName,
  104. IncumbencyState: value.IncumbencyState,
  105. IncumbencyStateName: value.IncumbencyStateName,
  106. Title: value.Title,
  107. TitleName: value.TitleName,
  108. TeachingMethod: null,
  109. TeachingMethodDesc: null
  110. });
  111. }
  112. });
  113. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  114. }
  115. function SelectCourseResult_DelTeacher() {
  116. var d = validTeacherChoose();
  117. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  118. var i, j;
  119. var len = teacherViewList.length;
  120. for (i = len - 1; i >= 0; i--) {
  121. for (j = 0; j < d.length; j++) {
  122. if (teacherViewList[i].UserID == d[j].UserID) {
  123. teacherViewList.splice(i, 1);
  124. break;
  125. }
  126. }
  127. }
  128. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  129. }
  130. //开班
  131. function AddMission() {
  132. var d = validChoose().join(',');
  133. var t = typevalidChoose().join(',');
  134. var teacher = teachingvalidChoose().join(',');
  135. var classroom = classroomvalidChoose().join(',');
  136. var status = statusValidChoose().join(',');
  137. var teacherStr = "";
  138. var classroomStr = "";
  139. if (d.length == 0) {
  140. $.messager.alert("系统提示", "请选择您要进行开班的任务班信息。");
  141. return;
  142. }
  143. for (var i = 0; i < teacher.split(',').length; i++) {
  144. if (teacher.split(',')[i] == null || teacher.split(',')[i] == "") {
  145. teacherStr = "检测到选中的数据授课老师为空,是否继续开班?";
  146. // $.messager.confirm("系统提示", "检测到选中的数据授课老师为空,是否继续开班?", function (r) {
  147. // if (r) {
  148. // submitTeachingPlan(d, t.split(',')[0]);
  149. // }
  150. // else {
  151. // return;
  152. // }
  153. // });
  154. }
  155. }
  156. for (var i = 0; i < classroom.split(',').length; i++) {
  157. if (classroom.split(',')[i] == null || classroom.split(',')[i] == "") {
  158. classroomStr = "检测到选中的数据教室为空,是否继续开班?";
  159. // $.messager.confirm("系统提示", "检测到选中的数据教室为空,是否继续开班?", function (r) {
  160. // if (r) {
  161. // submitTeachingPlan(d, t.split(',')[0]);
  162. // }
  163. // else {
  164. // return;
  165. // }
  166. // });
  167. }
  168. }
  169. // for (var i = 0; i < status.split(',').length; i++) {
  170. // if (status.split(',')[i].trim() != opened && status.split(',')[i].trim() != cancleCreate) {
  171. // $.messager.alert("系统提示", "只能对“已开放”状态的数据进行开班,请核查!");
  172. // return;
  173. // }
  174. // }
  175. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/SelectCourseResult/CheckEnouthNum', { IDs: d }, function (data) {
  176. if (data.IsSuccess) {
  177. if (data.Data) {
  178. $.messager.defaults = { ok: "继续开班", cancel: "不开班" };
  179. $.messager.confirm("选择提示", "检测到选中的选修学生人数未达到人数下限,是否继续开班?", function (r) {
  180. if (r) {
  181. submitTeachingPlan(d, t.split(',')[0]);
  182. }
  183. else {
  184. return;
  185. }
  186. });
  187. $.messager.defaults = { ok: "确定", cancel: "取消" };
  188. }
  189. else if (teacherStr != "") {
  190. $.messager.confirm("系统提示", teacherStr, function (r) {
  191. if (r) {
  192. submitTeachingPlan(d, t.split(',')[0]);
  193. }
  194. else {
  195. return;
  196. }
  197. });
  198. }
  199. else if (classroomStr != "") {
  200. $.messager.confirm("系统提示", classroomStr, function (r) {
  201. if (r) {
  202. submitTeachingPlan(d, t.split(',')[0]);
  203. }
  204. else {
  205. return;
  206. }
  207. });
  208. }
  209. else {
  210. submitTeachingPlan(d, t.split(',')[0]);
  211. }
  212. }
  213. else
  214. submitTeachingPlan(d, t.split(',')[0]);
  215. });
  216. }
  217. //导出
  218. function Export() {
  219. $(document.forms[0]).submit();
  220. }
  221. function submitTeachingPlan(teachingPlanIDs, Types) {
  222. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/SelectCourseResult/GenerateEducationMissionClassSubminit', { teachingPlanIDs: teachingPlanIDs, Types: Types }, function (data) {
  223. if (data.IsSuccess == true) {
  224. $("#dgSelectCourseResultList").cmsXDataTable('load');
  225. }
  226. $.messager.alert("系统提示", data.Message);
  227. });
  228. }
  229. //院系所
  230. function SelectCollegeComboGrid() {
  231. reload();
  232. }
  233. //取消开班
  234. function CancelMission() {
  235. var d = validChoose().join(',');
  236. var status = statusValidChoose().join(',');
  237. if (d.length == 0) {
  238. $.messager.alert("系统提示", "请选择您要进行开班的任务班信息。");
  239. return;
  240. }
  241. for (var i = 0; i < status.split(',').length; i++) {
  242. if (status.split(',')[i].trim() != opened) {
  243. $.messager.alert("系统提示", "只能对“已开放”状态的数据进行取消开班,请核查!");
  244. return;
  245. }
  246. }
  247. $.messager.confirm("系统提示", "您确定要取消开班吗?", function (r) {
  248. if (r) {
  249. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/SelectCourseResult/CancelEducationMissionClass', { teachingPlanIDs: d }, function (data) {
  250. if (data == "取消开班成功!") {
  251. $.messager.alert("系统提示", data);
  252. $("#dgSelectCourseResultList").cmsXDataTable('load');
  253. } else {
  254. $.messager.alert("系统提示", data);
  255. }
  256. });
  257. }
  258. });
  259. }