ClassroomExcessiveUseEdit.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. })
  6. //获取选中的数据
  7. function validSchedulingChoose() {
  8. var d = [];
  9. $.each($("#dgSchedulingList").cmsXDataTable("getSelections"), function (index) {
  10. d.push(this);
  11. });
  12. return d;
  13. }
  14. //添加时间安排
  15. function Scheduling_Add() {
  16. var schoolyearID = $("#SchoolyearID").combobox("getValue");
  17. var classroom = $("#ClassroomID").combogridX("getValue");
  18. if (classroom == nonSelect || classroom == "") {
  19. $.messager.alert('系统信息', "请先选择教室再添加时间安排。");
  20. } else {
  21. $.popupTopWindow('添加时间安排', CMS_SystemConfig.VirtualDirectoryPath + '/ClassroomExcessiveUse/SchedulingEdit?MNU=' + mnu + '&schoolyearID=' + schoolyearID + '&classroom=' + classroom, 600, 400, Scheduling_Add_Confirm);
  22. }
  23. }
  24. function Scheduling_Add_Confirm(scheduling) {
  25. if (!scheduling) return;
  26. var schedulingList = $("#dgSchedulingList").cmsXDataTable("getRows");
  27. if ($.grep(schedulingList, function (row, index) {
  28. if (scheduling.Weekday == row.Weekday && scheduling.CoursesTimeID == row.CoursesTimeID) {
  29. for (var i = 0; i < row.WeekNumList.length; i++) {
  30. if (scheduling.WeekNumList.contains(row.WeekNumList[i])) {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }).length == 0) {
  37. schedulingList.push({
  38. ClassroomExcessiveUseSchedulingID: Guid.NewGuid().ToString(),
  39. WeekNumList: scheduling.WeekNumList,
  40. Weekday: scheduling.Weekday,
  41. WeekdayDesc: scheduling.WeekdayDesc,
  42. CoursesTimeID: scheduling.CoursesTimeID,
  43. StartTimes: scheduling.StartTimes,
  44. EndTimes: scheduling.EndTimes,
  45. StartHour: scheduling.StartHour,
  46. StartMinute: scheduling.StartMinute,
  47. EndHour: scheduling.EndHour,
  48. EndMinute: scheduling.EndMinute,
  49. TimeDesc: scheduling.TimeDesc
  50. });
  51. $("#dgSchedulingList").cmsXDataTable("loadData", { rows: schedulingList, total: schedulingList.length });
  52. } else {
  53. $.messager.alert('系统信息', "请检查输入的时间安排,不要重复添加。");
  54. }
  55. }
  56. function Scheduling_Delete() {
  57. var d = validSchedulingChoose();
  58. var schedulingList = $("#dgSchedulingList").cmsXDataTable("getRows");
  59. var i, j;
  60. var len = schedulingList.length;
  61. for (i = len - 1; i >= 0; i--) {
  62. for (j = 0; j < d.length; j++) {
  63. if (schedulingList[i].ClassroomExcessiveUseSchedulingID == d[j].ClassroomExcessiveUseSchedulingID) {
  64. schedulingList.splice(i, 1);
  65. break;
  66. }
  67. }
  68. }
  69. $("#dgSchedulingList").cmsXDataTable("loadData", { rows: schedulingList, total: schedulingList.length });
  70. }
  71. function Scheduling_Edit(rowindex, rowdata) {
  72. $.popupTopWindow('添加时间安排', CMS_SystemConfig.VirtualDirectoryPath + '/ClassroomExcessiveUse/SchedulingEdit?MNU=' + mnu, 600, 300, Scheduling_Edit_Confirm, rowdata);
  73. }
  74. function Scheduling_Edit_Confirm(scheduling) {
  75. if (!scheduling) return;
  76. var schedulingList = $("#dgSchedulingList").cmsXDataTable("getRows");
  77. if ($.grep(schedulingList, function (row, index) {
  78. if (scheduling.Weekday == row.Weekday && scheduling.CoursesTimeID == row.CoursesTimeID && scheduling.ClassroomExcessiveUseSchedulingID != row.ClassroomExcessiveUseSchedulingID) {
  79. for (var i = 0; i < row.WeekNumList.length; i++) {
  80. if (scheduling.WeekNumList.contains(row.WeekNumList[i])) {
  81. return true;
  82. }
  83. }
  84. }
  85. return false;
  86. }).length == 0) {
  87. var curSchedulingList = $.grep(schedulingList, function (row, index) { return scheduling.ClassroomExcessiveUseSchedulingID == row.ClassroomExcessiveUseSchedulingID; });
  88. if (curSchedulingList.length == 0) return;
  89. var curScheduling = curSchedulingList[0];
  90. curScheduling.WeekNumList = scheduling.WeekNumList;
  91. curScheduling.Weekday = scheduling.Weekday;
  92. curScheduling.WeekdayDesc = scheduling.WeekdayDesc;
  93. curScheduling.CoursesTimeID = scheduling.CoursesTimeID;
  94. curScheduling.StartTimes = scheduling.StartTimes;
  95. curScheduling.EndTimes = scheduling.EndTimes;
  96. curScheduling.StartHour = scheduling.StartHour;
  97. curScheduling.StartMinute = scheduling.StartMinute;
  98. curScheduling.EndHour = scheduling.EndHour;
  99. curScheduling.EndMinute = scheduling.EndMinute;
  100. curScheduling.TimeDesc = scheduling.TimeDesc;
  101. $("#dgSchedulingList").cmsXDataTable("loadData", { rows: schedulingList, total: schedulingList.length });
  102. } else {
  103. $.messager.alert('系统信息', "请检查输入的时间安排,不要重复添加。");
  104. }
  105. }
  106. function ClassroomExcessiveUse_Save() {
  107. $(document.forms[0]).submit();
  108. }
  109. function popupClassroomReport(classroomID) {
  110. var schoolYearID = $("#SchoolyearID").combobox("getValue");
  111. var fullUrl = CMS_SystemConfig.ReportPagePath + "?ReportFolder=%2fEducationScheduling%2fClassroomSchedulingView&BuildingsInfoID_RAP=&ClassroomID_RAP=" + classroomID + "&SchoolyearID_RAP=" + schoolYearID;
  112. $.popupTopWindowOutsite('教室课表', fullUrl, 1024, 600);
  113. }
  114. function FormSuccess(data) {
  115. $('a').removeAttr('disabled', 'disabled');
  116. $('#loading').hide();
  117. if (data.IsSuccess) {
  118. $.messager.alert('系统信息', data.Message, null, function () {
  119. var dialogId = $.SystemGeneral.getUrlParam('WindowID');
  120. dialogId = (dialogId == null || dialogId == '') ? 'sysWindow' : dialogId;
  121. try {
  122. top.$('#' + dialogId).window('close');
  123. } catch (e) {
  124. }
  125. var tab = top.$('#index_center_tabs').tabs('getSelected');
  126. var $iframe = tab.panel('body').find("iframe");
  127. if ($iframe[0].contentWindow.reload)
  128. $iframe[0].contentWindow.reload();
  129. });
  130. } else {
  131. var classroomID = $("#ClassroomID").combogridX("getValue");
  132. var classroomName = $("#ClassroomID").combogridX("getText");
  133. var reportLink = "点击下列链接查看相关教室的课表:<br>";
  134. reportLink += '<a href="#this" onclick="javascript:popupClassroomReport(\'' + classroomID + '\');" style="color: #0000ff;">';
  135. reportLink += classroomName + "课表";
  136. reportLink += "</a>&nbsp;";
  137. $.messager.alert("系统提示", data.Message + reportLink);
  138. }
  139. }