OptionalCourseSettingEdit.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. $("#Credit").val(parseFloat($("#Credit").val()).toFixed(1));
  6. $("#TheoryCourse").keyup(function () {
  7. recalculate();
  8. });
  9. $("#Practicehours").keyup(function () {
  10. recalculate();
  11. });
  12. $("#TheoryWeeklyNum").keyup(function () {
  13. recalculate();
  14. });
  15. $("#PracticeWeeklyNum").keyup(function () {
  16. recalculate();
  17. });
  18. });
  19. function reload() {
  20. $("#dgOptionalCourseSettingList").cmsXDataTable("load", $.getDataGridParams("dgOptionalCourseSettingList"));
  21. }
  22. //获取选中的数据
  23. function validChoose() {
  24. var d = [];
  25. $.each($("#dgOptionalCourseSettingList").cmsXDataTable("getSelections"), function (index) {
  26. d.push(this.ExecutableOptionalCourseID);
  27. });
  28. return d;
  29. }
  30. function enablevalidChoose() {
  31. var d = [];
  32. $.each($("#dgOptionalCourseSettingList").cmsXDataTable("getSelections"), function (index) {
  33. d.push(this.IsEnableDesc);
  34. });
  35. return d;
  36. }
  37. function statusvalidChoose() {
  38. var d = [];
  39. $.each($("#dgOptionalCourseSettingList").cmsXDataTable("getSelections"), function (index) {
  40. d.push(this.RecordStatus);
  41. });
  42. return d;
  43. }
  44. function queryCollege(data) {
  45. $("#CollegeDropdown").combobox("reload", CMS_SystemConfig.VirtualDirectoryPath + "/College/CollegeDropdownListBanid?campusID=" + data.Value + "");
  46. }
  47. //弹出限选任务生成页面
  48. function OptionalCourseSetting_Create() {
  49. $.popupTopWindow('限选任务生成', CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCourseSetting/Create?MNU=" +
  50. mnu, 600, 300, null, null);
  51. }
  52. function QueryCoursematerialComboGrid(data) {
  53. reload();
  54. }
  55. function QuerySpecialtyComboGrid(data) {
  56. reload();
  57. }
  58. function QuerySchoolYearNumDropdownList(data) {
  59. reload();
  60. }
  61. function QueryIsEnableDropdownList(data) {
  62. reload();
  63. }
  64. function QueryIsOpenDropdownList(data) {
  65. reload();
  66. }
  67. function SelectCollegeComboGrid(data) {
  68. reload();
  69. }
  70. function SelectDictionaryGrade(data) {
  71. reload();
  72. }
  73. //选修任务班名称生成规则
  74. function QueryClassmajor(data) {
  75. document.getElementById("DefaultClassName").value = data.Name + "_" + $("#CoursematerialID").combogridX("getText") + "(限选)";
  76. // var GrademajorID = $("#GrademajorID").combogridX("getValue");
  77. // if (GrademajorID != null) {
  78. // var jsonString = "({'QueryParamsDatas':'GrademajorComboGrid|*|" + GrademajorID + "|@|'})";
  79. // $("#ClassmajorID").combogridX("reload", eval(jsonString));
  80. // }
  81. }
  82. function swapWeekSettings() {
  83. if ($("#weekExpander").attr("expanded") == "0") {
  84. $("#weekExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -50px 0");
  85. $("#weekExpander").closest("tr")
  86. .next().css("display", "")
  87. .next().css("display", "")
  88. .next().css("display", "")
  89. .next().css("display", "");
  90. $("#weekExpander").attr("expanded", "1");
  91. } else {
  92. $("#weekExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -32px 0");
  93. $("#weekExpander").closest("tr")
  94. .next().css("display", "none")
  95. .next().css("display", "none")
  96. .next().css("display", "none")
  97. .next().css("display", "none");
  98. $("#weekExpander").attr("expanded", "0");
  99. }
  100. }
  101. //弹出添加老师页面
  102. function addTeachers(rowindex, rowdata) {
  103. $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/OptionalCourseSetting/TeacherEdit?OptionalCourseID=' + rowdata.OptionalCourseID + '&MNU=' +
  104. mnu, 560, 480, AddTeachers_Confirm, rowdata);
  105. }
  106. //确定添加教师
  107. function AddTeachers_Confirm(data) {
  108. reload();
  109. }
  110. //弹出添加教师页面
  111. function OptionalCourseSetting_AddTeacher() {
  112. $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/Common/TeacherSelect?FromMNU=' +
  113. mnu, 560, 480, AddTeachers_Confirm);
  114. }
  115. //确定添加教师
  116. function AddTeachers_Confirm(teacherList) {
  117. if (!teacherList) return;
  118. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  119. $.each(teacherList, function (index, value) {
  120. if ($.grep(teacherViewList, function (row, index) { return value.UserID == row.UserID; }).length == 0) {
  121. teacherViewList.push({
  122. UserID: value.UserID,
  123. LoginID: value.StaffCode,
  124. Name: value.Name,
  125. CollegeID: value.CollegeID,
  126. CollegeName: value.CollegeName,
  127. BirthDate: value.BirthDate,
  128. TeacherType: value.TeacherType,
  129. TeacherTypeName: value.TeacherTypeName,
  130. IncumbencyState: value.IncumbencyState,
  131. IncumbencyStateName: value.IncumbencyStateName,
  132. Title: value.Title,
  133. TitleName: value.TitleName,
  134. TeachingMethod: null,
  135. TeachingMethodDesc: null
  136. });
  137. }
  138. });
  139. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  140. }
  141. //删除添加教师
  142. function OptionalCourseSetting_DelTeacher() {
  143. var d = validTeacherChoose();
  144. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  145. var i, j;
  146. var len = teacherViewList.length;
  147. for (i = len - 1; i >= 0; i--) {
  148. for (j = 0; j < d.length; j++) {
  149. if (teacherViewList[i].UserID == d[j].UserID) {
  150. teacherViewList.splice(i, 1);
  151. break;
  152. }
  153. }
  154. }
  155. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  156. }
  157. //获取选中的教师信息
  158. function validTeacherChoose() {
  159. var d = [];
  160. $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) {
  161. d.push(this);
  162. });
  163. return d;
  164. }
  165. //添加开放范围班级信息
  166. function OptionalCourseSetting_AddClass() {
  167. var GrademajorID = $("#GrademajorID").combogridX("getValue");
  168. $.popupTopWindow('添加班级', CMS_SystemConfig.VirtualDirectoryPath + '/Common/ClassmajorSelect?FromMNU=' + mnu + "&GrademajorID=" +
  169. GrademajorID, 650, 480, AddClass_Confirm);
  170. }
  171. //删除添加班级信息
  172. function OptionalCourseSetting_DelClass() {
  173. var d = validClassChoose();
  174. var classViewList = $("#dgClassList").cmsXDataTable("getRows");
  175. var i, j;
  176. var len = classViewList.length;
  177. for (i = len - 1; i >= 0; i--) {
  178. for (j = 0; j < d.length; j++) {
  179. if (classViewList[i].ClassmajorID == d[j].ClassmajorID) {
  180. classViewList.splice(i, 1);
  181. break;
  182. }
  183. }
  184. }
  185. $("#dgClassList").cmsXDataTable("loadData", { rows: classViewList, total: classViewList.length });
  186. }
  187. //确定添加班级
  188. function AddClass_Confirm(classList) {
  189. if (!classList) return;
  190. var classViewList = $("#dgClassList").cmsXDataTable("getRows");
  191. $.each(classList, function (index, value) {
  192. if ($.grep(classViewList, function (row, index) { return value.ClassmajorID == row.ClassmajorID; }).length == 0) {
  193. classViewList.push({
  194. ClassmajorID: value.ClassmajorID,
  195. Name: value.Name,
  196. No: value.No,
  197. StudentCount: value.StudentCount
  198. });
  199. }
  200. });
  201. $("#dgClassList").cmsXDataTable("loadData", { rows: classViewList, total: classViewList.length });
  202. QueryClassmajor(classViewList[0])
  203. }
  204. //获取选中的班级信息
  205. function validClassChoose() {
  206. var d = [];
  207. $.each($("#dgClassList").cmsXDataTable("getSelections"), function (index) {
  208. d.push(this);
  209. });
  210. return d;
  211. }
  212. function recalculate() {
  213. var theoryCourse = parseInt($("#TheoryCourse").val() == "" ? "0" : $("#TheoryCourse").val());
  214. var practicehours = parseInt($("#Practicehours").val() == "" ? "0" : $("#Practicehours").val());
  215. var theoryWeeklyNum = parseInt($("#TheoryWeeklyNum").val() == "" ? "0" : $("#TheoryWeeklyNum").val());
  216. var practiceWeeklyNum = parseInt($("#PracticeWeeklyNum").val() == "" ? "0" : $("#PracticeWeeklyNum").val());
  217. var totalHours = theoryCourse + practicehours;
  218. var totalWeeklyNum = theoryWeeklyNum + practiceWeeklyNum;
  219. var weeklyHours = totalHours / totalWeeklyNum;
  220. var weeklyNum = weeklyHours / 2;
  221. $("#Totalhours").val(totalHours);
  222. if (totalWeeklyNum != 0) {
  223. $("#SchoolweeksNum").val(totalWeeklyNum);
  224. $("#WeeklyHours").val(weeklyHours);
  225. $("#WeeklyNum").val(weeklyNum);
  226. }
  227. }
  228. function queryClass() {
  229. var jsonString = "";
  230. var parameterString = "";
  231. var StandardID = $("#StandardID").combogridX("getValue");
  232. var Schoolyear = $("#GradeID").combobox("getValue");
  233. if (StandardID != nonSelect) parameterString += "StandardDictionaryDropDown|*|" + StandardID + "|@|";
  234. if (StandardID != nonSelect) parameterString += "DictionaryStandard|*|" + StandardID + "|@|";
  235. if (Schoolyear != nonSelect) parameterString += "DictionaryGrade|*|" + Schoolyear + "|@|";
  236. if (parameterString != "") {
  237. jsonString = "({'QueryParamsDatas':'" + parameterString + "'})";
  238. $("#CoursematerialID").combogridX("reload", eval(jsonString));
  239. $("#GrademajorID").combogridX("reload", eval(jsonString));
  240. } else {
  241. $("#CoursematerialID").combogridX("reload", eval(jsonString));
  242. $("#GrademajorID").combogridX("reload", eval(jsonString));
  243. }
  244. reload();
  245. }
  246. function CoursematerialSelect(data) {
  247. if (data != "") {
  248. $("#SchoolyearNumID").combobox("setValue", data.SchoolyearNumID)
  249. $("#SchoolcodeID").combobox("setValue", data.SchoolcodeID)
  250. $("#CourseTypeID").combobox("setValue", data.CourseTypeID)
  251. $("#DepartmentID").combogridX("setValue", data.DepartmentID)
  252. $("#CourseStructureID").combobox("setValue", data.CourseStructureID)
  253. $("#CourseCategoryID").combobox("setValue", data.CourseCategoryID)
  254. $("#CourseQualityID").combobox("setValue", data.CourseQualityID)
  255. $("#TeachinglanguageID").combobox("setValue", data.TeachinglanguageID)
  256. $("#ExaminationModeID").combobox("setValue", data.ExaminationModeID)
  257. $("#ResultTypeID").combobox("setValue", data.ResultTypeID)
  258. $("#PracticeTypeID").combobox("setValue", data.PracticeTypeID)
  259. $("#Credit").val(data.Credit);
  260. $("#TheoryCourse").val(data.TheoryCourse);
  261. $("#Practicehours").val(data.Practicehours);
  262. $("#Trialhours").val(data.Trialhours);
  263. $("#TheoryWeeklyNum").val(data.TheoryWeeklyNum);
  264. $("#PracticeWeeklyNum").val(data.PracticeWeeklyNum);
  265. $("#TrialWeeklyNum").val(data.TrialWeeklyNum);
  266. $("#StartWeeklyNum").val(data.StartWeeklyNum);
  267. $("#EndWeeklyNum").val(data.EndWeeklyNum);
  268. $("#WeeklyHours").val(data.WeeklyHours);
  269. $("#WeeklyNum").val(data.WeeklyNum);
  270. $("#OptionalCourseID").val(data.OptionalCourseID);
  271. $.post(CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCoursePlan/TeachingModeType?OptionalCourseID=" + data.OptionalCourseID, null, function (result) {
  272. $.each($("[name='TeachingModeID']"), function (i, x) {
  273. if ($.grep(result, function (v) { return v == $(x).val(); }).length > 0) {
  274. $(x).attr("checked", "checked")
  275. } else {
  276. $(x).removeAttr("checked")
  277. }
  278. });
  279. });
  280. } else {
  281. $.messager.alert("系统提示", "任选课程信息为空。");
  282. }
  283. recalculate();
  284. }