FreeSelectionCourseApplyEdit.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. })
  6. //保存
  7. function FreeSelectionCourseApply_Save() {
  8. // if ($("input[name='TeachingModeID']:checked").length == 0) {
  9. // $.messager.alert("系统提示", "请选择至少一种授课方式。");
  10. // return;
  11. // }
  12. var currentTeacher = $("#dgTeacherList").cmsXDataTable("getRows");
  13. var isValidated = true;
  14. $.each(currentTeacher, function () {
  15. var curSelectedTeacher = this;
  16. if (curSelectedTeacher.TeachingMethod == null) {
  17. isValidated = false;
  18. return false;
  19. }
  20. });
  21. if (!isValidated) {
  22. $.messager.alert('系统信息', '请指定一种任课方式。');
  23. return;
  24. }
  25. if (!isNaN($("#Trialhours").val()) && $("#Trialhours").val() != ""
  26. && !isNaN($("#Practicehours").val()) && $("#Practicehours").val() != ""
  27. && parseFloat($("#Trialhours").val()) > parseFloat($("#Practicehours").val())) {
  28. $.messager.alert("系统提示", "实验学时不能大于实践学时。");
  29. return;
  30. }
  31. if (!isNaN($("#TrialWeeklyNum").val()) && $("#TrialWeeklyNum").val() != ""
  32. && !isNaN($("#PracticeWeeklyNum").val()) && $("#PracticeWeeklyNum").val() != ""
  33. && parseFloat($("#TrialWeeklyNum").val()) > parseFloat($("#PracticeWeeklyNum").val())) {
  34. $.messager.alert("系统提示", "实验周次不能大于实践周次。");
  35. return;
  36. }
  37. $(document.forms[0]).submit();
  38. }
  39. //保存后执行方法
  40. VerifySave = function (data) {
  41. if (!data.IsSuccess) {
  42. if (data.Type == 1) { //如果验证到排课冲突type返回1,弹出选择框,用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
  43. $.messager.defaults = { ok: "保存", cancel: "不保存" };
  44. $.messager.confirm("选择提示", data.Message + ",是否继续保存?", function (r) {
  45. if (r) { //验证到排课冲突后,若要继续保存则IsNeedVerify为false
  46. $("#IsNeedVerify").val(false);
  47. $(document.forms[0]).submit();
  48. }
  49. });
  50. $.messager.defaults = { ok: "确定", cancel: "取消" };
  51. }
  52. else
  53. $.messager.alert("系统提示", data.Message);
  54. } else {
  55. $.messager.alert('系统信息', data.Message, null, function () {
  56. if (data.IsSuccess) {
  57. var dialogId = $.SystemGeneral.getUrlParam('WindowID');
  58. dialogId = (dialogId == null || dialogId == '') ? 'sysWindow' : dialogId;
  59. try {
  60. top.$('#' + dialogId).window('close');
  61. } catch (e) {
  62. }
  63. var tab = top.$('#index_center_tabs').tabs('getSelected');
  64. var $iframe = tab.panel('body').find("iframe");
  65. if ($iframe[0].contentWindow.reload)
  66. $iframe[0].contentWindow.reload();
  67. }
  68. });
  69. }
  70. }
  71. function reload() {
  72. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/FreeSelectionCourseApply/GetFreeSelectionCourseView', { freeSelectionCourseID: $("#FreeSelectionCouseID").combogridX("getValue") }, function (data) {
  73. if (data != "") {
  74. $("#DepartmentID").combogridX("setValue", data.DepartmentID)
  75. $("#CourseStructureID").combobox("setValue", data.CourseStructureID)
  76. $("#CourseCategoryID").combobox("setValue", data.CourseCategoryID)
  77. $("#CourseQualityID").combobox("setValue", data.CourseQualityID)
  78. $("#CourseTypeID").combobox("setValue", data.CourseTypeID)
  79. $("#ExaminationModeID").combobox("setValue", data.ExaminationModeID)
  80. $("#TeachinglanguageID").combobox("setValue", data.TeachinglanguageID)
  81. $("#SchoolyearNumID").combobox("setValue", data.SchoolyearNumID)
  82. $("#SchoolcodeID").combobox("setValue", data.SchoolcodeID)
  83. $("#PracticeTypeID").combobox("setValue", data.PracticeTypeID)
  84. $("#ResultTypeID").combobox("setValue", data.ResultTypeID)
  85. $("#Credit").val(data.Credit);
  86. $("#TheoryCourse").val(data.TheoryCourse);
  87. $("#Practicehours").val(data.Practicehours);
  88. $("#Trialhours").val(data.Trialhours);
  89. $("#WeeklyNum").val(data.WeeklyNum);
  90. $("#TheoryWeeklyNum").val(data.TheoryWeeklyNum);
  91. $("#PracticeWeeklyNum").val(data.PracticeWeeklyNum);
  92. $("#TrialWeeklyNum").val(data.TrialWeeklyNum);
  93. $("#StartWeeklyNum").val(data.StartWeeklyNum);
  94. $("#EndWeeklyNum").val(data.EndWeeklyNum);
  95. $("#WeeklyHours").val(data.WeeklyHours);
  96. setStartEndWeeklyNum(); //起止周次
  97. } else {
  98. $.messager.alert("系统提示", "任选课程信息为空");
  99. }
  100. });
  101. }
  102. //任修任务班名称生成规则
  103. function DefaultClassNo() {
  104. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/FreeSelectionCourseApply/DefaultClassNo', { SchoolyearID: $("#SchoolyearID").combobox("getValue"),
  105. freeSelectionCourseID: $("#FreeSelectionCouseID").combogridX("getValue"), StartWeeklyNum: $("#StartWeeklyNum").val(), EndWeeklyNum: $("#EndWeeklyNum").val()
  106. }, function (data) {
  107. if (data != "") {
  108. $("#DefaultClassName").val($("#FreeSelectionCouseID").combogridX("getText") + "-任选(" + $("#StartEndWeeklyNum").val() + ")" + (data == "0" ? "" : data + "班"));
  109. }
  110. })
  111. }
  112. //弹出添加教师页面
  113. function FreeSelectionCouseApply_TeacherAdd() {
  114. $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/Common/TeacherSelect?FromMNU=' +
  115. mnu, 560, 480, AddTeachers_Confirm);
  116. }
  117. //确定添加教师
  118. function AddTeachers_Confirm(teacherList) {
  119. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  120. $.each(teacherList, function (index, value) {
  121. if ($.grep(teacherViewList, function (row, index) { return value.UserID == teacherViewList.UserID; }).length == 0) {
  122. teacherViewList.push({
  123. FreeSelectionCourseApplyID: $("#FreeSelectionCouseApplyID").val(),
  124. UserID: value.UserID,
  125. LoginID: value.StaffCode,
  126. Name: value.Name,
  127. CollegeID: value.CollegeID,
  128. CollegeName: value.CollegeName,
  129. BirthDate: value.BirthDate,
  130. TeacherType: value.TeacherType,
  131. TeacherTypeName: value.TeacherTypeName,
  132. IncumbencyState: value.IncumbencyState,
  133. IncumbencyStateName: value.IncumbencyStateName,
  134. Title: value.Title,
  135. TitleName: value.TitleName,
  136. TeachingMethod: TeachingMethod,
  137. TeachingMethodDesc: null
  138. });
  139. }
  140. });
  141. teacherViewList[0].TeachingMethod = TeachingMethod;
  142. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  143. }
  144. //获取选中的教师信息
  145. function validChoose() {
  146. var d = [];
  147. $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) {
  148. d.push(this);
  149. });
  150. return d;
  151. }
  152. //删除添加教师
  153. function FreeSelectionCouseApply_TeacherDelete() {
  154. var d = validChoose();
  155. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  156. var i, j;
  157. var len = teacherViewList.length;
  158. for (i = len - 1; i >= 0; i--) {
  159. for (j = 0; j < d.length; j++) {
  160. if (teacherViewList[i].UserID == d[j].UserID) {
  161. teacherViewList.splice(i, 1);
  162. break;
  163. }
  164. }
  165. }
  166. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  167. }
  168. //弹出添加专业页面
  169. function FreeSelectionCouseApply_SpecialtyAdd() {
  170. $.popupTopWindow('添加专业', CMS_SystemConfig.VirtualDirectoryPath + '/Common/SpecialtySelect?FromMNU=' +
  171. mnu, 560, 480, AddSpecialty_Confirm);
  172. }
  173. //确定添加专业
  174. function AddSpecialty_Confirm(specialtyList) {
  175. var specialtyViewList = $("#dgSpecialtyList").cmsXDataTable("getRows");
  176. $.each(specialtyList, function (index, value) {
  177. if ($.grep(specialtyViewList, function (row, index) { return value.SpecialtyID == specialtyViewList.SpecialtyID; }).length == 0) {
  178. specialtyViewList.push({
  179. FreeSelectionCourseApplyID: $("#FreeSelectionCouseApplyID").val(),
  180. SpecialtyID: value.SpecialtyID,
  181. Code: value.Code,
  182. StandardName: value.StandardName,
  183. LearnSystem: value.LearnSystem,
  184. EducationName: value.EducationName,
  185. LearningformName: value.ScienceclassName,
  186. PropertyName: value.PropertyName,
  187. StandardTitleName: value.StandardTitleName,
  188. StandardLevelName: value.StandardLevelName
  189. });
  190. }
  191. });
  192. $("#dgSpecialtyList").cmsXDataTable("loadData", { rows: specialtyViewList, total: specialtyViewList.length });
  193. }
  194. //获取选中的专业信息
  195. function validChooseSpecialty() {
  196. var d = [];
  197. $.each($("#dgSpecialtyList").cmsXDataTable("getSelections"), function (index) {
  198. d.push(this);
  199. });
  200. return d;
  201. }
  202. //删除添加专业
  203. function FreeSelectionCouseApply_SpecialtyDelete() {
  204. var d = validChooseSpecialty();
  205. var specialtyViewList = $("#dgSpecialtyList").cmsXDataTable("getRows");
  206. var i, j;
  207. var len = specialtyViewList.length;
  208. for (i = len - 1; i >= 0; i--) {
  209. for (j = 0; j < d.length; j++) {
  210. if (specialtyViewList[i].SpecialtyID == d[j].SpecialtyID) {
  211. specialtyViewList.splice(i, 1);
  212. break;
  213. }
  214. }
  215. }
  216. $("#dgSpecialtyList").cmsXDataTable("loadData", { rows: specialtyViewList, total: specialtyViewList.length });
  217. }
  218. function success(data) {
  219. $.messager.alert('系统信息', data.Message);
  220. if (data.IsSuccess) {
  221. top.$('#sysWindow').window('close');
  222. var tab = top.$('#index_center_tabs').tabs('getSelected');
  223. tab.panel('refresh');
  224. }
  225. }
  226. //点击上课周次信息收缩
  227. function swapWeekSettings() {
  228. if ($("#weekExpander").attr("expanded") == "0") {
  229. $("#weekExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -50px 0");
  230. $("#weekExpander").closest("tr")
  231. .next().css("display", "")
  232. .next().css("display", "")
  233. .next().css("display", "")
  234. .next().css("display", "");
  235. $("#weekExpander").attr("expanded", "1");
  236. } else {
  237. $("#weekExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -32px 0");
  238. $("#weekExpander").closest("tr")
  239. .next().css("display", "none")
  240. .next().css("display", "none")
  241. .next().css("display", "none")
  242. .next().css("display", "none");
  243. $("#weekExpander").attr("expanded", "0");
  244. }
  245. }