OptionalCourseSetting.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. var mnu = "";
  2. $(function () {
  3. mnu = $.SystemGeneral.getUrlParam("MNU");
  4. });
  5. //Excel导出
  6. function OptionalCourseSetting_Export() {
  7. $(document.forms[0]).submit();
  8. }
  9. //任务生成确定
  10. function OptionalCourseSetting_Save() {
  11. if ($("#frmSaveOptionalCourse").form("validate")) {
  12. $("#frmSaveOptionalCourse").submit();
  13. }
  14. }
  15. function reload() {
  16. $("#dgOptionalCourseSettingList").cmsXDataTable("load", $.getDataGridParams("dgOptionalCourseSettingList"));
  17. }
  18. //获取选中的数据
  19. function validChoose() {
  20. var d = [];
  21. $.each($("#dgOptionalCourseSettingList").cmsXDataTable("getSelections"), function (index) {
  22. d.push(this.ExecutableOptionalCourseID);
  23. });
  24. return d;
  25. }
  26. function isOpenvalidChoose() {
  27. var d = [];
  28. $.each($("#dgOptionalCourseSettingList").cmsXDataTable("getSelections"), function (index) {
  29. d.push(this.IsOpenDesc);
  30. });
  31. return d;
  32. }
  33. function statusvalidChoose() {
  34. var d = [];
  35. $.each($("#dgOptionalCourseSettingList").cmsXDataTable("getSelections"), function (index) {
  36. d.push(this.RecordStatusCode);
  37. });
  38. return d;
  39. }
  40. function queryCollege(data) {
  41. $("#CollegeDropdown").combobox("reload", CMS_SystemConfig.VirtualDirectoryPath + "/College/CollegeDropdownListBanid?campusID=" + data.Value + "");
  42. }
  43. //弹出添加教师页面
  44. function addTeachers(rowindex, rowdata) {
  45. $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/OptionalCourseSetting/TeacherEdit?OptionalCourseID=' + rowdata.OptionalCourseID
  46. + '&MNU=' + mnu, 560, 480, AddTeachers_Confirm, rowdata);
  47. }
  48. //确实添加教师
  49. function AddTeachers_Confirm(data) {
  50. reload();
  51. }
  52. //弹出限选任务生成页面
  53. function OptionalCourseSetting_Create() {
  54. $.popupTopWindow('限选任务生成', CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCourseSetting/Create?MNU=" +
  55. mnu, 600, 300, null, null);
  56. }
  57. //批量修改
  58. SystemBatchModifyControl.OnSubmit = function () {
  59. var r = statusvalidChoose();
  60. for (var i = 0; i < r.length; i++) {
  61. if (r[i] == CreatedStatus) {
  62. $.messager.alert("系统提示", "已开班状态的信息无法修改。");
  63. return false;
  64. }
  65. else if (r[i] != NotOpenStatus && document.getElementById("IsOpened_CheckBox").checked == true &&
  66. document.getElementById("IsOpenedCheckBox_div").style.display != "none") {
  67. $.messager.alert("系统提示", "已开放状态的信息无法重复开放。");
  68. return false;
  69. }
  70. else if (r[i] != OpenedStatus && document.getElementById("IsOpened_CheckBox").checked == false &&
  71. document.getElementById("IsOpenedCheckBox_div").style.display != "none") {
  72. $.messager.alert("系统提示", "未开放状态的信息无法重复取消。");
  73. return false;
  74. }
  75. }
  76. }
  77. //新增按钮
  78. function OptionalCourseSetting_Add() {
  79. var d = validChoose();
  80. var r = statusvalidChoose();
  81. if (d.length > 1) {
  82. $.messager.alert("系统信息", "只能选择单个记录进行复制新增。");
  83. return;
  84. }
  85. if (d.length == 1) {
  86. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCourseSetting/Edit?ExecutableOptionalCourseIDs=" + d + "&MNU=" + mnu + "&type=add";
  87. $.popupTopWindow('限选设定复制新增', redirectTo, 750, 550, null, null);
  88. }
  89. else
  90. {
  91. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCourseSetting/Edit?MNU=" + mnu + "&type=add";
  92. $.popupTopWindow('限选设定新增', redirectTo, 750, 550, null, null);
  93. }
  94. }
  95. //修改按钮
  96. function OptionalCourseSetting_Update() {
  97. var d = validChoose();
  98. var r = statusvalidChoose();
  99. if (d == "") {
  100. $.messager.alert("系统信息", "请选择您要修改的信息。");
  101. return;
  102. }
  103. if (d.length > 1) {
  104. $.messager.alert("系统信息", "只能选择单个记录进行修改。");
  105. return;
  106. }
  107. if (r[0] == CreatedStatus) {
  108. $.messager.alert("系统提示", "已开班状态的信息无法修改。");
  109. return ;
  110. }
  111. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCourseSetting/Edit?ExecutableOptionalCourseIDs=" + d + "&MNU=" + mnu + "&type=edit";
  112. $.popupTopWindow('限选设定修改', redirectTo, 750, 550, null, null);
  113. }
  114. //删除
  115. function OptionalCourseSetting_Delete() {
  116. var d = validChoose().join(',');
  117. var r = statusvalidChoose();
  118. if (d == "") {
  119. $.messager.alert("系统提示", "请选择您要删除的信息。");
  120. return;
  121. }
  122. for (var i = 0; i < r.length; i++) {
  123. if (r[i] == CreatedStatus) {
  124. $.messager.alert("系统提示", "已开班状态的信息无法删除!");
  125. return ;
  126. }
  127. }
  128. $.messager.confirm("系统提示", "您确定要删除选择的信息?", function (r) {
  129. if (r) {
  130. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/OptionalCourseSetting/Delete', { optionalCourseSettingIDs: d }, function (data) {
  131. if (data == "删除成功!") {
  132. $.messager.alert("系统提示", data);
  133. $("#dgOptionalCourseSettingList").cmsXDataTable('load');
  134. } else {
  135. $.messager.alert("系统提示", data);
  136. }
  137. });
  138. }
  139. });
  140. }
  141. //开放
  142. function OptionalCourseSetting_Submit() {
  143. var d = validChoose().join(",");
  144. var r = statusvalidChoose();
  145. if (d == "") {
  146. $.messager.alert("系统提示", "请选择您要开放的信息。");
  147. return;
  148. }
  149. for (var i = 0; i < r.length; i++) {
  150. if (r[i] != NotOpenStatus) {
  151. $.messager.alert("系统提示", "已开放状态的信息无法重复开放。");
  152. return;
  153. }
  154. }
  155. $.messager.confirm("系统提示", "您确定要对选择的限选设定进行开放?", function (r) {
  156. if (r) {
  157. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/OptionalCourseSetting/Submit', { optionalCourseSettingIDs: d }, function (data) {
  158. if (data == "开放成功!") {
  159. $.messager.alert("系统提示", data);
  160. $("#dgOptionalCourseSettingList").cmsXDataTable('load');
  161. } else {
  162. $.messager.alert("系统提示", data);
  163. }
  164. });
  165. }
  166. });
  167. }
  168. //取消
  169. function OptionalCourseSetting_Cancel() {
  170. var d = validChoose().join(',');
  171. if (d == "") {
  172. $.messager.alert("系统信息", "请选择您要取消的信息。");
  173. return;
  174. }
  175. var status = statusvalidChoose();
  176. for (var i = 0; i < status.length; i++) {
  177. if (status[i] != OpenedStatus) {
  178. $.messager.alert("系统提示", "只能对已开放状态的信息进行取消。");
  179. return;
  180. }
  181. }
  182. $.messager.confirm("系统提示", "您确定要对选择的限选设定进行取消?", function (r) {
  183. if (r) {
  184. $.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/OptionalCourseSetting/Cancel', { optionalCourseSettingIDs: d }, function (data) {
  185. if (data == "取消成功!") {
  186. $.messager.alert("系统提示", data);
  187. $("#dgOptionalCourseSettingList").cmsXDataTable('load');
  188. } else {
  189. $.messager.alert("系统提示", data);
  190. }
  191. });
  192. }
  193. });
  194. }
  195. function QueryCoursematerialComboGrid(data) {
  196. reload();
  197. }
  198. function QuerySpecialtyComboGrid(data) {
  199. reload();
  200. }
  201. function QuerySchoolYearNumDropdownList(data) {
  202. reload();
  203. }
  204. function QueryIsEnableDropdownList(data) {
  205. reload();
  206. }
  207. function QueryIsOpenDropdownList(data) {
  208. reload();
  209. }
  210. function SelectCollegeComboGrid(data) {
  211. reload();
  212. }
  213. function SelectDictionaryGrade(data) {
  214. reload();
  215. }
  216. function QueryClassmajor(data) {
  217. document.getElementById("DefaultClassName").value = data.Name + "_" + document.getElementById("CourseName").value + "(限选)";
  218. // var GrademajorID = $("#GrademajorID").combogridX("getValue");
  219. // if (GrademajorID != null) {
  220. // var jsonString = "({'QueryParamsDatas':'GrademajorComboGrid|*|" + GrademajorID + "|@|'})";
  221. // $("#ClassmajorID").combogridX("reload", eval(jsonString));
  222. // }
  223. }
  224. function swapWeekSettings() {
  225. if ($("#weekExpander").attr("expanded") == "0") {
  226. $("#weekExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -50px 0");
  227. $("#weekExpander").closest("tr")
  228. .next().css("display", "")
  229. .next().css("display", "")
  230. .next().css("display", "")
  231. .next().css("display", "");
  232. $("#weekExpander").attr("expanded", "1");
  233. } else {
  234. $("#weekExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -32px 0");
  235. $("#weekExpander").closest("tr")
  236. .next().css("display", "none")
  237. .next().css("display", "none")
  238. .next().css("display", "none")
  239. .next().css("display", "none");
  240. $("#weekExpander").attr("expanded", "0");
  241. }
  242. }
  243. //弹出添加老师页面
  244. function OptionalCourseSetting_AddTeacher() {
  245. $.popupTopWindow('添加教师', CMS_SystemConfig.VirtualDirectoryPath + '/Common/TeacherSelect?FromMNU=' +
  246. mnu, 560, 480, AddTeachers_Confirm);
  247. }
  248. //确定添加教师
  249. function AddTeachers_Confirm(teacherList) {
  250. if (!teacherList) return;
  251. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  252. $.each(teacherList, function (index, value) {
  253. if ($.grep(teacherViewList, function (row, index) { return value.UserID == row.UserID; }).length == 0) {
  254. teacherViewList.push({
  255. ExecutableOptionalCourseID: $("#ExecutableOptionalCourseID").val(),
  256. UserID: value.UserID,
  257. LoginID: value.StaffCode,
  258. Name: value.Name,
  259. CollegeID: value.CollegeID,
  260. CollegeName: value.CollegeName,
  261. BirthDate: value.BirthDate,
  262. TeacherType: value.TeacherType,
  263. TeacherTypeName: value.TeacherTypeName,
  264. IncumbencyState: value.IncumbencyState,
  265. IncumbencyStateName: value.IncumbencyStateName,
  266. Title: value.Title,
  267. TitleName: value.TitleName,
  268. TeachingMethod: null,
  269. TeachingMethodDesc: null
  270. });
  271. }
  272. });
  273. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  274. }
  275. //获取选中的数据
  276. function validTeacherChoose() {
  277. var d = [];
  278. $.each($("#dgTeacherList").cmsXDataTable("getSelections"), function (index) {
  279. d.push(this);
  280. });
  281. return d;
  282. }
  283. function validClassChoose() {
  284. var d = [];
  285. $.each($("#dgClassList").cmsXDataTable("getSelections"), function (index) {
  286. d.push(this);
  287. });
  288. return d;
  289. }
  290. //删除添加教师信息
  291. function OptionalCourseSetting_DelTeacher() {
  292. var d = validTeacherChoose();
  293. var teacherViewList = $("#dgTeacherList").cmsXDataTable("getRows");
  294. var i, j;
  295. var len = teacherViewList.length;
  296. for (i = len - 1; i >= 0; i--) {
  297. for (j = 0; j < d.length; j++) {
  298. if (teacherViewList[i].UserID == d[j].UserID) {
  299. teacherViewList.splice(i, 1);
  300. break;
  301. }
  302. }
  303. }
  304. $("#dgTeacherList").cmsXDataTable("loadData", { rows: teacherViewList, total: teacherViewList.length });
  305. }
  306. //添加开放范围班级信息
  307. function OptionalCourseSetting_AddClass() {
  308. $.popupTopWindow('添加班级', CMS_SystemConfig.VirtualDirectoryPath + '/Common/ClassmajorSelect?FromMNU=' +
  309. mnu + "&GrademajorID=" +
  310. document.getElementById("GrademajorID").value, 600, 480, AddClass_Confirm);
  311. }
  312. //删除开放范围班级信息
  313. function OptionalCourseSetting_DelClass() {
  314. var d = validClassChoose();
  315. var classViewList = $("#dgClassList").cmsXDataTable("getRows");
  316. var i, j;
  317. var len = classViewList.length;
  318. for (i = len - 1; i >= 0; i--) {
  319. for (j = 0; j < d.length; j++) {
  320. if (classViewList[i].ClassmajorID == d[j].ClassmajorID) {
  321. classViewList.splice(i, 1);
  322. break;
  323. }
  324. }
  325. }
  326. $("#dgClassList").cmsXDataTable("loadData", { rows: classViewList, total: classViewList.length });
  327. }
  328. //保存开放范围班级信息
  329. function AddClass_Confirm(classList) {
  330. if (!classList) return;
  331. var classViewList = $("#dgClassList").cmsXDataTable("getRows");
  332. $.each(classList, function (index, value) {
  333. if ($.grep(classViewList, function (row, index) { return value.ClassmajorID == row.ClassmajorID; }).length == 0) {
  334. classViewList.push({
  335. ExecutableOptionalCourseID: $("#ExecutableOptionalCourseID").val(),
  336. ClassmajorID: value.ClassmajorID,
  337. Name: value.Name,
  338. No: value.No,
  339. StudentCount: value.StudentCount
  340. });
  341. }
  342. });
  343. $("#dgClassList").cmsXDataTable("loadData", { rows: classViewList, total: classViewList.length });
  344. }
  345. //开放范围
  346. function StudentList(rowindex, rowdata) {
  347. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/OptionalCourseSetting/ClassList?executableOptionalCourseID=" + rowdata.ExecutableOptionalCourseID + "&Type=" + rowdata.SelectCourseType + "&MNU=" + mnu;
  348. //var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SelectCourseResult/Student";
  349. $.popupTopWindow('开放范围', redirectTo, 700, 400, null, null);
  350. }
  351. function recalculate() {
  352. var theoryCourse = parseInt($("#TheoryCourse").val() == "" ? "0" : $("#TheoryCourse").val());
  353. var practicehours = parseInt($("#Practicehours").val() == "" ? "0" : $("#Practicehours").val());
  354. var theoryWeeklyNum = parseInt($("#TheoryWeeklyNum").val() == "" ? "0" : $("#TheoryWeeklyNum").val());
  355. var practiceWeeklyNum = parseInt($("#PracticeWeeklyNum").val() == "" ? "0" : $("#PracticeWeeklyNum").val());
  356. var totalHours = theoryCourse + practicehours;
  357. var totalWeeklyNum = theoryWeeklyNum + practiceWeeklyNum;
  358. var weeklyHours = totalHours / totalWeeklyNum;
  359. var weeklyNum = weeklyHours / 2;
  360. $("#Totalhours").val(totalHours);
  361. if (totalWeeklyNum != 0) {
  362. $("#SchoolweeksNum").val(totalWeeklyNum);
  363. $("#WeeklyHours").val(weeklyHours);
  364. $("#WeeklyNum").val(weeklyNum);
  365. }
  366. }
  367. //联动查询
  368. function queryStandard(data) {
  369. queryClass();
  370. }
  371. function queryCollege(data) {
  372. var campusID = $("#CampusDropdown").combogridX("getValue");
  373. var collegeID = $("#CollegeDropdown").combogridX("getValue");
  374. var jsonString = "({'QueryParamsDatas':'CampusDropdown|*|" + campusID + "|@|";
  375. jsonString += "CollegeDropdown|*|" + collegeID + "|@|'})";
  376. $("#CollegeDropdown").combogridX("reload", eval(jsonString));
  377. $("#StandardDictionaryDropDown").combogridX("reload", eval(jsonString));
  378. // if (campusID != nonSelect) {
  379. // var jsonString = "({'QueryParamsDatas':'CampusDropdown|*|" + campusID + "|@|'})";
  380. // $("#CollegeDropdown").combogridX("reload", eval(jsonString));
  381. // }
  382. queryClass();
  383. }
  384. function queryClass() {
  385. var jsonString = "";
  386. var parameterString = "";
  387. var campusID = $("#CampusDropdown").combogridX("getValue");
  388. var collegeID = $("#CollegeDropdown").combogridX("getValue");
  389. //var educationID = $("#Education").combobox("getValue");
  390. var schoolYearID = $("#SchoolyearDictionaryDropDown").combobox("getValue");
  391. var standardID = $("#StandardDictionaryDropDown").combogridX("getValue");
  392. //var learningFormID = $("#LearningformDictionaryDropDown").combobox("getValue");
  393. if (campusID != nonSelect) parameterString += "CampusDropdown|*|" + campusID + "|@|";
  394. if (collegeID != nonSelect) parameterString += "CollegeDropdown|*|" + collegeID + "|@|";
  395. //if (educationID != nonSelect) parameterString += "DictionaryEducation|*|" + educationID + "|@|";
  396. if (schoolYearID != nonSelect) parameterString += "DictionaryGrade|*|" + schoolYearID + "|@|";
  397. if (standardID != nonSelect) parameterString += "DictionaryStandard|*|" + standardID + "|@|";
  398. //if (learningFormID != nonSelect) parameterString += "DictionaryLearningform|*|" + learningFormID + "|@|";
  399. if (parameterString != "") {
  400. jsonString = "({'QueryParamsDatas':'" + parameterString + "'})";
  401. $("#GrademajorComboGrid").combogridX("reload", eval(jsonString));
  402. $("#StandardDictionaryDropDown").combogridX("reload", eval(jsonString));
  403. } else {
  404. $("#GrademajorComboGrid").combogridX("reload", eval(jsonString));
  405. $("#StandardDictionaryDropDown").combogridX("reload", eval(jsonString));
  406. }
  407. reload();
  408. }