121 lines
4.5 KiB
HTML
121 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||
<title>权限管理</title>
|
||
<link rel="stylesheet" href="/layui/css/layui.css">
|
||
</head>
|
||
|
||
<body>
|
||
<div class="layui-layout layui-layout-admin">
|
||
<div id="header"></div>
|
||
<div class="layui-body" style="left: 200px;">
|
||
<div id="side"></div>
|
||
<blockquote class="layui-elem-quote"><span id="ip">用户权限管理</span></blockquote>
|
||
<table id="list" lay-filter="userList"></table>
|
||
<div id="footer"></div>
|
||
</div>
|
||
</div>
|
||
<script src="/layui/layui.js"></script>
|
||
<script src="/js/jquery-3.2.1.js"></script>
|
||
<script type="text/html" id="listTools">
|
||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||
</script>
|
||
<script>
|
||
$.get("/login/check.do", function (data) {
|
||
let json = JSON.parse(data);
|
||
if (json.code !== 0) {
|
||
window.location.href = "/"
|
||
}
|
||
})
|
||
layui.use(['layer', 'form', 'element'], function () {
|
||
let layer = layui.layer
|
||
, form = layui.form;
|
||
let transfer = layui.transfer;
|
||
let table = layui.table;
|
||
|
||
table.render({
|
||
elem: "#list"
|
||
, url: '/tools/auth/all.do'
|
||
, page: false
|
||
, cols: [[
|
||
{field: "id", title: "id", width: 80, sort: true, fixed: 'left'}
|
||
, {field: 'key', title: '授权码', width: 250}
|
||
, {field: 'authSize', title: '授权数量', width: 150}
|
||
, {field: "right", width: 80, toolbar: '#listTools'}
|
||
]]
|
||
, done: function (res, curr, count) {
|
||
table.on('tool(userList)', function (obj) {
|
||
console.log(obj.data)
|
||
if (obj.event === 'edit') {
|
||
let type;
|
||
let values=[]
|
||
layer.open({
|
||
title: '设置权限'
|
||
, content: '<div id="auth"></div>'
|
||
, success: function (layero, index) {
|
||
|
||
$.post('/tools/auth/user.do', {'uid': obj.data.id}, function (json) {
|
||
if (json.code === 0) {
|
||
console.log(json.data.user)
|
||
transfer.render({
|
||
elem: '#auth', //绑定元素
|
||
showSearch: true,
|
||
title: ['未授权', '已授权'],
|
||
data: json.data.all,
|
||
value: json.data.user,
|
||
onchange: function (data, index) {
|
||
if(index===0){
|
||
type='add';
|
||
}else{
|
||
type='remove';
|
||
}
|
||
for(let i in data){
|
||
values[i]={
|
||
"auth":data[i].title
|
||
}
|
||
}
|
||
console.log(values)
|
||
},
|
||
id: 'auth' //定义索引
|
||
});
|
||
}
|
||
})
|
||
|
||
}
|
||
, yes: function (index, layero) {
|
||
//do something
|
||
$.post("/tools/auth/set.do",{"uid":obj.data.id,"type":type,"auth":JSON.stringify(values)},function (json) {
|
||
|
||
})
|
||
layer.close(index); //如果设定了yes回调,需进行手工关闭
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
form.render();
|
||
}
|
||
});
|
||
|
||
});
|
||
$.ajax({cache: false})
|
||
$('#header').load("/html/header.html");
|
||
$('#footer').load("/html/footer.html");
|
||
|
||
|
||
</script>
|
||
<style>
|
||
#icon {
|
||
float: right;
|
||
}
|
||
|
||
.body {
|
||
bottom: 0;
|
||
}
|
||
</style>
|
||
</body>
|
||
|
||
</html> |