FreeSelectionCourseApplyTeacherEdit.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //获取选中的数据
  2. function validChoose() {
  3. var d = [];
  4. $.each($("#dgStaffList").cmsXDataTable("getSelections"), function (index) {
  5. d.push(this);
  6. });
  7. return d;
  8. }
  9. function reload() {
  10. $("#dgStaffList").cmsXDataTable("load", $.getDataGridParams("dgStaffList"));
  11. }
  12. function delTeacher(rowindex, rowdata) {
  13. var data = $("#dgTeacherList").cmsXDataTable("options").data;
  14. data.rows = $.grep(data.rows, function (row, index) { return row.UserID != rowdata.UserID });
  15. $("#dgTeacherList").cmsXDataTable("loadData", data);
  16. }
  17. function FreeSelectionCourseSetting_TeacherSave() {
  18. var selectedTeacher = validChoose();
  19. var currentTeacher = $("#dgTeacherList").cmsXDataTable("options").data.rows;
  20. var isValidated = true;
  21. var duplicateTeacher;
  22. $.each(selectedTeacher, function () {
  23. var curSelectedTeacher = this;
  24. if (!(curSelectedTeacher.TeachingMethod && curSelectedTeacher.TeachingMethod >= 0)) {
  25. isValidated = false;
  26. return false;
  27. }
  28. if ($.grep(currentTeacher, function (row, index) { return row.UserID == curSelectedTeacher.UserID; }).length > 0) {
  29. duplicateTeacher = curSelectedTeacher;
  30. return false;
  31. }
  32. });
  33. if (!isValidated) {
  34. $.messager.alert('系统信息', '请为选中的教师都指定一种任课方式。');
  35. return;
  36. }
  37. if (duplicateTeacher) {
  38. $.messager.alert('系统信息', duplicateTeacher.Name + '已经在任课老师列表中,无需重复添加。');
  39. return;
  40. }
  41. var allTeacher = selectedTeacher.concat(currentTeacher);
  42. $.ajax({
  43. url: CMS_SystemConfig.VirtualDirectoryPath + "/FreeSelectionCourseApply/TeacherEdit",
  44. data: {
  45. freeSelectionCourseApplyID: $.SystemGeneral.getUrlParam("FreeSelectionCourseApplyID"),
  46. addTeacherListJson: JSON.stringify(allTeacher)
  47. },
  48. dataType: 'json',
  49. success: function (data) {
  50. if (data.IsSuccess) {
  51. Teacher_Confirm();
  52. }
  53. else {
  54. $.messager.alert('系统信息', data.Message);
  55. }
  56. }
  57. });
  58. }
  59. function QueryCampusDropdownList(data) {
  60. $("#CollegeDropdown").combobox("reload", CMS_SystemConfig.VirtualDirectoryPath + "/College/CollegeDropdownListBanid?campusID=" + data.Value + "");
  61. }
  62. function QueryDepartmentDropdownList(data) {
  63. reload();
  64. }