SpecialtyClassSettingEdit.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. $("#PlanRecruitStudentCount").blur(function () {
  18. CalculateClassNumber(true);
  19. });
  20. $("#ClassArrangeStudentCount").blur(function () {
  21. CalculateClassNumber(true);
  22. });
  23. $("#ClassMaxStudentCount").blur(function () {
  24. CalculateClassNumber(true);
  25. });
  26. });
  27. //计算对应的班级个数
  28. function CalculateClassNumber(obj) {
  29. //非负的整数(/^\d+$/)
  30. var reg = /^\d+$/;
  31. var planRecruitStudentCount = $("#PlanRecruitStudentCount").val();
  32. var classArrangeStudentCount = $("#ClassArrangeStudentCount").val();
  33. var classMaxStudentCount = $("#ClassMaxStudentCount").val();
  34. if (!reg.test(planRecruitStudentCount)) {
  35. $.messager.alert("系统提示", "请输入非负整数。");
  36. $("#PlanRecruitStudentCount").val("");
  37. $("#ClassNumber").val("");
  38. return;
  39. }
  40. if (!reg.test(classArrangeStudentCount)) {
  41. $.messager.alert("系统提示", "请输入非负整数。");
  42. $("#ClassArrangeStudentCount").val("");
  43. $("#ClassNumber").val("");
  44. return;
  45. }
  46. if (!reg.test(classMaxStudentCount)) {
  47. $.messager.alert("系统提示", "请输入非负整数。");
  48. $("#ClassMaxStudentCount").val("");
  49. $("#ClassNumber").val("");
  50. return;
  51. }
  52. //if (parseInt(classMaxStudentCount) < parseInt(classArrangeStudentCount)) {
  53. // $.messager.alert("系统提示", "每班预招人数不能大于每班最大人数。");
  54. // $("#ClassNumber").val("");
  55. // return;
  56. //}
  57. if (obj) {
  58. if (planRecruitStudentCount == "0") {
  59. $("#ClassNumber").val("1");
  60. }
  61. else if (classArrangeStudentCount == "0") {
  62. $("#ClassNumber").val("1");
  63. }
  64. else if (classMaxStudentCount == "0") {
  65. $("#ClassNumber").val("1");
  66. }
  67. else {
  68. //取整
  69. var classNumber = parseInt(parseInt(planRecruitStudentCount) / parseInt(classArrangeStudentCount));
  70. var total = classNumber * parseInt(classMaxStudentCount);
  71. if (total >= parseInt(planRecruitStudentCount)) {
  72. $("#ClassNumber").val(parseInt(classNumber));
  73. }
  74. else {
  75. $("#ClassNumber").val(parseInt(classNumber + 1));
  76. }
  77. }
  78. }
  79. }
  80. //保存
  81. function SpecialtyClassSetting_Save() {
  82. var planRecruitStudentCount = $("#PlanRecruitStudentCount").val();
  83. var classArrangeStudentCount = $("#ClassArrangeStudentCount").val();
  84. var classMaxStudentCount = $("#ClassMaxStudentCount").val();
  85. var classNumber = $("#ClassNumber").val();
  86. if (planRecruitStudentCount == "") {
  87. $.messager.alert("系统提示", "计划招生人数不能为空,请输入。");
  88. $("#ClassNumber").val("");
  89. return;
  90. }
  91. if (classArrangeStudentCount == "") {
  92. $.messager.alert("系统提示", "每班预招人数不能为空,请输入。");
  93. $("#ClassNumber").val("");
  94. return;
  95. }
  96. if (classMaxStudentCount == "") {
  97. $.messager.alert("系统提示", "每班最大人数不能为空,请输入。");
  98. $("#ClassNumber").val("");
  99. return;
  100. }
  101. if (parseInt(classMaxStudentCount) < parseInt(classArrangeStudentCount)) {
  102. $.messager.alert("系统提示", "每班预招人数不能大于每班最大人数。");
  103. $("#ClassNumber").val("");
  104. return;
  105. }
  106. if (classNumber == "") {
  107. $.messager.alert("系统提示", "班级个数不能为空,请输入。");
  108. return;
  109. }
  110. $.messager.confirm("系统提示", "请确认是否要按此信息进行专业分班?", function (r) {
  111. if (r) {
  112. CalculateClassNumber(true);
  113. $("#ClassNumber").attr("disabled", false);
  114. $(document.forms[0]).submit();
  115. }
  116. });
  117. }
  118. //联动
  119. function querySpecialty(data) {
  120. var specialtyID = $("#SpecialtyID").combogridX("getValue");
  121. if (specialtyID == "" || specialtyID == "-1" || specialtyID == null) {
  122. $("#Code").val("");
  123. $("#EducationID").combogridX("setValue", "-1");
  124. $("#LearningformID").combogridX("setValue", "-1");
  125. $("#LearnSystem").val("");
  126. $("#ScienceclassID").combogridX("setValue", "-1");
  127. }
  128. else {
  129. $("#Code").val(data.Code);
  130. $("#EducationID").combogridX("setValue", data.EducationID);
  131. $("#LearningformID").combogridX("setValue", data.LearningformID);
  132. $("#LearnSystem").val(data.LearnSystem);
  133. $("#ScienceclassID").combogridX("setValue", data.ScienceclassID);
  134. }
  135. }