rbac基本完成
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
<!-- 头 像 -->
|
||||
<a href="javascript:;">
|
||||
<img src="" id="avatar" class="avatar">
|
||||
<span>{{ username }}</span>
|
||||
<span>{{ realname }}</span>
|
||||
</a>
|
||||
<!-- 功 能 菜 单 -->
|
||||
<dl class="layui-nav-child">
|
||||
|
||||
@@ -13,19 +13,25 @@
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
{% if authorize("admin:file:add") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:file:delete") %}
|
||||
<button class="pear-btn pear-btn-sm" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="user-bar">
|
||||
{% if authorize("admin:file:delete") %}
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
|
||||
</script>
|
||||
{% endif %}
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/layui/layui.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/pear/pear.js') }}"></script>
|
||||
<script>
|
||||
|
||||
@@ -37,21 +37,29 @@
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="power-toolbar">
|
||||
{% if authorize("admin:power:add") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:role:remove") %}
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="power-bar">
|
||||
{% if authorize("admin:role:edit") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:role:remove") %}
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="power-type">
|
||||
@@ -104,7 +112,9 @@
|
||||
page: false,
|
||||
cols: [
|
||||
[
|
||||
{% if authorize("admin:role:remove") %}
|
||||
{type: 'checkbox'},
|
||||
{% endif %}
|
||||
{field: 'powerName', minWidth: 200, title: '权限名称'},
|
||||
{field: 'icon', title: '图标', templet: '#icon'},
|
||||
{field: 'powerType', title: '权限类型', templet: '#power-type'},
|
||||
|
||||
@@ -38,23 +38,33 @@
|
||||
</body>
|
||||
|
||||
<script type="text/html" id="role-toolbar">
|
||||
{% if authorize("admin:role:add") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:role:remove") %}
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="role-bar">
|
||||
{% if authorize("admin:role:edit") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:role:power") %}
|
||||
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="power"><i class="layui-icon layui-icon-vercode"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:role:remove") %}
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="role-enable">
|
||||
@@ -70,13 +80,14 @@
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let popup = layui.popup;
|
||||
let common = layui.common;
|
||||
|
||||
let MODULE_PATH = "/admin/role/";
|
||||
|
||||
let cols = [
|
||||
[
|
||||
{% if authorize("admin:role:remove") %}
|
||||
{type: 'checkbox'},
|
||||
{% endif %}
|
||||
{title: '角色名', field: 'roleName', align: 'center', width: 100},
|
||||
{title: 'Key值', field: 'roleCode', align: 'center'},
|
||||
{title: '描述', field: 'details', align: 'center'},
|
||||
@@ -201,32 +212,49 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.batchRemove = function (obj) {
|
||||
let ids = common.checkField(obj,'id');
|
||||
if (common.isEmpty(ids)) {
|
||||
popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
layer.confirm('确定要删除选中角色', {icon: 3, title: '提示'}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: MODULE_PATH + "batchRemove/" + ids,
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
table.reload('role-table');
|
||||
});
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
window.batchRemove = function(obj) {
|
||||
let data = table.checkStatus(obj.config.id).data;
|
||||
if (data.length === 0) {
|
||||
layer.msg("未选中数据", {
|
||||
icon: 3,
|
||||
time: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
var ids = []
|
||||
var hasCheck = table.checkStatus('role-table')
|
||||
var hasCheckData = hasCheck.data
|
||||
if (hasCheckData.length > 0) {
|
||||
$.each(hasCheckData, function (index, element) {
|
||||
ids.push(element.id)
|
||||
})
|
||||
}
|
||||
console.log(ids)
|
||||
layer.confirm('确定要删除选中角色', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
|
||||
url: MODULE_PATH + "batchRemove",
|
||||
data: {ids:ids},
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
table.reload('role-table');
|
||||
});
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
window.refresh = function () {
|
||||
table.reload('role-table');
|
||||
|
||||
@@ -49,21 +49,29 @@
|
||||
</body>
|
||||
|
||||
<script type="text/html" id="user-toolbar">
|
||||
{% if authorize("admin:user:add") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="pear-icon pear-icon-add"></i>
|
||||
新增
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:user:remove") %}
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="pear-icon pear-icon-ashbin"></i>
|
||||
删除
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="user-bar">
|
||||
{% if authorize("admin:user:edit") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="pear-icon pear-icon-edit"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:user:remove") %}
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="pear-icon pear-icon-ashbin"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="user-enable">
|
||||
@@ -94,13 +102,14 @@
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let popup = layui.popup;
|
||||
let common = layui.common;
|
||||
|
||||
let MODULE_PATH = "/admin/user/";
|
||||
|
||||
let cols = [
|
||||
[
|
||||
{% if authorize("admin:user:remove") %}
|
||||
{type: 'checkbox'},
|
||||
{% endif %}
|
||||
{title: '姓名', field: 'realname', align: 'center', width: 110},
|
||||
{title: '账号', field: 'username', align: 'center'},
|
||||
{title: '启用', field: 'enable', align: 'center', templet: '#user-enable',width: 120},
|
||||
@@ -239,32 +248,49 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.batchRemove = function (obj) {
|
||||
let ids = common.checkField(obj,'userId');
|
||||
if (common.isEmpty(ids)) {
|
||||
popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
layer.confirm('确定要删除选中用户', {icon: 3, title: '提示'}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: MODULE_PATH + "batchRemove/" + ids,
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg,function(){
|
||||
table.reload('user-table');
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
window.batchRemove = function(obj) {
|
||||
let data = table.checkStatus(obj.config.id).data;
|
||||
if (data.length === 0) {
|
||||
layer.msg("未选中数据", {
|
||||
icon: 3,
|
||||
time: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
var ids = []
|
||||
var hasCheck = table.checkStatus('user-table')
|
||||
var hasCheckData = hasCheck.data
|
||||
if (hasCheckData.length > 0) {
|
||||
$.each(hasCheckData, function (index, element) {
|
||||
ids.push(element.id)
|
||||
})
|
||||
}
|
||||
console.log(ids)
|
||||
layer.confirm('确定要删除选中角色', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
|
||||
url: MODULE_PATH + "batchRemove",
|
||||
data: {ids:ids},
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
table.reload('role-table');
|
||||
});
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
window.refresh = function (param) {
|
||||
table.reload('user-table', {where: param});
|
||||
|
||||
Reference in New Issue
Block a user