admin_rule.html
4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
<fieldset class="layui-elem-field layui-field-title">
<legend>权限{:lang('list')}</legend>
</fieldset>
<blockquote class="layui-elem-quote">
<a href="{:url('ruleAdd')}" class="layui-btn layui-btn-sm">{:lang('add')}权限</a>
</blockquote>
<table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/html" id="auth">
<input type="checkbox" name="authopen" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="authopen" {{ d.authopen == 0 ? 'checked' : '' }}>
</script>
<script type="text/html" id="status">
<input type="checkbox" name="menustatus" value="{{d.id}}" lay-skin="switch" lay-text="显示|隐藏" lay-filter="menustatus" {{ d.menustatus == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="order">
<input name="{{d.id}}" data-id="{{d.id}}" class="list_order layui-input" value=" {{d.sort}}" size="10"/>
</script>
<script type="text/html" id="icon">
<span class="icon {{d.icon}}"></span>
</script>
<script type="text/html" id="action">
<a href="{:url('ruleEdit')}?id={{d.id}}" class="layui-btn layui-btn-xs">{:lang('edit')}</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
</script>
{include file="common/foot"/}
<script>
layui.use(['table','form'], function() {
var table = layui.table,form = layui.form, $ = layui.jquery;
tableIn = table.render({
elem: '#list',
url: '{:url("adminRule")}',
method: 'post',
cols: [[
{field: 'id', title: '{:lang("id")}', width: 70, fixed: true},
{field: 'icon', align: 'center',title: '{:lang("icon")}', width: 60,templet: '#icon'},
{field: 'ltitle', title: '权限名称', width: 200},
{field: 'href', title: '控制器/方法', width: 200},
{field: 'authopen',align: 'center', title: '是否验证权限', width: 150,toolbar: '#auth'},
{field: 'menustatus',align: 'center',title: '菜单{:lang("status")}', width: 150,toolbar: '#status'},
{field: 'sort',align: 'center', title: '{:lang("order")}', width: 80, templet: '#order'},
{width: 160,align: 'center', toolbar: '#action'}
]]
});
form.on('switch(authopen)', function(obj){
loading =layer.load(1, {shade: [0.1,'#fff']});
var id = this.value;
var authopen = obj.elem.checked===true?0:1;
$.post('{:url("ruleTz")}',{'id':id,'authopen':authopen},function (res) {
layer.close(loading);
if (res.status==1) {
tableIn.reload();
}else{
layer.msg(res.msg,{time:1000,icon:2});
tableIn.reload();
return false;
}
})
});
form.on('switch(menustatus)', function(obj){
loading =layer.load(1, {shade: [0.1,'#fff']});
var id = this.value;
var menustatus = obj.elem.checked===true?1:0;
$.post('{:url("ruleState")}',{'id':id,'menustatus':menustatus},function (res) {
layer.close(loading);
if (res.status==1) {
tableIn.reload();
}else{
layer.msg(res.msg,{time:1000,icon:2});
tableIn.reload();
return false;
}
})
});
table.on('tool(list)', function(obj){
var data = obj.data;
if(obj.event === 'del'){
layer.confirm('您确定要删除该记录吗?', function(index){
var loading = layer.load(1, {shade: [0.1, '#fff']});
$.post("{:url('ruleDel')}",{id:data.id},function(res){
layer.close(loading);
if(res.code==1){
layer.msg(res.msg,{time:1000,icon:1});
obj.del();
}else{
layer.msg(res.msg,{time:1000,icon:2});
}
});
layer.close(index);
});
}
});
$('body').on('blur','.list_order',function() {
var id = $(this).attr('data-id');
var sort = $(this).val();
$.post('{:url("ruleOrder")}',{id:id,sort:sort},function(res){
if(res.code==1){
layer.msg(res.msg,{time:1000,icon:1},function(){
location.href = res.url;
});
}else{
layer.msg(res.msg,{time:1000,icon:2});
tableIn.reload();
}
})
})
})
</script>