123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //加载
- $(function () {
- //非负浮点数(/^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$/)
- var reg = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$/;
- var learnSystem = $("#LearnSystem").val();
- if (learnSystem == "" || learnSystem == null) {
- $("#LearnSystem").val("");
- }
- else {
- if (!reg.test(learnSystem)) {
- $("#LearnSystem").val("");
- }
- else {
- $("#LearnSystem").val(parseFloat(learnSystem).toFixed(1));
- }
- }
- $("#PlanRecruitStudentCount").blur(function () {
- CalculateClassNumber(true);
- });
- $("#ClassArrangeStudentCount").blur(function () {
- CalculateClassNumber(true);
- });
- $("#ClassMaxStudentCount").blur(function () {
- CalculateClassNumber(true);
- });
- });
- //计算对应的班级个数
- function CalculateClassNumber(obj) {
- //非负的整数(/^\d+$/)
- var reg = /^\d+$/;
- var planRecruitStudentCount = $("#PlanRecruitStudentCount").val();
- var classArrangeStudentCount = $("#ClassArrangeStudentCount").val();
- var classMaxStudentCount = $("#ClassMaxStudentCount").val();
- if (!reg.test(planRecruitStudentCount)) {
- $.messager.alert("系统提示", "请输入非负整数。");
- $("#PlanRecruitStudentCount").val("");
- $("#ClassNumber").val("");
- return;
- }
- if (!reg.test(classArrangeStudentCount)) {
- $.messager.alert("系统提示", "请输入非负整数。");
- $("#ClassArrangeStudentCount").val("");
- $("#ClassNumber").val("");
- return;
- }
- if (!reg.test(classMaxStudentCount)) {
- $.messager.alert("系统提示", "请输入非负整数。");
- $("#ClassMaxStudentCount").val("");
- $("#ClassNumber").val("");
- return;
- }
- //if (parseInt(classMaxStudentCount) < parseInt(classArrangeStudentCount)) {
- // $.messager.alert("系统提示", "每班预招人数不能大于每班最大人数。");
- // $("#ClassNumber").val("");
- // return;
- //}
- if (obj) {
- if (planRecruitStudentCount == "0") {
- $("#ClassNumber").val("1");
- }
- else if (classArrangeStudentCount == "0") {
- $("#ClassNumber").val("1");
- }
- else if (classMaxStudentCount == "0") {
- $("#ClassNumber").val("1");
- }
- else {
- //取整
- var classNumber = parseInt(parseInt(planRecruitStudentCount) / parseInt(classArrangeStudentCount));
- var total = classNumber * parseInt(classMaxStudentCount);
- if (total >= parseInt(planRecruitStudentCount)) {
- $("#ClassNumber").val(parseInt(classNumber));
- }
- else {
- $("#ClassNumber").val(parseInt(classNumber + 1));
- }
- }
- }
- }
- //保存
- function SpecialtyClassSetting_Save() {
- var planRecruitStudentCount = $("#PlanRecruitStudentCount").val();
- var classArrangeStudentCount = $("#ClassArrangeStudentCount").val();
- var classMaxStudentCount = $("#ClassMaxStudentCount").val();
- var classNumber = $("#ClassNumber").val();
- if (planRecruitStudentCount == "") {
- $.messager.alert("系统提示", "计划招生人数不能为空,请输入。");
- $("#ClassNumber").val("");
- return;
- }
- if (classArrangeStudentCount == "") {
- $.messager.alert("系统提示", "每班预招人数不能为空,请输入。");
- $("#ClassNumber").val("");
- return;
- }
- if (classMaxStudentCount == "") {
- $.messager.alert("系统提示", "每班最大人数不能为空,请输入。");
- $("#ClassNumber").val("");
- return;
- }
- if (parseInt(classMaxStudentCount) < parseInt(classArrangeStudentCount)) {
- $.messager.alert("系统提示", "每班预招人数不能大于每班最大人数。");
- $("#ClassNumber").val("");
- return;
- }
- if (classNumber == "") {
- $.messager.alert("系统提示", "班级个数不能为空,请输入。");
- return;
- }
- $.messager.confirm("系统提示", "请确认是否要按此信息进行专业分班?", function (r) {
- if (r) {
- CalculateClassNumber(true);
- $("#ClassNumber").attr("disabled", false);
- $(document.forms[0]).submit();
- }
- });
- }
- //联动
- function querySpecialty(data) {
- var specialtyID = $("#SpecialtyID").combogridX("getValue");
- if (specialtyID == "" || specialtyID == "-1" || specialtyID == null) {
- $("#Code").val("");
- $("#EducationID").combogridX("setValue", "-1");
- $("#LearningformID").combogridX("setValue", "-1");
- $("#LearnSystem").val("");
- $("#ScienceclassID").combogridX("setValue", "-1");
- }
- else {
- $("#Code").val(data.Code);
- $("#EducationID").combogridX("setValue", data.EducationID);
- $("#LearningformID").combogridX("setValue", data.LearningformID);
- $("#LearnSystem").val(data.LearnSystem);
- $("#ScienceclassID").combogridX("setValue", data.ScienceclassID);
- }
- }
|