MinorPlanApplyEdit.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. $(function () {
  2. mnu = $.SystemGeneral.getUrlParam("MNU");
  3. })
  4. //获取选中的数据
  5. function validChoose() {
  6. var d = [];
  7. $.each($("#dgStandardAndMinorSpecialtyCourseViewList").cmsXDataTable("getSelections"), function (index) {
  8. d.push(this);
  9. });
  10. return d;
  11. }
  12. function MinorPlanApply_Save() {
  13. var patten = /^-?\d+\.?\d{0,1}$/;
  14. var d = validChoose();
  15. for (var i = 0; i < d.length; i++) {
  16. if (d[i].Credit == null) {
  17. $.messager.alert("系统信息", "请填写学分信息!");
  18. return;
  19. }
  20. if (d[i].Credit.toString() == "") {
  21. $.messager.alert("系统信息", "请填写学分信息!");
  22. return;
  23. }
  24. if (!patten.test(d[i].Credit)) {
  25. d[i].Credit = d[i].Credit.trim();
  26. if (!patten.test(d[i].Credit)) {
  27. $.messager.alert("系统信息", "请在学分输入框输入数字");
  28. return;
  29. }
  30. }
  31. if (d[i].TheoryCourse == null) {
  32. $.messager.alert("系统信息", "请填写理论学时信息!");
  33. return;
  34. }
  35. if (d[i].TheoryCourse.toString() == "") {
  36. $.messager.alert("系统信息", "请填写理论学时信息!");
  37. return;
  38. }
  39. if (!patten.test(d[i].TheoryCourse)) {
  40. d[i].TheoryCourse = d[i].TheoryCourse.trim();
  41. if (!patten.test(d[i].TheoryCourse)) {
  42. $.messager.alert("系统信息", "请在理论学时输入框输入数字");
  43. return;
  44. }
  45. }
  46. if (d[i].Practicehours == null) {
  47. $.messager.alert("系统信息", "请填写实践学时信息!");
  48. return;
  49. }
  50. if (d[i].Practicehours.toString() == "") {
  51. $.messager.alert("系统信息", "请填写实践学时信息!");
  52. return;
  53. }
  54. if (!patten.test(d[i].Practicehours)) {
  55. d[i].Practicehours = d[i].Practicehours.trim();
  56. if (!patten.test(d[i].Practicehours)) {
  57. $.messager.alert("系统信息", "请在实践学时输入框输入数字");
  58. return;
  59. }
  60. }
  61. if (d[i].TheoryWeeklyNum.toString() == "") {
  62. d[i].TheoryWeeklyNum = null;
  63. }
  64. if (d[i].PracticeWeeklyNum.toString() == "") {
  65. d[i].PracticeWeeklyNum = null;
  66. }
  67. if (d[i].TrialWeeklyNum.toString() == "") {
  68. d[i].TrialWeeklyNum = null;
  69. }
  70. if (d[i].StartWeeklyNum == null) {
  71. $.messager.alert("系统信息", "请填写结束周次信息!");
  72. return;
  73. }
  74. if (d[i].StartWeeklyNum.toString() == "") {
  75. $.messager.alert("系统信息", "请填写开始周次信息!");
  76. return;
  77. }
  78. if (!patten.test(d[i].StartWeeklyNum)) {
  79. d[i].StartWeeklyNum = d[i].StartWeeklyNum.trim();
  80. if (!patten.test(d[i].StartWeeklyNum)) {
  81. $.messager.alert("系统信息", "请在开始周次输入框输入数字");
  82. return;
  83. }
  84. }
  85. if (d[i].EndWeeklyNum == null) {
  86. $.messager.alert("系统信息", "请填写结束周次信息!");
  87. return;
  88. }
  89. if (d[i].EndWeeklyNum.toString() == "") {
  90. $.messager.alert("系统信息", "请填写结束周次信息!");
  91. return;
  92. }
  93. if (!patten.test(d[i].EndWeeklyNum)) {
  94. d[i].EndWeeklyNum = d[i].EndWeeklyNum.trim();
  95. if (!patten.test(d[i].EndWeeklyNum)) {
  96. $.messager.alert("系统信息", "请在开始周次输入框输入数字");
  97. return;
  98. }
  99. }
  100. if (d[i].WeeklyHours.toString() == "") {
  101. d[i].WeeklyHours = null;
  102. }
  103. if (d[i].WeeklyNum.toString() == "") {
  104. d[i].WeeklyNum = null;
  105. }
  106. if (!isNaN($("#Trialhours").val()) && $("#Trialhours").val() != ""
  107. && !isNaN($("#Practicehours").val()) && $("#Practicehours").val() != ""
  108. && parseFloat($("#Trialhours").val()) > parseFloat($("#Practicehours").val())) {
  109. $.messager.alert("系统提示", "实验学时不能大于实践学时。");
  110. return;
  111. }
  112. if (!isNaN($("#TrialWeeklyNum").val()) && $("#TrialWeeklyNum").val() != ""
  113. && !isNaN($("#PracticeWeeklyNum").val()) && $("#PracticeWeeklyNum").val() != ""
  114. && parseFloat($("#TrialWeeklyNum").val()) > parseFloat($("#PracticeWeeklyNum").val())) {
  115. $.messager.alert("系统提示", "实验周次不能大于实践周次。");
  116. return;
  117. }
  118. }
  119. $("#MinorSpecialtyCourse").val(JSON.stringify(d));
  120. $(document.forms[0]).submit();
  121. }
  122. //弹出添加课程页面
  123. function MinorPlanApply_CourseAdd() {
  124. $.popupTopWindow('添加课程', CMS_SystemConfig.VirtualDirectoryPath + '/MinorPlanApply/AddCourse?FromMNU=' +
  125. mnu + '&YearID=0&StandardID=0', 800, 600, CourseAdd_Confirm);
  126. }
  127. //确定
  128. function CourseAdd_Confirm(CourseList) {
  129. if (CourseList == undefined)
  130. return;
  131. var CourseViewList = $("#dgStandardAndMinorSpecialtyCourseViewList").cmsXDataTable("getRows");
  132. $.each(CourseList, function (index, value) {
  133. if ($.grep(CourseViewList, function (row, index) { return value.MinorCourseID == CourseViewList.MinorCourseID; }).length == 0) {
  134. CourseViewList.push({
  135. MinorCourseID:value.MinorCourseID,
  136. CourseCode:value.CourseCode,
  137. CourseName:value.CourseName,
  138. StarttermName: value.StarttermName,
  139. SchoolyearNumID: value.SchoolyearNumID,
  140. SchoolcodeID:value.SchoolcodeID,
  141. Credit:value.Credit,
  142. TheoryCourse:value.TheoryCourse,
  143. Practicehours:value.Practicehours,
  144. TheoryWeeklyNum:value.TheoryWeeklyNum,
  145. PracticeWeeklyNum:value.PracticeWeeklyNum,
  146. TrialWeeklyNum:value.TrialWeeklyNum,
  147. StartWeeklyNum:value.StartWeeklyNum,
  148. EndWeeklyNum:value.EndWeeklyNum,
  149. WeeklyHours:value.WeeklyHours,
  150. WeeklyNum: value.WeeklyNum,
  151. Trialhours:value.Trialhours,
  152. StarttermID:value.StarttermID,
  153. CoursematerialID: value.CoursematerialID,
  154. DepartmentID: value.DepartmentID,
  155. CourseStructureID: value.CourseStructureID,
  156. CourseCategoryID: value.CourseCategoryID,
  157. CourseTypeID: value.CourseTypeID,
  158. CourseQualityID: value.CourseQualityID,
  159. PracticeTypeID: value.PracticeTypeID,
  160. ExaminationModeID: value.ExaminationModeID,
  161. CourseFineID: value.CourseFineID,
  162. TeachinglanguageID: value.TeachinglanguageID,
  163. ResultTypeID:value.ResultTypeID
  164. });
  165. }
  166. });
  167. $("#dgStandardAndMinorSpecialtyCourseViewList").cmsXDataTable("loadData", { rows: CourseViewList, total: CourseViewList.length });
  168. }
  169. //删除课程
  170. function MinorPlanApply_CourseDelete() {
  171. var d = validChoose();
  172. var CourseViewList = $("#dgStandardAndMinorSpecialtyCourseViewList").cmsXDataTable("getRows");
  173. var i, j;
  174. var len = CourseViewList.length;
  175. for (i = len - 1; i >= 0; i--) {
  176. for (j = 0; j < d.length; j++) {
  177. if (CourseViewList[i].MinorPlanApplicationID == d[j].MinorPlanApplicationID) {
  178. CourseViewList.splice(i, 1);
  179. break;
  180. }
  181. }
  182. }
  183. $("#dgStandardAndMinorSpecialtyCourseViewList").cmsXDataTable("loadData", { rows: CourseViewList, total: CourseViewList.length });
  184. }
  185. function reload() {
  186. $("#dgStandardAndMinorSpecialtyCourseViewList").cmsXDataTable("load", $.getDataGridParams("dgStandardAndMinorSpecialtyCourseViewList"));
  187. }