SpecialtyCourseEdit.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //加载
  2. $(function () {
  3. //非负浮点数(/^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$/)
  4. var reg = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$/;
  5. var learnSystem = $("#LearnSystem").val();
  6. if (learnSystem == "" || learnSystem == null) {
  7. $("#LearnSystem").val("");
  8. }
  9. else {
  10. if (!reg.test(learnSystem)) {
  11. $("#LearnSystem").val("");
  12. }
  13. else {
  14. $("#LearnSystem").val(parseFloat(learnSystem).toFixed(1));
  15. }
  16. }
  17. $("#Credit").val(parseFloat($("#Credit").val()));
  18. $("#TheoryCourse").keyup(function () {
  19. recalculate();
  20. });
  21. $("#Practicehours").keyup(function () {
  22. recalculate();
  23. });
  24. $("#TheoryWeeklyNum").keyup(function () {
  25. recalculate();
  26. });
  27. $("#PracticeWeeklyNum").keyup(function () {
  28. recalculate();
  29. });
  30. $("#teachingSettingExpander").closest("tr")
  31. .next().css("display", "")
  32. .next().css("display", "none")
  33. .next().css("display", "none")
  34. .next().css("display", "none")
  35. .next().css("display", "none")
  36. .next().css("display", "none")
  37. .next().css("display", "none");
  38. $("#teachingSettingExpander").attr("expanded", "1");
  39. $("#otherExpander").closest("tr")
  40. .next().css("display", "none")
  41. .next().css("display", "none")
  42. .next().css("display", "none")
  43. .next().css("display", "none")
  44. .next().css("display", "none")
  45. .next().css("display", "")
  46. .next().css("display", "")
  47. .next().css("display", "")
  48. .next().css("display", "none");
  49. $("#otherExpander").attr("expanded", "1");
  50. });
  51. //相关计算
  52. function recalculate() {
  53. var theoryCourse = parseInt($("#TheoryCourse").val() == "" ? "0" : $("#TheoryCourse").val());
  54. var practicehours = parseInt($("#Practicehours").val() == "" ? "0" : $("#Practicehours").val());
  55. var theoryWeeklyNum = parseInt($("#TheoryWeeklyNum").val() == "" ? "0" : $("#TheoryWeeklyNum").val());
  56. var practiceWeeklyNum = parseInt($("#PracticeWeeklyNum").val() == "" ? "0" : $("#PracticeWeeklyNum").val());
  57. var totalHours = theoryCourse + practicehours;
  58. var totalWeeklyNum = theoryWeeklyNum + practiceWeeklyNum;
  59. var weeklyHours = totalHours / totalWeeklyNum;
  60. var weeklyNum = weeklyHours / 2;
  61. $("#Totalhours").val(totalHours);
  62. if (totalWeeklyNum != 0) {
  63. $("#SchoolweeksNum").val(totalWeeklyNum);
  64. $("#WeeklyHours").val(weeklyHours);
  65. $("#WeeklyNum").val(weeklyNum);
  66. }
  67. }
  68. //点击收缩(教学设置信息)
  69. function swapTeachingSetting() {
  70. if ($("#teachingSettingExpander").attr("expanded") == "1") {
  71. $("#teachingSettingExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -32px 0");
  72. $("#teachingSettingExpander").closest("tr")
  73. .next().css("display", "")
  74. .next().css("display", "")
  75. .next().css("display", "")
  76. .next().css("display", "")
  77. .next().css("display", "")
  78. .next().css("display", "")
  79. .next().css("display", "");
  80. $("#teachingSettingExpander").attr("expanded", "0");
  81. } else {
  82. $("#teachingSettingExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -50px 0");
  83. $("#teachingSettingExpander").closest("tr")
  84. .next().css("display", "")
  85. .next().css("display", "none")
  86. .next().css("display", "none")
  87. .next().css("display", "none")
  88. .next().css("display", "none")
  89. .next().css("display", "none")
  90. .next().css("display", "none");
  91. $("#teachingSettingExpander").attr("expanded", "1");
  92. }
  93. }
  94. //点击收缩(其它信息)
  95. function swapother() {
  96. if ($("#otherExpander").attr("expanded") == "1") {
  97. $("#otherExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -32px 0");
  98. $("#otherExpander").closest("tr")
  99. .next().css("display", "")
  100. .next().css("display", "")
  101. .next().css("display", "")
  102. .next().css("display", "")
  103. .next().css("display", "")
  104. .next().css("display", "")
  105. .next().css("display", "")
  106. .next().css("display", "")
  107. .next().css("display", "");
  108. $("#otherExpander").attr("expanded", "0");
  109. } else {
  110. $("#otherExpander").css("background", "url('../../Content/Bowin.Control.Core/themes/metro-blue/images/tree_icons.png') no-repeat -50px 0");
  111. $("#otherExpander").closest("tr")
  112. .next().css("display", "none")
  113. .next().css("display", "none")
  114. .next().css("display", "none")
  115. .next().css("display", "none")
  116. .next().css("display", "none")
  117. .next().css("display", "")
  118. .next().css("display", "")
  119. .next().css("display", "")
  120. .next().css("display", "none");
  121. $("#otherExpander").attr("expanded", "1");
  122. }
  123. }
  124. //设置列颜色为红色
  125. function SetRedColumn(index, row, value) {
  126. return " <span style=\"color: red;\">" + value + "</span>";
  127. }
  128. //联动
  129. function querySpecialty(data) {
  130. var specialtyID = $("#SpecialtyID").combogridX("getValue");
  131. if (specialtyID == "" || specialtyID == "-1" || specialtyID == null) {
  132. $("#StandardCode").val("");
  133. $("#EducationID").combobox("setValue", "-1");
  134. $("#LearningformID").combobox("setValue", "-1");
  135. $("#LearnSystem").val("");
  136. }
  137. else {
  138. $("#StandardCode").val(data.Code);
  139. $("#EducationID").combobox("setValue", data.EducationID);
  140. $("#LearningformID").combobox("setValue", data.LearningformID);
  141. $("#LearnSystem").val(data.LearnSystem);
  142. }
  143. }
  144. //保存
  145. function SpecialtyCourse_Save() {
  146. if ($("input[name='TeachingModeIDList']:checked").length == 0) {
  147. $.messager.alert("系统提示", "请选择至少一种授课方式。");
  148. return;
  149. }
  150. if (!isNaN($("#Trialhours").val()) && $("#Trialhours").val() != ""
  151. && !isNaN($("#Practicehours").val()) && $("#Practicehours").val() != ""
  152. && parseFloat($("#Trialhours").val()) > parseFloat($("#Practicehours").val())) {
  153. $.messager.alert("系统提示", "实验学时不能大于实践学时。");
  154. return;
  155. }
  156. if (!isNaN($("#TrialWeeklyNum").val()) && $("#TrialWeeklyNum").val() != ""
  157. && !isNaN($("#PracticeWeeklyNum").val()) && $("#PracticeWeeklyNum").val() != ""
  158. && parseFloat($("#TrialWeeklyNum").val()) > parseFloat($("#PracticeWeeklyNum").val())) {
  159. $.messager.alert("系统提示", "实验周次不能大于实践周次。");
  160. return;
  161. }
  162. $(document.forms[0]).submit();
  163. }