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.

147 lines
4.7 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 () {
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 += "<tr>";
trHtml += "<td>{0}</td>";
trHtml += "<td><div title=\"{1}\" class=\"ellipsis\">{1}</div></td>";
trHtml += "<td><div title=\"{2}\" class=\"ellipsis\">{2}</div></td>";
trHtml += "<td><div title=\"{3}\" class=\"ellipsis\">{3}</div></td>";
trHtml += "<td><div title=\"{4}\" class=\"ellipsis\">{4}</div></td>";
trHtml += "<td>{5}</td>";
trHtml += "<td class=\"operate\">";
trHtml += "<a class=\"spr spr-edit\" title=\"编辑\" href=\"javascript:Edit({6});\"></a>";
trHtml += "<a class=\"spr spr-del\" title=\"删除\" href=\"javascript:Del({6});\"></a>";
trHtml += "</td>";
trHtml += "</tr>";
//拼接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 () { }
});
}