已废弃
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

206 lines
9.2 KiB

<!DOCTYPE html>
<html lang="en" xmlns:checked="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta content="webkit" name="renderer">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<link href="/static/lib/layui-v2.6.3/css/layui.css" media="all" rel="stylesheet">
<link href="/static/css/public.css" media="all" rel="stylesheet">
</head>
<body>
<div class="layuimini-container">
<input id="postId" style="display: none" th:value="${postId}">
<input id="classes" style="display: none" th:value="${classes}">
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add_role">添加权限</button>
<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete">删除权限</button>
</div>
</script>
<table id="demo" class="layui-hide" lay-filter="currentTableFilter"></table>
<script type="text/html" id="currentTableBar">
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a>
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-delete" lay-event="delete">删除</a>
</script>
</div>
<script charset="utf-8" src="/static/lib/layui-v2.6.3/layui.js"></script>
<script>
layui.use('table', function () {
var table = layui.table;
var $ = layui.$;
var postId = $("#postId").val();
var classes = $("#classes").val();
//第一个实例
table.render({
elem: '#demo'
, url: '/company/findPostRole?postId=' + postId+'&classes='+classes, //数据接口
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
height: 'full-255',//固定高度-即固定表头固定第一行首行
request: {
pageName: 'page', //页码的参数名称,默认:page
limitName: 'size' //每页数据量的参数名,默认:limit
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
, statusCode: 200 //规定成功的状态码,默认:0
, msgName: 'message' //规定状态信息的字段名称,默认:msg
, countName: 'count' //规定数据总数的字段名称,默认:count
, dataName: 'data' //规定数据列表的字段名称,默认:data
}, toolbar: '#toolbarDemo'
, cols: [
[ //表头
{type: "checkbox", width: 50},
{field: 'depositoryName', width: 200, title: '仓库名称', sort: true},
{field: 'name', width: 250, title: '名称', sort: true},
{field: 'dutiesname',width: 200,title: '名称',sort: true},
{field: 'aoname',width: 200,title: '归属行政组织名称',sort: true},
{field: 'jobname',width: 200,title: '职务类别',sort: true},
{title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
]
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line'
});
//监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj)
});
table.on('tool(currentTableFilter)', function (obj) {
let data = obj.data;
if(obj.event === 'detail'){
var index = layer.open({
title: '修改权限',
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['100%', '100%'],
content: '/post_role_edit?id='+data.id+"&depositoryId="+data.depositoryId,
end:function () {
location.reload()
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
else if(obj.event === 'delete'){
var req = {};
req.id = data.id;
req.depositoryId = data.depositoryId;
req.classes = classes;
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
$.ajax({
url: '/company/postRole_del',
dataType: 'json',
type: 'POST',
contentType: "application/json;charset=utf-8",
data: JSON.stringify(req),
beforeSend: function () {
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
},
success: function (data) {
layer.close(this.layerIndex);
if (data.status >= 300) {
layer.msg(data.statusInfo.message);//失败的表情
return;
} else {
obj.del();
layer.msg("删除成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
});
}
}
})
});
}
});
table.on('toolbar(currentTableFilter)', function (obj) {
if (obj.event === 'add_role') {
var index = layer.open({
title: '添加权限',
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['100%', '100%'],
content: '/postRoleAdd?id='+postId+'&classes='+classes,
end:function () {
location.reload()
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}
else if (obj.event === 'delete') { // 监听删除操作
var checkStatus = table.checkStatus('demo')
, data = checkStatus.data;
var req = {};
req.ids = [];
req.depositoryIds = [];
for (i = 0, len = data.length; i < len; i++) {
req.ids[i] = data[i].id;
req.depositoryIds[i] = data[i].depositoryId;
}
req.classes = classes;
if(req.ids.length > 0) {
layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) {
$.ajax({
url: '/company/postRole_del',
dataType: 'json',
type: 'POST',
contentType: "application/json;charset=utf-8",
data: JSON.stringify(req),
beforeSend: function () {
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
},
success: function (data) {
layer.close(this.layerIndex);
if (data.status >= 300) {
layer.msg(data.statusInfo.message);//失败的表情
return;
} else {
layer.msg("删除成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
});
//执行搜索重载
table.reload('demo', {
url: '/company/findPostRole?postId=' + postId+'&classes='+classes,
page: {
curr: 1
}
}, 'data');
}
}
})
});
}else{
layer.msg("未选中记录,请确认!");
return false;
}
}
})
});
</script>
</body>
</html>