ExecutableFreeSelectionCouseEdit.js 14 KB

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