You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
5.9 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

$(document).ready(function () {
//下拉菜单
selectHelper.GetSelect({
url: "/Admin/College/GetSelectCollegeList",
Id: "#selectCollege",
value: "请选择"
});
GetList();
//保存
$("#btnSave").click(function () {
var id = parseInt($("#classID").val());
var collegeId = $("#selectCollege").val();
if (id == 0) {
var num = CountClass(collegeId);
if (num == 50) {
dialogHelper.Error({ content: "该学院下班级数量最多只能有50个!" });
return;
}
}
//输入验证
if (!VerificationHelper.checkFrom("popAddClassInfo")) {
return;
}
$.ajax({
url: "/Admin/Class/SaveDetails",
type: "POST",
async: false,
dataType: "json",
data: {
Id: id,
ClassName: $.trim($("#className").val()),
CollegeId: collegeId,
SchoolId: $("#schoolId").val(),
Remark: $("#remark").val(),
Status: $("#status").val()
},
success: function (data) {
dialogHelper.Success({
content: "保存成功!",
success: function () {
location.href = location.href;
},
});
}
});
});
//关闭
$("#btnCancel").click(function () {
dialogHelper.Close("popAddClassInfo");
});
});
function GetList() {
pageHelper.Init({
url: "/Admin/Class/GetClassList",
type: "POST",
pageDiv: "#pages",
data: {},
bind: function (data) {
var html = "";
$(data.Data).each(function (index, dom) {
//每行html
var trHtml = "";
trHtml += "<tr>";
trHtml += "<td>{0}</td>";
var str = "";
if (dom.ClassName.length > 15) {
str = dom.ClassName.substr(0, 15) + "...";
} else {
str = dom.ClassName;
}
trHtml += "<td><div title=\"{1}\" class=\"ellipsis\">" + str + "</div></td>";
var str2 = "";
if (dom.strCollegeName.length > 15) {
str2 = dom.strCollegeName.substr(0, 15) + "...";
} else {
str2 = dom.strCollegeName;
}
trHtml += "<td><div title=\"{2}\" class=\"ellipsis\">" + str2 + "</div></td>"; // 字段错误(黄忠情 update 2016.09.21
trHtml += "<td><div title=\"{3}\" class=\"ellipsis\">{3}</div></td>";
trHtml += "<td>{4}</td>";
trHtml += "<td class=\"operate\">";
trHtml += "<a class=\"spr spr-edit\" title=\"编辑\" href=\"javascript:Edit({5});\"></a>";
trHtml += "<a class=\"spr spr-del\" title=\"删除\" href=\"javascript:Del({5});\"></a>";
trHtml += "</td>";
trHtml += "</tr>";
//拼接tbody
html += StringHelper.FormatStr(trHtml,
((data.PageIndex - 1) * data.PageSize + index + 1), //0 序号
dom.ClassName, //1 班级名称
dom.strCollegeName, //2 所属学院
dom.Remark, //3 备注
dom.CreateTimeStr, //4 创建时间
dom.Id //5 Id
);
});
$("#classList").html(html);
}
});
}
function Add() {
//数量检测
//重置界面内容
$("#classID").val(0);
$("#selectCollege").val(0);
$("#className").val("")
$("#remark").val("");
$("#selectCollege").removeAttr("disabled").removeClass("disabled");
//弹出表单
$("#popAddClassInfo h3").html("新增班级");
dialogHelper.Show("popAddClassInfo");
}
function Edit(id) {
$.ajax({
url: "/Admin/Class/Details",
type: "POST",
async: false,
dataType: "json",
data: {
id: id
},
success: function (data) {
$("#classID").val(data.Id);
$("#className").val(data.ClassName)
$("#selectCollege").val(data.CollegeId);
$("#remark").val(data.Remark);
$("#status").val(data.Status);
//学院字段只读
$("#selectCollege").attr("disabled", "disabled").addClass("disabled");
//弹出表单
$("#popAddClassInfo h3").html("编辑班级");
dialogHelper.Show("popAddClassInfo");
}
});
}
function Del(id) {
dialogHelper.Confirm({
content: "将删除班级下所有学生账号与数据,是否确定删除?",
success: function () {
$.ajax({
url: "/Admin/Class/DeleteClass",
type: "POST",
async: false,
dataType: "json",
data: {
classID: id
},
success: function (data) {
dialogHelper.Success({
content: "删除成功!",
success: function () {
location.href = location.href;
},
});
}
});
},
cancle: function () { }
});
}
function CountClass(collegeId) {
var num = 0;
$.ajax({
url: "/Admin/Class/CountClass",
type: "POST",
async: false,
dataType: "json",
data:
{
collegeId: collegeId
},
success: function (data) {
num = data.Num;
}
});
return num;
}