1
0
Files
helper/application/system/view/auth/index.html
2020-08-06 14:58:51 +08:00

137 lines
5.3 KiB
HTML

{extend name="public/base" /}
{block name="body"}
<blockquote class="layui-elem-quote">
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('auth/add')}" id="add"><i class="layui-icon">&#xe654;</i> 新增分组</button>
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('auth/edit')}" id="edit"><i class="layui-icon">&#xe642;</i> 编辑分组</button>
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('auth/menu')}" id="menu"><i class="layui-icon">&#xe632;</i> 菜单授权</button>
<button type="button" class="layui-btn layui-btn-small" data-href="{:url('auth/user')}" id="user"><i class="layui-icon">&#xe60c;</i> 用户授权</button>
<button type="button" class="layui-btn layui-btn-small layui-btn-danger" data-href="{:url('auth/del')}" id="del"><i class="layui-icon">&#xe640;</i> 删除分组</button>
</blockquote>
<div class="layui-form admin-main">
<table class="layui-table">
<thead>
<tr>
<th width="20"><input type="checkbox" lay-skin="primary" lay-filter="allChoose"></th>
<th>ID</th>
<th>分组名称</th>
<th>更新时间</th>
<th>状态</th>
<th>备注</th>
</tr>
</thead>
<tbody>
{volist name="list" id="vo"}
<tr>
<td><input type="checkbox" data-id="{$vo.id}" lay-filter="id" lay-skin="primary"></td>
<td>{$vo.id}</td>
<td>{$vo.title}</td>
<td>{$vo.update_time}</td>
<td><input type="checkbox" name="close" data-id="{$vo.id}" lay-skin="switch" lay-filter="status" {eq name="vo.status" value="1"}checked{/eq} lay-text="正常|禁用"></td>
<td>{$vo.remark}</td>
</tr>
{/volist}
</tbody>
</table>
{$list->render();}
</div>
{/block}
{block name="layui"}
<script>
layui.use(['form'], function(){
var $ = layui.jquery, form = layui.form();
form.on('checkbox(allChoose)', function(data) {
var child = $(data.elem).parents('table').find('tbody input[lay-filter="id"]');
child.each(function(index, item) {
item.checked = data.elem.checked;
});
form.render('checkbox');
});
form.on('switch(status)', function(data) {
$.get("{:url('auth/status')}", {id: $(data.elem).data('id'), status: data.elem.checked}, function(res) {
layer.msg(res.msg, {icon: Math.abs(res.code - 2), time: 1000});
});
});
$('#add').on('click', function(e) {
layer.open({
type: 2,
area: ['400px', '320px'],
content: $(this).data('href')
});
});
$('#edit').on('click', function(e) {
var nodes = getSelected();
if (nodes.length != 1) {
layer.msg('请选择一条要编辑的数据');
} else {
layer.open({
type: 2,
title: $(this).html(),
area: ['400px', '320px'],
content: $(this).data('href') + '?id=' + nodes[0]
});
}
});
$('#del').on('click', function(e) {
var nodes = getSelected();
var $this = $(this);
if (nodes.length < 1) {
layer.msg('请选择一条要删除的数据');
} else {
layer.confirm('你确定要删除么?', {icon: 3, title:'提示'}, function(index) {
$.get($this.data('href'), {id: nodes.join(',')}, function(res) {
layer.close(index);
layer.msg(res.msg, {icon: Math.abs(res.code - 2), time: 1000}, function() {
if (res.code == 1) {
location.reload();
}
});
});
});
}
});
$('#menu').on('click', function(e) {
var nodes = getSelected();
var $this = $(this);
if (nodes.length != 1) {
layer.msg('请选择一条要编辑的数据');
} else {
layer.open({
type: 2,
title: $(this).html(),
area: ['100%', '100%'],
content: $this.data('href') + '?id=' + nodes[0]
});
}
});
$('#user').on('click', function(e) {
var nodes = getSelected();
var $this = $(this);
if (nodes.length != 1) {
layer.msg('请选择一条要编辑的数据');
} else {
layer.open({
type: 2,
title: $(this).html(),
area: ['100%', '100%'],
content: $this.data('href') + '?id=' + nodes[0]
});
}
});
function getSelected() {
var child = $('.layui-form').find('tbody input[lay-filter="id"]:checked');
var idArr = [];
child.each(function(index, item) {
idArr[index] = $(item).data('id');
});
return idArr;
}
});
</script>
{/block}