|
|
@@ -24,6 +24,9 @@ var cols = [{
|
|
|
colClass: 'text-center'
|
|
|
}];
|
|
|
var pageNo = null;
|
|
|
+var edittype = "add";
|
|
|
+var pagesize = 30;
|
|
|
+var RoleMap = new HashMap()
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
$("#main_content_title").html("角色管理")
|
|
|
@@ -37,7 +40,31 @@ $(document).ready(function () {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- var pagesize = 15;
|
|
|
+
|
|
|
+ $('.datatable').on('click', 'button', function () {
|
|
|
+ if (this.name == "user_edit") {
|
|
|
+
|
|
|
+ edittype = "edit"
|
|
|
+ loadRoleData(RoleMap.get(parseInt(this.id)));
|
|
|
+
|
|
|
+ $('#addRoleModal').modal('show');
|
|
|
+ }
|
|
|
+ if (this.name == "user_delete") {
|
|
|
+
|
|
|
+ RoleDelete(this.id, function (data) {
|
|
|
+ layer.msg('角色删除成功!', {
|
|
|
+ time: 2000, //20s后自动关闭
|
|
|
+ }, function () {
|
|
|
+ getrole(pagesize, 1);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ function (error) {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
if (pageNo == null || pageNo == "") {
|
|
|
getrole(pagesize, 1);
|
|
|
} else {
|
|
|
@@ -46,10 +73,11 @@ $(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
|
- $("#add_role_btn").on("click",function(){
|
|
|
-
|
|
|
- $('#addRoleModal').modal('show');
|
|
|
- })
|
|
|
+ $("#add_role_btn").on("click", function () {
|
|
|
+ edittype = "add";
|
|
|
+ loadRoleData(null);
|
|
|
+ $('#addRoleModal').modal('show');
|
|
|
+ })
|
|
|
|
|
|
});
|
|
|
|
|
|
@@ -68,8 +96,10 @@ function getrole(size, page) {
|
|
|
userdata["checked"] = false;
|
|
|
userdata["data"] = [i + 1, role.des, role.usercount, '<button class="btn btn-primary" name="user_edit" id=' + role.id + '><i class="icon icon-edit"></i>修改</button> <button class="btn btn-primary" name="user_delete" id=' + role.id + ' ><i class="icon icon-remove-circle"></i>删除</button>'];
|
|
|
rowdata.push(userdata);
|
|
|
+ RoleMap.set(role.id,role);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
// 使用data参数更新数据:
|
|
|
$('.datatable').datatable('load', {
|