impr:常用页面接口

master
bobi 2019-11-03 22:18:01 +08:00
parent b172bb28aa
commit bd15d1b817
6 changed files with 889 additions and 998 deletions

View File

@ -9,6 +9,11 @@ layui.define([], function (exprots) {
listRole: "http://rap2api.taobao.org/app/mock/233041/role/listRole",
listArticle: "http://rap2api.taobao.org/app/mock/233041/article/listArticle",
listMessage: "http://rap2api.taobao.org/app/mock/233041/message/listMessage",
listProduct: "http://rap2api.taobao.org/app/mock/233041/product/listProduct",
listDownload: "http://rap2api.taobao.org/app/mock/233041/download/listDownload",
listLink: "http://rap2api.taobao.org/app/mock/233041/link/listLink",
listTask: "http://rap2api.taobao.org/app/mock/233041/task/listTask",
listImage: "http://rap2api.taobao.org/app/mock/233041/image/listImage",
listBbs: "http://rap2api.taobao.org/app/mock/233041/bbs/listBbs",

View File

@ -8,17 +8,6 @@
</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">
@ -36,23 +25,23 @@
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
layui.use(["element", "table", "form", "laydate", "okLayer", "okUtils", "okMock"], function () {
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;
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;
util.fixbar({});
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
var articleTable = table.render({
let articleTable = table.render({
elem: "#tableId",
url: okMock.api.download.list,
url: okMock.api.listDownload,
limit: 20,
page: true,
even: true,
@ -61,21 +50,23 @@
cols: [[
{type: "checkbox", fixed: "left"},
{field: "id", title: "ID", width: 170, sort: true},
{field: "name", title: "资源名称", width: 250},
{field: "name", title: "资源名称", width: 150},
{field: "remarks", title: "资源信息", width: 250},
{field: "url", title: "预览", width: 250, templet: "#urlTpl"},
{field: "publisher", title: "发布者", width: 100},
{field: "downloadSize", title: "下载量", width: 80},
{field: "recommend", title: "是否推荐", width: 100, align: "center", templet: "#recommendTpl"},
{field: "status", title: "状态", width: 110, align: "center", templet: "#statusTpl"},
{field: "createTime", title: "创建时间", width: 180},
{field: "updateTime", title: "更新时间", width: 180},
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
]],
done: function (res, curr, count) {
console.log(res, curr, count)
console.log(res, curr, count);
}
});
form.on("submit(search)", function () {
form.on("submit(search)", function (data) {
articleTable.reload({
where: data.field,
page: {curr: 1}
@ -91,8 +82,8 @@
case "batchDisabled":
batchDisabled();
break;
case "batchDel":
batchDel();
case "batchDelete":
batchDelete();
break;
case "add":
add();
@ -101,13 +92,13 @@
});
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
let data = obj.data;
switch (obj.event) {
case "edit":
edit(data.id);
case "updateById":
updateById(data.id);
break;
case "del":
del(data.id);
case "deleteById":
deleteById(data.id);
break;
}
});
@ -115,13 +106,12 @@
function batchEnabled() {
okLayer.confirm("确定要批量上架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchNormal", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量上架成功");
okUtils.ajax("/download/update-download-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
@ -130,54 +120,51 @@
function batchDisabled() {
okLayer.confirm("确定要批量下架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchStop", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量下架成功");
okUtils.ajax("/download/update-download-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function batchDel() {
function batchDelete() {
okLayer.confirm("确定要批量删除吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchDel", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量删除成功");
okUtils.ajax("/download/deleteDownload", "delete", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function add() {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
okLayer.open("添加文章", "download-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)
});
})
}
function updateById(id) {
okLayer.open("编辑文章", "download-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
});
}
function deleteById(id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/download/deleteDownload", "delete", {idsStr: id}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error);
});
});
}
})
</script>
@ -186,20 +173,20 @@
<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>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batchDelete">批量删除</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>
<a href="javascript:" title="编辑" lay-event="updateById"><i class="layui-icon">&#xe642;</i></a>
<a href="javascript:" title="删除" lay-event="deleteById"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 链接 -->
<script type="text/html" id="urlTpl">
<a href="{{d.url}}" target="_blank">{{d.url}}</a>
</script>
<!-- 土建 -->
<!-- 是否推荐 -->
<script type="text/html" id="recommendTpl">
{{# if(d.recommend == 0){ }}
<span class="layui-btn layui-btn-normal layui-btn-xs">已推荐</span>
@ -217,6 +204,5 @@
<span class="layui-btn layui-btn-warm layui-btn-xs">已删除</span>
{{# } }}
</script>
</body>
</html>

View File

@ -8,17 +8,6 @@
</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">
@ -36,23 +25,23 @@
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
layui.use(["element", "table", "form", "laydate", "okLayer", "okUtils", "okMock"], function () {
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;
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;
util.fixbar({});
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
var articleTable = table.render({
let articleTable = table.render({
elem: "#tableId",
url: okMock.api.article.list,
url: okMock.api.listImage,
limit: 20,
page: true,
even: true,
@ -61,12 +50,14 @@
cols: [[
{type: "checkbox", fixed: "left"},
{field: "id", title: "ID", width: 170, sort: true},
{field: "title", title: "标题", width: 350},
{field: "title", title: "标题", width: 150},
{field: "url", title: "链接", width: 250, templet: "#urlTpl"},
{field: "publisher", title: "发布者", width: 100},
{field: "readSize", title: "阅读量", width: 80},
{field: "isTop", title: "是否置顶", width: 100, align: "center", templet: "#topTpl"},
{field: "status", title: "发布状态", width: 110, align: "center", templet: "#statusTpl"},
{field: "createTime", title: "创建时间", width: 150},
{field: "updateTime", title: "更新时间", width: 150},
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
]],
done: function (res, curr, count) {
@ -74,7 +65,7 @@
}
});
form.on("submit(search)", function () {
form.on("submit(search)", function (data) {
articleTable.reload({
where: data.field,
page: {curr: 1}
@ -90,8 +81,8 @@
case "batchDisabled":
batchDisabled();
break;
case "batchDel":
batchDel();
case "batchDelete":
batchDelete();
break;
case "add":
add();
@ -100,13 +91,13 @@
});
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
let data = obj.data;
switch (obj.event) {
case "edit":
edit(data.id);
case "updateById":
updateById(data.id);
break;
case "del":
del(data.id);
case "deleteById":
deleteById(data.id);
break;
}
});
@ -114,13 +105,12 @@
function batchEnabled() {
okLayer.confirm("确定要批量上架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchNormal", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量上架成功");
okUtils.ajax("/image/update-image-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
@ -129,52 +119,49 @@
function batchDisabled() {
okLayer.confirm("确定要批量下架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchStop", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量下架成功");
okUtils.ajax("/image/update-image-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function batchDel() {
function batchDelete() {
okLayer.confirm("确定要批量删除吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchDel", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量删除成功");
okUtils.ajax("/image/deleteImage", "delete", {idsStr: idsStr}).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function add() {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
okLayer.open("添加图片", "image-add.html", "90%", "90%", null, function () {
articleTable.reload();
})
}
function edit(id) {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", null, function () {
function updateById(id) {
okLayer.open("编辑图片", "image-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
})
}
function del(id) {
function deleteById(id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/article/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response);
okUtils.table.successMsg("删除成功");
okUtils.ajax("/image/deleteImage", "delete", {idsStr: id}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
})
}
@ -185,17 +172,14 @@
<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>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batchDelete">批量删除</button>
<button class="layui-btn layui-btn-sm" lay-event="add">添加图片</button>
</div>
</script>
<!-- 链接模板 -->
<script type="text/html" id="urlTpl">
<a href="{{d.url}}" target="_blank">{{d.url}}</a>
</script>
<!-- 是否指顶模板
<input type="checkbox" name="isTop" value="{{d.isTop}}" lay-skin="switch" lay-text="是|否" {{ d.isTop== true ? 'checked' : ''}}>
-->
<script type="text/html" id="topTpl">
{{# if(d.isTop == true){ }}
<span class="layui-btn layui-btn-normal layui-btn-xs">已置顶</span>
@ -203,9 +187,6 @@
<span class="layui-btn layui-btn-warm layui-btn-xs">未置顶</span>
{{# } }}
</script>
<!-- 发布状态模板
<input type="checkbox" name="top" value="{{d.status}}" lay-skin="switch" lay-text="已发布|未发布" {{ d.status== true ? 'checked' : ''}}>
-->
<script type="text/html" id="statusTpl">
{{# if(d.status == true){ }}
<span class="layui-btn layui-btn-normal layui-btn-xs">已发布</span>
@ -215,8 +196,8 @@
</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>
<a href="javascript:" title="编辑" lay-event="updateById"><i class="layui-icon">&#xe642;</i></a>
<a href="javascript:" title="删除" lay-event="deleteById"><i class="layui-icon">&#xe640;</i></a>
</script>
</body>
</html>

View File

@ -8,17 +8,6 @@
</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">
@ -36,23 +25,23 @@
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
layui.use(["element", "table", "form", "laydate", "okLayer", "okUtils", "okMock"], function () {
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;
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;
util.fixbar({});
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
var articleTable = table.render({
let articleTable = table.render({
elem: "#tableId",
url: okMock.api.link.list,
url: okMock.api.listLink,
limit: 20,
page: true,
even: true,
@ -61,11 +50,12 @@
cols: [[
{type: "checkbox", fixed: "left"},
{field: "id", title: "ID", width: 170, sort: true},
{field: "name", title: "名称", width: 100},
{field: "name", title: "名称", width: 150},
{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},
{field: "updateTime", title: "更新时间", width: 150},
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
]],
done: function (res, curr, count) {
@ -73,7 +63,7 @@
}
});
form.on("submit(search)", function () {
form.on("submit(search)", function (data) {
articleTable.reload({
where: data.field,
page: {curr: 1}
@ -83,97 +73,59 @@
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;
case "batchDelete":
batchDel();
break;
}
});
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
let data = obj.data;
switch (obj.event) {
case "edit":
edit(data.id);
case "updateById":
updateById(data.id);
break;
case "del":
del(data.id);
case "deleteById":
deleteById(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);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchDel", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量删除成功");
okUtils.ajax("/link/deleteLink", "delete", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function add() {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
okLayer.open("添加连接", "link-add.html", "90%", "90%", null, function () {
articleTable.reload();
})
}
function edit(id) {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", null, function () {
function updateById(id) {
okLayer.open("编辑连接", "link-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
})
}
function del(id) {
function deleteById(id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/article/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response);
okUtils.table.successMsg("删除成功");
okUtils.ajax("/link/deleteLink", "delete", {idsStr: id}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
})
}
@ -182,22 +134,19 @@
<!-- 头工具栏模板 -->
<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 class="layui-inline" lay-event="add"><i class="layui-icon">&#xe654;</i></div>
<div class="layui-inline" lay-event="batchDelete"><i class="layui-icon">&#xe640;</i></div>
</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>
<a href="javascript:" title="编辑" lay-event="updateById"><i class="layui-icon">&#xe642;</i></a>
<a href="javascript:" title="删除" lay-event="deleteById"><i class="layui-icon">&#xe640;</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){ }}
@ -208,6 +157,5 @@
<span class="layui-btn layui-btn-danger layui-btn-xs">已删除</span>
{{# } }}
</script>
</body>
</html>

View File

@ -8,17 +8,6 @@
</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">
@ -36,23 +25,23 @@
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
layui.use(["element", "table", "form", "laydate", "okLayer", "okUtils", "okMock"], function () {
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;
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;
util.fixbar({});
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
var articleTable = table.render({
let articleTable = table.render({
elem: "#tableId",
url: okMock.api.product.list,
url: okMock.api.listProduct,
limit: 20,
page: true,
even: true,
@ -60,12 +49,13 @@
size: "lg",
cols: [[
{type: "checkbox", fixed: "left"},
{field: "id", title: "ID", width: 170, sort: true},
{field: "id", title: "ID", width: 200, sort: true},
{field: "name", title: "产品名称", width: 100},
{field: "logo", title: "产品LOGO", width: 150, templet: "#logoTpl"},
{field: "url", title: "产品官网", width: 200, templet: "#urlTpl"},
{field: "description", title: "产品描述", width: 400},
{field: "createTime", title: "创建时间", width: 180},
{field: "updateTime", title: "更新时间", width: 180},
{title: "操作", width: 100, align: "center", fixed: "right", templet: "#operationTpl"}
]],
done: function (res, curr, count) {
@ -73,7 +63,7 @@
}
});
form.on("submit(search)", function () {
form.on("submit(search)", function (data) {
articleTable.reload({
where: data.field,
page: {curr: 1}
@ -89,8 +79,8 @@
case "batchDisabled":
batchDisabled();
break;
case "batchDel":
batchDel();
case "batchDelete":
batchDelete();
break;
case "add":
add();
@ -99,13 +89,13 @@
});
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
let data = obj.data;
switch (obj.event) {
case "edit":
edit(data.id);
case "updateById":
updateById(data.id);
break;
case "del":
del(data.id);
case "deleteById":
deleteById(data.id);
break;
}
});
@ -113,13 +103,12 @@
function batchEnabled() {
okLayer.confirm("确定要批量上架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchNormal", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量上架成功");
okUtils.ajax("/product/update-product-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
@ -128,52 +117,49 @@
function batchDisabled() {
okLayer.confirm("确定要批量下架吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchStop", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量下架成功");
okUtils.ajax("/product/update-product-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function batchDel() {
function batchDelete() {
okLayer.confirm("确定要批量删除吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchDel", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量删除成功");
okUtils.ajax("/product/deleteProduct", "delete", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function add() {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
okLayer.open("添加产品", "product-add.html", "90%", "90%", null, function () {
articleTable.reload();
})
}
function edit(id) {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", null, function () {
function updateById(id) {
okLayer.open("编辑产品", "product-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
})
}
function del(id) {
function deleteById(id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/article/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response);
okUtils.table.successMsg("删除成功");
okUtils.ajax("/product/deleteProduct", "delete", {idsStr: id}).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
})
}
@ -184,14 +170,14 @@
<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>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batchDelete">批量删除</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>
<a href="javascript:" title="编辑" lay-event="updateById"><i class="layui-icon">&#xe642;</i></a>
<a href="javascript:" title="删除" lay-event="deleteById"><i class="layui-icon">&#xe640;</i></a>
</script>
<script type="text/html" id="logoTpl">

View File

@ -8,17 +8,6 @@
</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">
@ -37,23 +26,23 @@
<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;
let element = layui.element;
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;
util.fixbar({});
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
var articleTable = table.render({
let articleTable = table.render({
elem: "#tableId",
url: okMock.api.task.list,
url: okMock.api.listTask,
limit: 20,
page: true,
even: true,
@ -77,7 +66,7 @@
}
});
form.on("submit(search)", function () {
form.on("submit(search)", function (data) {
articleTable.reload({
where: data.field,
page: {curr: 1}
@ -87,14 +76,14 @@
table.on("toolbar(tableFilter)", function (obj) {
switch (obj.event) {
case "batchEnabled":
batchEnabled();
case "batchStart":
batchStart();
break;
case "batchDisabled":
batchDisabled();
case "batchEnd":
batchEnd();
break;
case "batchDel":
batchDel();
case "batchDelete":
batchDelete();
break;
case "add":
add();
@ -103,81 +92,77 @@
});
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
let data = obj.data;
switch (obj.event) {
case "edit":
edit(data.id);
case "updateById":
updateById(data.id);
break;
case "del":
del(data.id);
case "deleteById":
deleteById(data.id);
break;
}
});
function batchEnabled() {
okLayer.confirm("确定要批量上架吗?", function (index) {
function batchStart() {
okLayer.confirm("确定要批量开始吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchNormal", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量上架成功");
okUtils.ajax("/task/update-task-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function batchDisabled() {
okLayer.confirm("确定要批量下架吗?", function (index) {
function batchEnd() {
okLayer.confirm("确定要批量结束吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchStop", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量下架成功");
okUtils.ajax("/task/update-task-status", "put", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function batchDel() {
function batchDelete() {
okLayer.confirm("确定要批量删除吗?", function (index) {
layer.close(index);
var idsStr = okUtils.table.batchCheck(table);
let idsStr = okUtils.tableBatchCheck(table);
if (idsStr) {
okUtils.ajax("/article/batchDel", "post", {idsStr: idsStr}).done(function (response) {
console.log(response);
okUtils.table.successMsg("批量删除成功");
okUtils.ajax("/task/deleteTask", "delete", {idsStr: idsStr}, true).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
}
});
}
function add() {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
okLayer.open("添加任务", "task-add.html", "90%", "90%", null, function () {
articleTable.reload();
})
}
function edit(id) {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", null, function () {
function updateById(id) {
okLayer.open("编辑任务", "task-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
})
}
function del(id) {
function deleteById(id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/article/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response);
okUtils.table.successMsg("删除成功");
okUtils.ajax("/task/deleteTask", "delete", {idsStr: id}).done(function (response) {
okUtils.tableSuccessMsg(response.msg);
}).fail(function (error) {
console.log(error)
console.log(error);
});
})
}
@ -186,16 +171,16 @@
<!-- 头工具栏模板 -->
<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>
<button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="batchStart">批量开始</button>
<button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="batchEnd">批量结束</button>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batchDelete">批量删除</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>
<a href="javascript:" title="编辑" lay-event="updateById"><i class="layui-icon">&#xe642;</i></a>
<a href="javascript:" title="删除" lay-event="deleteById"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 任务进度 -->
<script type="text/html" id="progressTpl">