初始化CRICS
This commit is contained in:
94
WebSite/Scripts/sys-role-index.js
Normal file
94
WebSite/Scripts/sys-role-index.js
Normal file
@@ -0,0 +1,94 @@
|
||||
function add() {
|
||||
$("#dialog")
|
||||
.find(".dlg-content").panel({ href: "/SysRole/Edit/", queryParams: {} }).end()
|
||||
.find(".dlg-footer .dlg-btn-save").unbind("click").bind("click", save).end()
|
||||
.dialog({
|
||||
title: lang.NewRole,
|
||||
width: 350,
|
||||
height: 500
|
||||
})
|
||||
.dialog("open");
|
||||
}
|
||||
function getSelectedItem() {
|
||||
var data = $("#rolelist tr.selected").data("role");
|
||||
if (data == undefined) {
|
||||
data = null;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
function edit() {
|
||||
var row = getSelectedItem();
|
||||
if (row) {
|
||||
if (row.ID === 1) {//Name === "超级管理员") {
|
||||
$.tools.alert(lang.CNESAR);
|
||||
return;
|
||||
}
|
||||
$("#dialog")
|
||||
.find(".dlg-content").panel({ href: "/SysRole/Edit/", queryParams: { ID: row.ID} }).end()
|
||||
.find(".dlg-footer .dlg-btn-save").unbind("click").bind("click", save).end()
|
||||
.dialog({
|
||||
title: lang.EditRole,
|
||||
width: 350,
|
||||
height: 500
|
||||
})
|
||||
.dialog("open");
|
||||
} else {
|
||||
$.tools.alert(lang.PleaseSelectTheData);
|
||||
}
|
||||
}
|
||||
//删除数据
|
||||
function delData() {
|
||||
var selectedRow = getSelectedItem();
|
||||
if (selectedRow) {
|
||||
if (selectedRow.ID === 1) {//Name === "超级管理员") {
|
||||
$.tools.alert(lang.CNDTSAR);
|
||||
return;
|
||||
}
|
||||
$.tools.delPost("id=" + selectedRow.ID, "/SysRole/Delete/", function () {
|
||||
loadRoles();
|
||||
}, this);
|
||||
} else {
|
||||
$.tools.alert(lang.PleaseSelectTheData);
|
||||
}
|
||||
}
|
||||
function save() {
|
||||
var form = $("#dialog").find("form");
|
||||
if (form.form("enableValidation").form("validate")) {
|
||||
var params = form.serialize();
|
||||
var authorityNodes = $('#treeAuthority').tree('getChecked'); // $("#dialog .authorities").tree("getChecked", ["checked", "indeterminate"]);
|
||||
if (authorityNodes.length == 0) {
|
||||
$.tools.alert(lang.PleaseSelectTheData);
|
||||
return;
|
||||
}
|
||||
$.each(authorityNodes, function (i, n) { params += "&Authorities=" + n.id; });
|
||||
$.tools.post(params, "/SysRole/Save/", function () {
|
||||
loadRoles();
|
||||
$("#dialog").window('close');
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
function itemClick() {
|
||||
$(".role-list tr").removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
}
|
||||
function itemDblClick() { edit(); }
|
||||
|
||||
function appendItem(obj) {
|
||||
var td1 = $("<td class='item-header'></td>").append("<img src='/images/role_32.png' alt='' />");
|
||||
var td2 = $("<td></td>").append("<h3></h3>").find("h3").text(obj.Name).end()
|
||||
.append("<span></span>").find("span").text(obj.Authorities).end();
|
||||
var tr = $("<tr></tr>").data("role", obj).append(td1, td2).bind("click", itemClick).bind("dblclick", itemDblClick);
|
||||
$("#rolelist").append(tr);
|
||||
}
|
||||
function loadData(data) {
|
||||
$("#rolelist tbody").remove();
|
||||
if (data instanceof Array) {
|
||||
for (var i in data) {
|
||||
appendItem(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function loadRoles() {
|
||||
$.tools.post({}, "/SysRole/LoadAll2", function (result) { loadData(result.data); }, this, true);
|
||||
}
|
||||
$(function () { loadRoles(); });
|
||||
Reference in New Issue
Block a user