2018-06-03 17:09:10 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>用户列表</title>
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
2019-03-29 15:53:37 +00:00
|
|
|
<link rel="stylesheet" href="css/okadmin.css">
|
2018-08-03 02:37:52 +00:00
|
|
|
<link rel="stylesheet" href="lib/nprogress/nprogress.css">
|
2018-06-03 17:09:10 +00:00
|
|
|
</head>
|
|
|
|
|
<body>
|
2018-08-03 02:37:52 +00:00
|
|
|
<div class="ok-body">
|
|
|
|
|
<!--面包屑导航区域-->
|
|
|
|
|
<div class="ok-body-breadcrumb">
|
2019-03-31 08:54:23 +00:00
|
|
|
<span class="layui-breadcrumb">
|
|
|
|
|
<a><cite>首页</cite></a>
|
2019-03-31 11:00:59 +00:00
|
|
|
<a><cite>会员管理</cite></a>
|
2019-03-31 08:54:23 +00:00
|
|
|
<a><cite>用户列表</cite></a>
|
|
|
|
|
</span>
|
2019-02-14 14:43:38 +00:00
|
|
|
<a class="layui-btn layui-btn-sm" href="javascript:location.replace(location.href);" title="刷新">
|
2018-08-03 02:37:52 +00:00
|
|
|
<i class="layui-icon layui-icon-refresh"></i>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<!--模糊搜索区域-->
|
|
|
|
|
<div class="layui-row">
|
|
|
|
|
<form class="layui-form layui-col-md12 ok-search">
|
|
|
|
|
<input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime">
|
|
|
|
|
<input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime">
|
|
|
|
|
<input class="layui-input" placeholder="请输入用户名" autocomplete="off">
|
|
|
|
|
<button class="layui-btn" lay-submit="" lay-filter="search">
|
|
|
|
|
<i class="layui-icon layui-icon-search"></i>
|
2018-06-06 05:16:16 +00:00
|
|
|
</button>
|
2018-08-03 02:37:52 +00:00
|
|
|
</form>
|
2018-06-03 17:09:10 +00:00
|
|
|
</div>
|
2018-08-03 02:37:52 +00:00
|
|
|
<!--工具栏-->
|
|
|
|
|
<okToolbar>
|
|
|
|
|
<button class="layui-btn layui-btn-normal" id="batchEnabled">
|
|
|
|
|
<i class="iconfont icon-shangsheng"></i>批量启用
|
|
|
|
|
</button>
|
|
|
|
|
<button class="layui-btn layui-btn-warm" id="batchDisabled">
|
|
|
|
|
<i class="iconfont icon-web-icon-"></i>批量停用
|
|
|
|
|
</button>
|
|
|
|
|
<button class="layui-btn layui-btn-danger" id="batchDel">
|
|
|
|
|
<i class="layui-icon layui-icon-delete"></i>批量删除
|
|
|
|
|
</button>
|
|
|
|
|
<button class="layui-btn" id="addUser">
|
|
|
|
|
<i class="layui-icon"></i>添加用户
|
|
|
|
|
</button>
|
|
|
|
|
<span>共有数据:<i id="countNum"></i> 条</span>
|
|
|
|
|
</okToolbar>
|
|
|
|
|
<!--数据表格-->
|
|
|
|
|
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
|
|
|
|
|
</div>
|
|
|
|
|
<!--js逻辑-->
|
|
|
|
|
<script src="lib/layui/layui.js"></script>
|
|
|
|
|
<script src="lib/nprogress/nprogress.js"></script>
|
|
|
|
|
<script>
|
2019-05-12 08:15:57 +00:00
|
|
|
// NProgress.start();
|
|
|
|
|
// window.onload = function () {
|
|
|
|
|
// NProgress.done();
|
|
|
|
|
// }
|
|
|
|
|
layui.config({
|
|
|
|
|
base: "lib/layui_plugins/"
|
|
|
|
|
}).extend({
|
2019-05-12 11:09:10 +00:00
|
|
|
okLayer: "okLayer/okLayer",
|
|
|
|
|
okUtils: "okUtils/okUtils"
|
|
|
|
|
}).use(["element", "table", "form", "jquery", "laydate", "okLayer", "okUtils"], function () {
|
2018-08-03 02:37:52 +00:00
|
|
|
var table = layui.table;
|
|
|
|
|
var form = layui.form;
|
|
|
|
|
var $ = layui.jquery;
|
|
|
|
|
var laydate = layui.laydate;
|
2019-05-12 08:15:57 +00:00
|
|
|
var okLayer = layui.okLayer;
|
2019-05-12 11:09:10 +00:00
|
|
|
var okUtils = layui.okUtils;
|
2018-08-03 02:37:52 +00:00
|
|
|
|
2019-05-12 08:15:57 +00:00
|
|
|
laydate.render({elem: "#startTime", type: "datetime"});
|
|
|
|
|
laydate.render({elem: "#endTime", type: "datetime"});
|
2018-08-03 02:37:52 +00:00
|
|
|
|
|
|
|
|
table.render({
|
2019-04-14 07:09:15 +00:00
|
|
|
elem: "#tableId",
|
|
|
|
|
url: "data/user.json",
|
2018-08-03 02:37:52 +00:00
|
|
|
limit: 10,
|
|
|
|
|
page: true,
|
|
|
|
|
cols: [[
|
2019-04-14 07:09:15 +00:00
|
|
|
{type: "checkbox"},
|
|
|
|
|
{field: "id", title: "ID", width: 80, sort: true},
|
|
|
|
|
{field: "username", title: "用户名", width: 100},
|
|
|
|
|
{field: "name", title: "姓名", width: 100},
|
|
|
|
|
{field: "password", title: "密码", width: 100},
|
|
|
|
|
{field: "status", title: "状态", width: 85, templet: "#statusTpl"},
|
|
|
|
|
{field: "role", title: "角色", width: 100, templet: "#roleTpl"},
|
|
|
|
|
{field: "email", title: "邮箱", width: 200},
|
|
|
|
|
{field: "createTime", title: "创建时间", width: 200},
|
|
|
|
|
{field: "logins", title: "登陆次数", width: 100},
|
|
|
|
|
{title: "操作", width: 200, align: 'center', templet: "#operationTpl"}
|
2018-08-03 02:37:52 +00:00
|
|
|
]],
|
|
|
|
|
done: function (res, curr, count) {
|
|
|
|
|
$("#countNum").text(count);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-04-14 07:09:15 +00:00
|
|
|
form.on("submit(search)", function () {
|
|
|
|
|
layer.msg("正在查询,请稍后...");
|
2018-08-03 02:37:52 +00:00
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2019-04-14 07:09:15 +00:00
|
|
|
table.on("tool(tableFilter)", function (obj) {
|
2018-08-03 02:37:52 +00:00
|
|
|
var data = obj.data;
|
|
|
|
|
var layEvent = obj.event;
|
2019-04-14 07:09:15 +00:00
|
|
|
if (layEvent === "edit") {
|
2019-05-13 00:45:45 +00:00
|
|
|
okLayer.open("编辑用户", "user-edit.html", "90%", "90%", true)
|
2019-04-14 07:09:15 +00:00
|
|
|
} else if (layEvent === "del") {
|
2019-05-12 11:09:10 +00:00
|
|
|
okLayer.confirm("确定要删除吗?", function () {
|
|
|
|
|
okUtils.ajax("/user/batchDel", "post", {idsStr: data.id}).done(function (response) {
|
|
|
|
|
console.log(response)
|
|
|
|
|
okLayer.tableOperationMsg("删除成功");
|
|
|
|
|
}).fail(function (error) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
})
|
2018-08-03 02:37:52 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#batchEnabled").click(function () {
|
2019-05-12 08:57:14 +00:00
|
|
|
okLayer.confirm("确定要批量启用吗?", function (index) {
|
|
|
|
|
layer.close(index);
|
2019-05-12 11:09:10 +00:00
|
|
|
var idsStr = okLayer.tableCheck(table);
|
|
|
|
|
console.log("idsStr-->" + idsStr)
|
2019-05-12 08:57:14 +00:00
|
|
|
// ajax请求后台api
|
2019-05-12 11:09:10 +00:00
|
|
|
if (idsStr) {
|
|
|
|
|
okUtils.ajax("/user/batchNormal", "post", {idsStr: idsStr}).done(function (response) {
|
|
|
|
|
console.log(response)
|
|
|
|
|
okLayer.tableOperationMsg("批量启用成功");
|
|
|
|
|
}).fail(function (error) {
|
|
|
|
|
console.log(error)
|
2018-08-03 02:37:52 +00:00
|
|
|
});
|
|
|
|
|
}
|
2018-07-10 08:49:07 +00:00
|
|
|
});
|
2018-08-03 02:37:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$("#batchDisabled").click(function () {
|
2019-05-12 08:57:14 +00:00
|
|
|
okLayer.confirm("确定要批量停用吗?", function (index) {
|
|
|
|
|
layer.close(index);
|
2019-05-12 11:09:10 +00:00
|
|
|
var idsStr = okLayer.tableCheck(table);
|
|
|
|
|
if (idsStr) {
|
|
|
|
|
okUtils.ajax("/user/batchStop", "post", {idsStr: idsStr}).done(function (response) {
|
|
|
|
|
console.log(response)
|
|
|
|
|
okLayer.tableOperationMsg("批量停用成功");
|
|
|
|
|
}).fail(function (error) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-07-10 08:49:07 +00:00
|
|
|
});
|
2018-08-03 02:37:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$("#batchDel").click(function () {
|
2019-05-12 08:57:14 +00:00
|
|
|
okLayer.confirm("确定要批量删除吗?", function (index) {
|
|
|
|
|
layer.close(index);
|
2019-05-12 11:09:10 +00:00
|
|
|
var idsStr = okLayer.tableCheck(table);
|
|
|
|
|
if (idsStr) {
|
|
|
|
|
okUtils.ajax("/user/batchDel", "post", {idsStr: idsStr}).done(function (response) {
|
|
|
|
|
console.log(response)
|
|
|
|
|
okLayer.tableOperationMsg("批量删除成功");
|
|
|
|
|
}).fail(function (error) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-07-10 08:49:07 +00:00
|
|
|
});
|
2018-08-03 02:37:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$("#addUser").click(function () {
|
2019-05-13 00:45:45 +00:00
|
|
|
okLayer.open("添加用户", "user-add.html", "90%", "90%", true)
|
2018-06-05 16:18:57 +00:00
|
|
|
})
|
2018-08-03 02:37:52 +00:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<!--模板-->
|
|
|
|
|
<script type="text/html" id="statusTpl">
|
2019-05-12 11:09:10 +00:00
|
|
|
<input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|停用" {{ d.status== 0 ? 'checked' : ''}}>
|
2018-08-03 02:37:52 +00:00
|
|
|
</script>
|
|
|
|
|
<script type="text/html" id="roleTpl">
|
|
|
|
|
{{ d.role == 0 ? '管理员' : '普通用户 '}}
|
|
|
|
|
</script>
|
|
|
|
|
<script type="text/html" id="operationTpl">
|
|
|
|
|
<a href="javascript:;" title="编辑" lay-event="edit"><i class="layui-icon"></i></a>
|
|
|
|
|
<a href="javascript:;" title="删除" lay-event="del"><i class="layui-icon"></i></a>
|
|
|
|
|
</script>
|
2018-06-03 17:09:10 +00:00
|
|
|
</body>
|
2019-02-14 14:43:38 +00:00
|
|
|
</html>
|