mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-05 19:41:44 +08:00
91 lines
4.0 KiB
PHP
91 lines
4.0 KiB
PHP
{extend name='table'}
|
|
|
|
{block name="button"}
|
|
<!--{if auth("add")}-->
|
|
<button data-modal='{:url("add")}' data-title="添加权限" class='layui-btn layui-btn-sm layui-btn-primary'>添加权限</button>
|
|
<!--{/if}-->
|
|
|
|
<!--{if auth("remove")}-->
|
|
<button data-action='{:url("remove")}' data-table-id="RoleData" data-rule="id#{id}" data-confirm="确定要批量删除权限吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
|
|
<!--{/if}-->
|
|
{/block}
|
|
|
|
{block name="content"}
|
|
<div class="think-box-shadow">
|
|
{include file='auth/index_search'}
|
|
<table id="RoleData" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
|
|
</div>
|
|
{/block}
|
|
|
|
{block name='script'}
|
|
<script>
|
|
$(function () {
|
|
// 初始化表格组件
|
|
var $table = $('#RoleData').layTable({
|
|
even: true, height: 'full',
|
|
sort: {field: 'sort desc,id', type: 'desc'},
|
|
cols: [[
|
|
{checkbox: true, fixed: true},
|
|
{field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
|
|
{field: 'title', title: '权限名称', minWidth: 140, align: 'center', sort: false},
|
|
{
|
|
field: 'utype', title: '身份权限', minWidth: 140, sort: false, templet: function (d) {
|
|
if ((d.utype_info || {}).name) {
|
|
return d.utype_info.name + '<span class="color-desc"> ( ' + d.utype_info.code + ' ) </span>'
|
|
}
|
|
return '<span class="color-desc">-</span>';
|
|
}
|
|
},
|
|
{
|
|
field: 'desc', title: '权限描述', align: 'center', sort: false, templet: function (d) {
|
|
return d.desc || '<span class="color-desc">-</span>'
|
|
}
|
|
},
|
|
{field: 'create_at', title: '创建时间', align: 'center', sort: true},
|
|
{field: 'status', title: '权限状态', align: 'center', minWidth: 110, fixed: 'right', templet: '#StatusSwitchTpl'},
|
|
{toolbar: '#toolbar', align: 'center', minWidth: 200, title: '权限操作', fixed: 'right'},
|
|
]]
|
|
});
|
|
|
|
// 数据状态切换操作
|
|
layui.form.on('switch(StatusSwitch)', function (obj) {
|
|
$.form.load("{:url('state')}", {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0}, 'post', function (ret) {
|
|
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
|
|
$table.trigger('reload'); // 操作异常时重载数据
|
|
});
|
|
return false;
|
|
}, false);
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
<!-- 列表排序权重模板 -->
|
|
<script type="text/html" id="SortInputTpl">
|
|
<input min="0" type="number" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
|
|
</script>
|
|
|
|
<!-- 数据状态切换模板 -->
|
|
<script type="text/html" id="StatusSwitchTpl">
|
|
<!--{if auth("state")}-->
|
|
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{d.status>0?'checked':''}}>
|
|
<!--{else}-->
|
|
{{d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
|
|
<!--{/if}-->
|
|
</script>
|
|
|
|
<!-- 数据操作工具条模板 -->
|
|
<script type="text/html" id="toolbar">
|
|
<!--{if auth('edit')}-->
|
|
<a class="layui-btn layui-btn-primary layui-btn-sm" data-title="编辑权限" data-modal='{:url("edit")}?id={{d.id}}'>编 辑</a>
|
|
<!--{/if}-->
|
|
|
|
<!--{if auth("apply")}-->
|
|
<a class="layui-btn layui-btn-normal layui-btn-sm" data-open='{:url("apply")}?id={{d.id}}'>授 权</a>
|
|
<!--{/if}-->
|
|
|
|
<!--{if auth("remove")}-->
|
|
<a class="layui-btn layui-btn-danger layui-btn-sm" data-confirm="确定要删除权限吗?" data-action="{:url('remove')}" data-value="id#{{d.id}}">删 除</a>
|
|
<!--{/if}-->
|
|
</script>
|
|
{/block} |