add:bbs.html

master
bobi 2019-09-03 15:41:58 +08:00
parent 53f6877369
commit 35b7e46f28
7 changed files with 225 additions and 6 deletions

View File

@ -160,6 +160,12 @@
"href": "pages/often/image.html",
"icon": "",
"spread": false
},
{
"title": "帖子列表",
"href": "pages/often/bbs.html",
"icon": "",
"spread": false
}
]
},

View File

@ -43,6 +43,9 @@ layui.define([], function(exprots) {
},
download: {
list: "https://www.easy-mock.com/mock/5d5d0dd46cfcbd1b8627bf1d/ok-admin-v2.0/download/list"
},
bbs: {
list: "https://www.easy-mock.com/mock/5d5d0dd46cfcbd1b8627bf1d/ok-admin-v2.0/bbs/list"
}
}
};

210
pages/often/bbs.html Normal file
View File

@ -0,0 +1,210 @@
<!DOCTYPE html>
<html>
<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="ok-body-breadcrumb">
<span class="layui-breadcrumb">
<a><cite>首页</cite></a>
<a><cite>常用页面</cite></a>
<a><cite>帖子列表</cite></a>
</span>
<a class="layui-btn layui-btn-sm" href="javascript:location.replace(location.href);" title="刷新">
<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" 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>
</div>
<!--数据表格-->
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
</div>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
layui.use(["element", "table", "form", "laydate", "okLayer", "okUtils", "okMock"], function () {
var element = layui.element;
var table = layui.table;
var form = layui.form;
var util = layui.util;
var laydate = layui.laydate;
var okLayer = layui.okLayer;
var okUtils = layui.okUtils;
var okMock = layui.okMock;
util.fixbar({});
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
var articleTable = table.render({
elem: "#tableId",
url: okMock.api.bbs.list,
limit: 20,
page: true,
even: true,
toolbar: "#toolbarTpl",
size: "sm",
cols: [[
{type: "checkbox", fixed: "left"},
{field: "guid", title: "GUID", width: 280, sort: true},
{field: "username", title: "发帖人", width: 100},
{field: "title", title: "标题", width: 250},
{field: "summary", title: "摘要", width: 300},
{field: "content", title: "内容", width: 350},
{field: "createTime", title: "发帖时间", width: 150},
{field: "status", title: "状态", width: 110, align: "center", templet: "#statusTpl"},
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
]],
done: function (res, curr, count) {
console.log(res, curr, count);
element.init();
}
});
form.on("submit(search)", function () {
articleTable.reload({
where: data.field,
page: {curr: 1}
});
return false;
});
table.on("toolbar(tableFilter)", function (obj) {
switch (obj.event) {
case "batchEnabled":
batchEnabled();
break;
case "batchDisabled":
batchDisabled();
break;
case "batchDel":
batchDel();
break;
case "add":
add();
break;
}
});
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
switch (obj.event) {
case "edit":
edit(data.id);
break;
case "del":
del(data.id);
break;
}
});
function batchEnabled() {
okLayer.confirm("确定要批量上架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchNormal", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量上架成功");
}).fail(function (error) {
console.log(error)
});
}
});
}
function batchDisabled() {
okLayer.confirm("确定要批量下架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchStop", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量下架成功");
}).fail(function (error) {
console.log(error)
});
}
});
}
function batchDel() {
okLayer.confirm("确定要批量删除吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchDel", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量删除成功");
}).fail(function (error) {
console.log(error)
});
}
});
}
function add() {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
articleTable.reload();
})
}
function edit(id) {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
})
}
function del(id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/article/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response);
okUtils.table.successMsg("删除成功");
}).fail(function (error) {
console.log(error)
});
})
}
})
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="batchEnabled">批量上架</button>
<button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="batchDisabled">批量下架</button>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batchDel">批量删除</button>
<button class="layui-btn layui-btn-sm" lay-event="add">添加文章</button>
</div>
</script>
<!-- 行工具栏模板 -->
<script type="text/html" id="operationTpl">
<a href="javascript:" title="编辑" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>
<a href="javascript:" title="删除" lay-event="del"><i class="layui-icon">&#xe640;</i></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>
{{# } else if(d.status == 2) { }}
<span class="layui-btn layui-btn-danger layui-btn-xs">已删除</span>
{{# } }}
</script>
</body>
</html>

View File

@ -61,8 +61,8 @@
cols: [[
{type: "checkbox", fixed: "left"},
{field: "guid", title: "GUID", width: 280, sort: true},
{field: "name", title: "名称", width: 350},
{field: "remarks", title: "备注", width: 350},
{field: "name", title: "名称", width: 100},
{field: "remarks", title: "备注", width: 310},
{field: "url", title: "链接", width: 250, templet: "#urlTpl"},
{field: "status", title: "状态", width: 110, align: "center", templet: "#statusTpl"},
{field: "createTime", title: "创建时间", width: 150},

View File

@ -62,7 +62,7 @@
{type: "checkbox", fixed: "left"},
{field: "guid", title: "GUID", width: 280, sort: true},
{field: "username", title: "留言者", width: 100},
{field: "content", title: "留言内容", width: 350},
{field: "content", title: "留言内容", width: 300},
{field: "url", title: "文章链接", width: 250, templet: "#urlTpl"},
{field: "createTime", title: "留言时间", width: 150},
{field: "status", title: "状态", width: 110, align: "center", templet: "#statusTpl"},

View File

@ -64,7 +64,7 @@
{field: "name", title: "产品名称", width: 100},
{field: "logo", title: "产品LOGO", width: 150, templet: "#logoTpl"},
{field: "url", title: "产品官网", width: 200, templet: "#urlTpl"},
{field: "description", title: "产品描述", width: 100},
{field: "description", title: "产品描述", width: 400},
{field: "createTime", title: "创建时间", width: 180},
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
]],

View File

@ -62,7 +62,7 @@
cols: [[
{type: "checkbox", fixed: "left"},
{field: "guid", title: "GUID", width: 280, sort: true},
{field: "name", title: "任务名称", width: 350},
{field: "name", title: "任务名称", width: 150},
{field: "createTime", title: "任务创建时间", width: 150},
{field: "startTime", title: "任务开始时间", width: 150},
{field: "endTime", title: "任务结束时间", width: 150},