$(document).ready(function () {
GetList();
//保存
$("#btnSave").click(function () {
//输入验证
if (!VerificationHelper.checkFrom("popAddInfo")) {
return;
}
$.ajax({
url: "/Admin/College/SaveDetails",
type: "POST",
async: false,
dataType: "json",
data: {
Id: $("#collegeID").val(),
CollegeName: $.trim($("#collegeName").val()),
Contacts: $("#contract").val(),
Tel: $("#tel").val(),
Address: $("#address").val()
},
success: function (data) {
dialogHelper.Success({
content: "保存成功!",
success: function () {
location.href = location.href;
},
});
}
});
});
//关闭
$("#btnCancel").click(function () {
dialogHelper.Close("popAddInfo");
});
});
function GetList() {
pageHelper.Init({
url: "/Admin/College/GetCollegeList",
type: "POST",
pageDiv: "#pages",
data: {
},
bind: function (data) {
var html = "";
$(data.Data).each(function (index, dom) {
//每行html
var trHtml = "";
trHtml += "
";
trHtml += "{0} | ";
trHtml += "{1} | ";
trHtml += "{2} | ";
trHtml += "{3} | ";
trHtml += "{4} | ";
trHtml += "{5} | ";
trHtml += "";
trHtml += "";
trHtml += "";
trHtml += " | ";
trHtml += "
";
//拼接tbody
html += StringHelper.FormatStr(trHtml,
((data.PageIndex - 1) * data.PageSize + index + 1), //0 序号
dom.CollegeName, //1 院系名称
dom.Contacts, //2 联系人
dom.Tel, //3 联系电话
dom.Address, //4 地址
dom.CreateTimeStr, //5 创建日期
dom.Id //6 Id
);
});
$("#collegeList").html(html);
}
});
}
function Add() {
//数量检测
var num = parseInt($("#pageTotalCount").val());
if (num >= 20) {
dialogHelper.Error({ content: "院系数量最多只能有20个!" });
return;
}
//重置界面内容
$("#collegeID").val(0);
$("#collegeName").val("");
$("#contract").val("");
$("#tel").val("");
$("#address").val("");
//弹出表单
$("#popAddInfo h3").html("新增院系");
dialogHelper.Show("popAddInfo");
}
function Edit(id) {
$.ajax({
url: "/Admin/College/Details",
type: "POST",
async: false,
dataType: "json",
data: {
collegeID: id
},
success: function (data) {
$("#collegeID").val(data.Id);
$("#collegeName").val(data.CollegeName);
$("#contract").val(data.Contacts);
$("#tel").val(data.Tel);
$("#address").val(data.Address);
//弹出表单
$("#popAddInfo h3").html("编辑院系");
dialogHelper.Show("popAddInfo");
}
});
}
function Del(id) {
dialogHelper.Confirm({
content: "确认删除该院系吗?",
success: function () {
$.ajax({
url: "/Admin/College/DelCollege",
type: "POST",
async: false,
dataType: "json",
data: {
collegeID: id
},
success: function (data) {
dialogHelper.Success({
content: "删除成功!",
success: function () {
location.href = location.href;
},
});
}
});
},
cancle: function () { }
});
}