123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- //加载
- $(function () {
- $("#GroupNum").attr("disabled", true);
- $("#StudentNum").attr("disabled", true);
- //任务班数
- $("#IsGroup").click(function () {
- $("#IsAverageStudent").attr("checked", false);
- $("#OrderType").attr("checked", false);
- $("#StudentNum").attr("disabled", true);
- $("#GroupNum").attr("disabled", false);
- if ($("#IsGroup").attr("checked") != "checked") {
- $("#GroupNum").attr("disabled", true);
- }
-
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- });
- //平均人数
- $("#IsAverageStudent").click(function () {
- $("#IsGroup").attr("checked", false);
- $("#OrderType").attr("checked", false);
- $("#StudentNum").attr("disabled", false);
- $("#GroupNum").attr("disabled", true);
- if ($("#IsAverageStudent").attr("checked") != "checked") {
- $("#StudentNum").attr("disabled", true);
- }
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- });
- //排序方式
- $("#OrderType").click(function () {
- $("#IsAverageStudent").attr("checked", false);
- $("#IsGroup").attr("checked", false);
- $("#StudentNum").attr("disabled", true);
- $("#GroupNum").attr("disabled", true);
- });
- $("#GroupNum").blur(function () {
- AverageNum(false);
- });
- $("#StudentNum").blur(function () {
- AverageNum(true);
- });
- })
- //计算(向上取整)
- function AverageNum(obj) {
- //非零的正整数(/^[0-9]*$/)
- var reg = /^[0-9]*$/;
-
- var totalnum = 0;
- var studentTotalNum = $("#StudentTotalNum").val();
- var groupNum = $("#GroupNum").val();
- var studentNum = $("#StudentNum").val();
- if (!reg.test(groupNum)) {
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- $.messager.alert("系统提示", "请输入正整数。");
- return;
- }
- if (!reg.test(studentNum)) {
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- $.messager.alert("系统提示", "请输入正整数。");
- return;
- }
- if (obj) {
- //按平均人数进行分班
- if (studentTotalNum != "" || studentTotalNum != 0) {
- if (studentNum == "" || studentNum == 0) {
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- return;
- }
- if (parseInt(studentNum) >= parseInt(studentTotalNum)) {
- $.messager.alert("系统提示", "每班人数不能大于等于计划人数。");
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- return;
- }
- //向上取整
- totalnum = Math.ceil(parseInt(studentTotalNum) / parseInt(studentNum));
- $("#hid_StudentNum").val(studentNum);
- $("#hid_GroupNum").val(parseInt(totalnum));
- $("#GroupNum").val(parseInt(totalnum));
- }
- }
- else {
- //按任务班数进行分班
- if (studentTotalNum != "" || studentTotalNum != 0) {
- if (groupNum == "" || groupNum == 0) {
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- return;
- }
- if (parseInt(groupNum) <= 1) {
- $.messager.alert("系统提示", "任务班数不能小于等于1。");
- $("#GroupNum").val("");
- $("#StudentNum").val("");
- return;
- }
- totalnum = Math.ceil(parseInt(studentTotalNum) / parseInt(groupNum));
- $("#hid_GroupNum").val(groupNum);
- $("#hid_StudentNum").val(parseInt(totalnum));
- $("#StudentNum").val(parseInt(totalnum));
- }
- }
- }
- //确定分班
- function RetakePlanTaskSeparate_Confirm() {
- var studentNum = $("#StudentNum").val();
- var groupNum = $("#GroupNum").val();
- var OrderType = $("#OrderType").val();
- $("#hid_StudentTotalNum").val($("#StudentTotalNum").val());
- if ($("#IsGroup").attr("checked") != "checked" && $("#IsAverageStudent").attr("checked") != "checked") {
- $.messager.alert("系统提示", "请选择分班方式。");
- return;
- }
- if ((groupNum == "" || studentNum == "") && OrderType != "true") {
- $.messager.alert("系统提示", "任务班数或每班人数不能为空。");
- return;
- }
- $.messager.confirm("系统提示", "请确认是否要按选择的分班方式进行分班?", function (r) {
- if (r) {
- $(document.forms[0]).submit();
- }
- });
- }
|