EducationMissionClassEdit.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. })
  6. //加载列表
  7. function reload() {
  8. $("#dgTeacherList").cmsXDataTable("load", $.getDataGridParams("dgTeacherList"));
  9. }
  10. //获取选中的数据
  11. function validChoose() {
  12. var d = [];
  13. $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) {
  14. d.push(this);
  15. });
  16. return d;
  17. }
  18. //验证上课周次、每周次、周学时相乘等于总学时
  19. //function Total() {
  20. // var hours = $("#SchoolweeksNum").val() * $("#WeeklyNum").val() * $("#WeeklyHours").val();
  21. // if (hours != $("#Totalhours").val()) {
  22. // $.messager.alert('系统信息', "上课周次、每周次、周学时相乘必须等于总学时!");
  23. // }
  24. //}
  25. //添加教师
  26. function EducationMissionClass_TeacherAdd() {
  27. $.popupTopWindow('教师信息', CMS_SystemConfig.VirtualDirectoryPath + '/EducationMissionClass/TeacherSelect?FromMNU=' + mnu, 900, 500, AddTeachers_Confirm);
  28. }
  29. function AddTeachers_Confirm(teacherList) {
  30. if (!teacherList) return;
  31. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  32. $.each(teacherList, function (index, value) {
  33. if ($.grep(teacherViewList, function (row, index) { return value.UserID == row.UserID; }).length == 0) {
  34. teacherViewList.push({
  35. FreeSelectionCourseApplyID: $("#FreeSelectionCouseApplyID").val(),
  36. UserID: value.UserID,
  37. LoginID: value.StaffCode,
  38. Name: value.Name,
  39. CollegeID: value.CollegeID,
  40. CollegeName: value.CollegeName,
  41. BirthDate: value.BirthDate,
  42. TeacherType: value.TeacherType,
  43. TeacherTypeName: value.TeacherTypeName,
  44. IncumbencyState: value.IncumbencyState,
  45. IncumbencyStateName: value.IncumbencyStateName,
  46. Title: value.Title,
  47. TitleName: value.TitleName,
  48. TeachingMethod: 0,//默認选取的数据为主讲课
  49. TeachingMethodDesc: null,
  50. SexName: value.SexName,
  51. DepartmentName: value.DepartmentName,
  52. DepartmentID: value.DepartmentID
  53. });
  54. }
  55. });
  56. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  57. }
  58. //删除教师
  59. function EducationMissionClass_TeacherDelete() {
  60. var d = validChoose();
  61. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  62. var i, j;
  63. var len = teacherViewList.length;
  64. for (i = len - 1; i >= 0; i--) {
  65. for (j = 0; j < d.length; j++) {
  66. if (teacherViewList[i].UserID == d[j].UserID) {
  67. teacherViewList.splice(i, 1);
  68. break;
  69. }
  70. }
  71. }
  72. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  73. }
  74. function success(data) {
  75. $.messager.alert('系统信息', data.Message);
  76. if (data.IsSuccess) {
  77. top.$('#sysWindow').window('close');
  78. var tab = top.$('#index_center_tabs').tabs('getSelected');
  79. tab.panel('refresh');
  80. }
  81. }
  82. //单周
  83. function EducationMissionClass_AloneWeek() {
  84. EducationMissionClass_Clear();
  85. $("input[name='WeekNum']").each(function () {
  86. var teaching = $(this).val();
  87. if (teaching % 2 == 1) {
  88. $(this)[0].checked = true;
  89. }
  90. });
  91. }
  92. //清除
  93. function EducationMissionClass_Clear() {
  94. $("input[name='WeekNum']").attr("checked", false);
  95. }
  96. //所有
  97. function EducationMissionClass_All() {
  98. $("input[name='WeekNum']").attr("checked", true);
  99. }
  100. //双周
  101. function EducationMissionClass_BothWeek() {
  102. EducationMissionClass_Clear();
  103. $("input[name='WeekNum']").each(function () {
  104. var teaching = $(this).val();
  105. if (teaching % 2 != 1) {
  106. $(this)[0].checked = true;
  107. }
  108. });
  109. }
  110. function loadClassroom() {
  111. var roomUseID = $("#ClassroomTypeID").combobox("getValue");
  112. var collegeID = $("#CollegeID").val();
  113. if (roomUseID == nonSelect) {
  114. roomUseID = "null"
  115. }
  116. var jsonString = "({'QueryParamsDatas':'ClassroomType|*|" + roomUseID
  117. + "|@|CollegeID|*|" + collegeID + "|@|IsSpecialDictionaryDropDown|*|" + 1 + "|@|lodaType|*|" + 1 + "|@|'})";
  118. // CMSFunction.ComboGrid.SetValue($("#ClassroomID"), "", "");
  119. $("#ClassroomID").combogridX("reload", eval(jsonString));
  120. //reload();
  121. }
  122. function queryClassroom() {
  123. var roomUseID = $("#ClassroomTypeID").combobox("getValue");
  124. var collegeID = $("#CollegeID").val();
  125. if (roomUseID == nonSelect) {
  126. roomUseID = "null"
  127. }
  128. CMSFunction.ComboGrid.SetValue($("#ClassroomID"), "", ""); //重新选择教室类型、清空教室
  129. var jsonString = "({'QueryParamsDatas':'ClassroomType|*|" + roomUseID
  130. + "|@|IsSpecialDictionaryDropDown|*|" + 1 + "|@|lodaType|*|" + 1 + "|@|'})";
  131. // CMSFunction.ComboGrid.SetValue($("#ClassroomID"), "", "");
  132. $("#ClassroomID").combogridX("reload", eval(jsonString));
  133. //reload();
  134. }
  135. function EducationMissionClass_EditSave() {
  136. //Total();
  137. var startWeeklyNum = $("#StartWeeklyNum").val();
  138. var endWeeklyNum = $("#EndWeeklyNum").val();
  139. var countnum = parseInt(endWeeklyNum) - parseInt(startWeeklyNum) + 1;
  140. var tmleng = $("input[name='WeekNum']:checked").length;
  141. if (tmleng > countnum) {
  142. $.messager.alert('系统信息', "所选周次不能大于总周次!");
  143. return;
  144. }
  145. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/EducationMissionClass/CheckEducationMissionClassOpenControl', { educationMissionClassIDs: $("#EducationMissionClassID").val() }, function (data) {
  146. if (data.IsSuccess) {
  147. $.messager.confirm('确认', "保存教学安排会导致需要重新调整课程进度,是否确定?", function (r) {
  148. if (r) {
  149. var ischecked = $("input[name='WeekNum']").is(':checked');
  150. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  151. if (!ischecked) {
  152. }
  153. // if (teacherViewList.length == 0) {
  154. // $.messager.alert('系统信息', "请添加授课老师!");
  155. // return;
  156. // }
  157. for (var i = 0; i < teacherViewList.length; i++) {
  158. if (teacherViewList[i].TeachingMethod == null || teacherViewList[i].TeachingMethod == -1) {
  159. $.messager.alert('系统信息', "请选择授课老师的任课方式!");
  160. return;
  161. }
  162. }
  163. var classNum = $("#ClassNum").val();
  164. $("#ClassNums").val(classNum);
  165. $(document.forms[0]).submit();
  166. }
  167. });
  168. } else {
  169. $.messager.alert("系统提示", data.Message);
  170. return;
  171. }
  172. });
  173. }
  174. //获取选中的数据
  175. function validChoosTeacher() {
  176. var d = [];
  177. $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) {
  178. d.push(this);
  179. });
  180. return d;
  181. }
  182. //教师科表预览
  183. function Preview(rowindex, rowdata) {
  184. var schoolYearID = $("#SchoolyearID").val()
  185. //var fullUrl = CMS_SystemConfig.VirtualDirectoryPath + '/EducationSchedulingReport/TeacherReport?userID=' + rowdata.UserID + '&schoolyearID=' + schoolYearID;
  186. //$.popupTopWindow('教师课表预览', fullUrl, window.screen.availWidth, window.screen.availHeight - 60);
  187. var fullUrl = CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fTeacherSchedulingView&CollegeID_RAP=&UserID_RAP=" + rowdata.UserID + "&SchoolyearID_RAP=" + schoolYearID;
  188. $.popupTopWindowOutsite('教师课表', fullUrl, 1024, 600);
  189. }
  190. function EducationMissionClass_SetTeacherSave() {
  191. var d = validChoosTeacher();
  192. //if (d.length == 0) {
  193. // $.messager.alert("提示", "请选择您要设置的教师!");
  194. // return;
  195. //}
  196. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  197. for (var i = 0; i < teacherViewList.length; i++) {
  198. if (teacherViewList[i].TeachingMethod == null || teacherViewList[i].TeachingMethod == -1) {
  199. $.messager.alert('系统信息', "请选择授课老师的任课方式!");
  200. return;
  201. }
  202. }
  203. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/EducationMissionClass/CheckEducationMissionClassOpenControl', { educationMissionClassIDs: $("#EducationMissionClassID").val() }, function (data) {
  204. if (data.IsSuccess) {
  205. var teacherJsonStr = JSON.stringify(d);
  206. $("#hid_TeacherJsonStr").val(teacherJsonStr); //将json赋值给隐藏域
  207. $(document.forms[0]).submit(); //提交Form表单
  208. } else {
  209. $.messager.alert("系统提示", data.Message);
  210. return;
  211. }
  212. });
  213. }