已废弃
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.

105 lines
4.7 KiB

3 years ago
<!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>
<input id="did" style="display: none" th:value="${did}">
<table id="demo" lay-filter="test"></table>
<script charset="utf-8" src="/static/lib/layui-v2.6.3/layui.js"></script>
<script>
layui.use('table', function () {
var table = layui.table;
var did = document.getElementById("did").value;
//第一个实例
table.render({
elem: '#demo'
, height: 312
, url: '/repository/findManagerByDid?did=' + did, //数据接口
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
request: {
pageName: 'page', //页码的参数名称,默认:page
limitName: 'pagesize' //每页数据量的参数名,默认:limit
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
, statusCode: 200 //规定成功的状态码,默认:0
, msgName: 'message' //规定状态信息的字段名称,默认:msg
, countName: 'count' //规定数据总数的字段名称,默认:count
, dataName: 'data' //规定数据列表的字段名称,默认:data
}
, page: true //开启分页
, cols: [
[ //表头
{field: 'id', width: 80, title: 'ID', sort: true},
{field: 'number', width: 100, title: '工号', sort: true},
{field: 'name', width: 100, title: '姓名', sort: true},
{
field: 'gender', width: 80, title: '性别', sort: true, templet: function (d) {
if (d.gender == 1) {
return "男性";
} else if (d.gender == 2) {
return "女性";
} else if (d.gender == 3) {
return "中性"
}
}
},
{
field: 'state', title: '状态', minWidth: 80, sort: true, templet: function (d) {
if (d.state == 1) {
return "启用";
} else if (d.state == 2) {
return "禁用";
}
}
},
{
field: 'health', title: '健康状况', minWidth: 160, sort: true, templet: function (d) {
switch (d.health) {
case 1:
return "良好";
case 2:
return "一般";
case 3:
return "较弱";
case 4:
return "有生理缺陷";
case 5:
return "残废"
}
}
},
{field: 'mobilephone', width: 200, title: '内线电话', sort: true},
{field: 'companyname', width: 200, title: '公司名称', sort: true},
{field: 'maindeparmentname', width: 200, title: '主部门', sort: true},
{field: 'sunmaindeparmentname', width: 200, title: '岗位', sort: true},
{field: 'workpostname', width: 200, title: '工段', sort: true},
{field: 'positionname', width: 200, title: '职位', sort: true},
]
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line'
});
});
</script>
</body>
</html>