2019-08-30 05:47:14 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
2019-11-03 12:50:58 +00:00
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<title>留言列表</title>
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
|
<link rel="stylesheet" href="../../css/oksub.css">
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="ok-body">
|
|
|
|
|
<!--模糊搜索区域-->
|
|
|
|
|
<div class="layui-row">
|
|
|
|
|
<form class="layui-form layui-col-md12 ok-search">
|
|
|
|
|
<input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime" name="startTime">
|
|
|
|
|
<input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime" name="endTime">
|
|
|
|
|
<input class="layui-input" placeholder="请输入标题" autocomplete="off" name="title">
|
|
|
|
|
<button class="layui-btn" lay-submit="" lay-filter="search">
|
|
|
|
|
<i class="layui-icon layui-icon-search"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</form>
|
2019-09-01 13:16:20 +00:00
|
|
|
</div>
|
2019-11-03 12:50:58 +00:00
|
|
|
<!--数据表格-->
|
|
|
|
|
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
|
|
|
|
|
</div>
|
|
|
|
|
<!--js逻辑-->
|
|
|
|
|
<script src="../../lib/layui/layui.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
layui.use(["table", "form", "laydate", "okLayer", "okUtils", "okMock"], function () {
|
|
|
|
|
let table = layui.table;
|
|
|
|
|
let form = layui.form;
|
|
|
|
|
let util = layui.util;
|
|
|
|
|
let laydate = layui.laydate;
|
|
|
|
|
let okLayer = layui.okLayer;
|
|
|
|
|
let okUtils = layui.okUtils;
|
|
|
|
|
let okMock = layui.okMock;
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
util.fixbar({});
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
laydate.render({elem: "#startTime", type: "datetime"});
|
|
|
|
|
laydate.render({elem: "#endTime", type: "datetime"});
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
let articleTable = table.render({
|
|
|
|
|
elem: "#tableId",
|
|
|
|
|
url: okMock.api.listMessage,
|
|
|
|
|
limit: 20,
|
|
|
|
|
page: true,
|
|
|
|
|
even: true,
|
|
|
|
|
toolbar: "#toolbarTpl",
|
|
|
|
|
size: "sm",
|
|
|
|
|
cols: [[
|
|
|
|
|
{type: "checkbox", fixed: "left"},
|
|
|
|
|
{field: "id", title: "ID", width: 170, sort: true},
|
|
|
|
|
{field: "commenter", title: "留言者", width: 100},
|
|
|
|
|
{field: "content", title: "留言内容", width: 300},
|
|
|
|
|
{field: "url", title: "文章链接", width: 250, templet: "#urlTpl"},
|
|
|
|
|
{field: "status", title: "状态", width: 110, align: "center", templet: "#statusTpl"},
|
|
|
|
|
{field: "createTime", title: "留言时间", width: 150},
|
|
|
|
|
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
|
|
|
|
|
]],
|
|
|
|
|
done: function (res, curr, count) {
|
|
|
|
|
console.log(res, curr, count)
|
2019-08-30 05:47:14 +00:00
|
|
|
}
|
2019-11-03 12:50:58 +00:00
|
|
|
});
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
form.on("submit(search)", function (data) {
|
|
|
|
|
articleTable.reload({
|
|
|
|
|
where: data.field,
|
|
|
|
|
page: {curr: 1}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
table.on("toolbar(tableFilter)", function (obj) {
|
|
|
|
|
switch (obj.event) {
|
|
|
|
|
case "batchDelete":
|
|
|
|
|
batchDelete();
|
|
|
|
|
break;
|
2019-09-01 13:16:20 +00:00
|
|
|
}
|
2019-11-03 12:50:58 +00:00
|
|
|
});
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
table.on("tool(tableFilter)", function (obj) {
|
|
|
|
|
let data = obj.data;
|
|
|
|
|
switch (obj.event) {
|
|
|
|
|
case "updateById":
|
|
|
|
|
updateById(data.id);
|
|
|
|
|
break;
|
|
|
|
|
case "deleteById":
|
|
|
|
|
deleteById(data.id);
|
|
|
|
|
break;
|
2019-09-01 13:16:20 +00:00
|
|
|
}
|
2019-11-03 12:50:58 +00:00
|
|
|
});
|
2019-08-30 05:47:14 +00:00
|
|
|
|
2019-11-03 12:50:58 +00:00
|
|
|
function batchDelete() {
|
|
|
|
|
okLayer.confirm("确定要批量删除吗?", function (index) {
|
|
|
|
|
layer.close(index);
|
|
|
|
|
let idsStr = okUtils.tableBatchCheck(table);
|
|
|
|
|
if (idsStr) {
|
|
|
|
|
okUtils.ajax("/message/deleteMessage", "delete", {idsStr: idsStr}, true).done(function (response) {
|
|
|
|
|
okUtils.tableSuccessMsg(response.msg);
|
2019-09-01 13:16:20 +00:00
|
|
|
}).fail(function (error) {
|
2019-11-03 12:50:58 +00:00
|
|
|
console.log(error);
|
2019-09-01 13:16:20 +00:00
|
|
|
});
|
2019-11-03 12:50:58 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateById(id) {
|
|
|
|
|
okLayer.open("编辑留言", "message-edit.html?id=" + id, "90%", "90%", null, function () {
|
|
|
|
|
articleTable.reload();
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteById(id) {
|
|
|
|
|
okLayer.confirm("确定要删除吗?", function () {
|
|
|
|
|
okUtils.ajax("/message/deleteMessage", "delete", {idsStr: id}, true).done(function (response) {
|
|
|
|
|
okUtils.tableSuccessMsg(response.msg);
|
|
|
|
|
}).fail(function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<!-- 头工具栏模板 -->
|
|
|
|
|
<script type="text/html" id="toolbarTpl">
|
|
|
|
|
<div class="layui-btn-container">
|
|
|
|
|
<div class="layui-inline" lay-event="batchDelete"><i class="layui-icon"></i></div>
|
|
|
|
|
</div>
|
|
|
|
|
</script>
|
|
|
|
|
<!-- 行工具栏模板 -->
|
|
|
|
|
<script type="text/html" id="operationTpl">
|
|
|
|
|
<a href="javascript:" title="编辑" lay-event="updateById"><i class="layui-icon"></i></a>
|
|
|
|
|
<a href="javascript:" title="删除" lay-event="deleteById"><i class="layui-icon"></i></a>
|
|
|
|
|
</script>
|
|
|
|
|
<!-- 链接 -->
|
|
|
|
|
<script type="text/html" id="urlTpl">
|
|
|
|
|
<a href="{{d.url}}" target="_blank">{{d.url}}</a>
|
|
|
|
|
</script>
|
|
|
|
|
<!-- 状态-->
|
|
|
|
|
<script type="text/html" id="statusTpl">
|
|
|
|
|
{{# if(d.status == 0){ }}
|
|
|
|
|
<span class="layui-btn layui-btn-normal layui-btn-xs">已读</span>
|
|
|
|
|
{{# } else if(d.status == 1) { }}
|
|
|
|
|
<span class="layui-btn layui-btn-warm layui-btn-xs">未读</span>
|
|
|
|
|
{{# } }}
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
2019-08-30 05:47:14 +00:00
|
|
|
</html>
|