rbac基本完成

This commit is contained in:
mkg
2021-03-22 20:42:02 +08:00
parent 328458eda9
commit 4c8917fe05
17 changed files with 777 additions and 268 deletions
+54 -26
View File
@@ -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');