230 lines
9.4 KiB
HTML
230 lines
9.4 KiB
HTML
{layout name="layout1" /}
|
|
<style>
|
|
.layui-table-cell {
|
|
height: auto;
|
|
white-space: normal;
|
|
}
|
|
</style>
|
|
<div class="wrapper">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<div class="layui-collapse like-layui-collapse">
|
|
<div class="layui-colla-item">
|
|
<h2 class="layui-colla-title like-layui-colla-title">操作提示</h2>
|
|
<div class="layui-colla-content layui-show">
|
|
<p>* 可通过关键词搜索历史文章;</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 搜索区域 -->
|
|
<div class="layui-card-body layui-form">
|
|
<div class="layui-form-item">
|
|
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">文章标题:</label>
|
|
<div class="layui-input-block">
|
|
<input type="text" id="title" name="title" placeholder="请输入文章标题"
|
|
autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- <div class="layui-inline">-->
|
|
<!-- <label for="goods_name" class="layui-form-label">商品名称:</label>-->
|
|
<!-- <div class="layui-inline" style="margin-right:0;">-->
|
|
<!-- <div class="layui-input-inline" >-->
|
|
<!-- <input type="text" id="goods_name" name="goods_name" placeholder="请输入商品名称"-->
|
|
<!-- autocomplete="off" class="layui-input">-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
|
|
<div class="layui-inline">
|
|
<a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
|
|
<a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-tab layui-tab-card" lay-filter="tab-all">
|
|
<div class="layui-tab-item layui-show">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<button type="button" id="add-mail-news" class="layui-btn layui-btn-normal layui-btn-sm layEvent">添加</button>
|
|
<table id="like-table-lists" lay-filter="like-table-lists"></table>
|
|
<script type="text/html" id="operation">
|
|
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="audit">编辑</a>
|
|
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
|
|
</script>
|
|
<!-- 文章标题 -->
|
|
<script type="text/html" id="news-type">
|
|
<div >
|
|
{{# if(d.type == 0 ){ }}
|
|
文章
|
|
{{# } else { }}
|
|
视频
|
|
{{# } }}
|
|
</div>
|
|
</script>
|
|
<!-- 是否置顶 -->
|
|
<script type="text/html" id="news-top">
|
|
<div >
|
|
{{# if(d.is_top == 0 ){ }}
|
|
否
|
|
{{# } else { }}
|
|
是
|
|
{{# } }}
|
|
</div>
|
|
</script>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<script>
|
|
layui.use(['table', 'laydate', 'form'], function () {
|
|
var $ = layui.$
|
|
, table = layui.table
|
|
, element = layui.element
|
|
, form = layui.form
|
|
, status = 'all';
|
|
|
|
|
|
form.on("submit(search)", function(data){
|
|
table.reload("like-table-lists", {
|
|
where: data.field,
|
|
page: {
|
|
curr: 1
|
|
}
|
|
});
|
|
});
|
|
|
|
form.on("submit(clear-search)", function(){
|
|
$("#goods_name").val("");
|
|
$("#shop_id").val("");
|
|
form.render();
|
|
table.reload("like-table-lists", {
|
|
where: {},
|
|
page: {
|
|
curr: 1
|
|
}
|
|
});
|
|
});
|
|
|
|
getList();
|
|
element.on('tab(tab-all)', function (data) {
|
|
status = $(this).attr('data-type');
|
|
getList();
|
|
});
|
|
|
|
function getList() {
|
|
like.tableLists("#like-table-lists", '{:url("mallNews/lists")}', [
|
|
{field: 'goodsId', width: 80, title: 'ID', sort: true, hide: true}
|
|
, {field: 'title', title: '标题', width: 300}
|
|
, {field: 'type', title: '文章类型', width: 200, align: 'center',templet: '#news-type'}
|
|
, {field: 'is_top', title: '是否置顶', width: 320, align: 'center', templet: '#news-top'}
|
|
, {fixed: 'right', title: '操作', width: 400, align: 'center', toolbar: '#operation'}
|
|
]);
|
|
}
|
|
|
|
//添加快讯
|
|
$(document).on('click', '#add-mail-news', function () {
|
|
layer.open({
|
|
type: 2
|
|
, title: '添加快讯'
|
|
, content: '{:url("MallNews/add")}'
|
|
, area: ['90%', '90%']
|
|
,btn: ['确定', '取消']
|
|
, yes: function (index, layero) {
|
|
var iframeWindow = window['layui-layer-iframe' + index]
|
|
, submitID = 'addSubmit'
|
|
, submit = layero.find('iframe').contents().find('#' + submitID);
|
|
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
|
|
var field = data.field;
|
|
like.ajax({
|
|
url: '{:url("mallNews/add")}',
|
|
data: field,
|
|
type: "post",
|
|
success: function (res) {
|
|
if (res.code === 1) {
|
|
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
|
layer.close(index);
|
|
table.reload('like-table-lists');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
submit.trigger('click');
|
|
}
|
|
});
|
|
});
|
|
|
|
//事件
|
|
var active = {
|
|
audit: function (obj) {
|
|
console.log(obj)
|
|
layer.open({
|
|
type: 2
|
|
, title: '编辑'
|
|
, content: '{:url("mallNews/audit")}?id=' + obj.data.id
|
|
, area: ['90%', '90%']
|
|
,btn: ['确定', '取消']
|
|
, yes: function (index, layero) {
|
|
var iframeWindow = window['layui-layer-iframe' + index]
|
|
, submitID = 'addSubmit'
|
|
, submit = layero.find('iframe').contents().find('#' + submitID);
|
|
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
|
|
var field = data.field;
|
|
like.ajax({
|
|
url: '{:url("mallNews/audit")}',
|
|
data: field,
|
|
type: "post",
|
|
success: function (res) {
|
|
if (res.code === 1) {
|
|
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
|
layer.close(index);
|
|
table.reload('like-table-lists');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
submit.trigger('click');
|
|
}
|
|
});
|
|
},
|
|
// 删除
|
|
del: function (obj) {
|
|
layer.confirm('确定要删除该文章吗?', function (index) {
|
|
like.ajax({
|
|
url: '{:url("mallNews/del")}',
|
|
data: {id: obj.data.id},
|
|
type: "post",
|
|
success: function (res) {
|
|
if (res.code === 1) {
|
|
layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
|
|
layer.close(index);
|
|
obj.del();
|
|
}
|
|
}
|
|
});
|
|
layer.close(index);
|
|
})
|
|
}
|
|
};
|
|
|
|
// 监听表格右侧工具条
|
|
table.on('tool(like-table-lists)', function (obj) {
|
|
var type = obj.event;
|
|
active[type] ? active[type].call(this, obj) : '';
|
|
});
|
|
|
|
// 绑定点击按钮事件
|
|
$('.layui-btn.layuiadmin-btn').on('click', function () {
|
|
var type = $(this).data('type');
|
|
active[type] ? active[type].call(this) : '';
|
|
});
|
|
});
|
|
</script> |