180 行
6.2 KiB
HTML
可执行文件
180 行
6.2 KiB
HTML
可执行文件
<!--[1.1.96]-->
|
|
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/goodsList.css"/>
|
|
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/myscroll.css"/>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
table {
|
|
border: 1px solid #f1f1f1;
|
|
margin-top: 40px;
|
|
}
|
|
|
|
.layui-table-cell {
|
|
height: auto;
|
|
}
|
|
|
|
#exchange {
|
|
margin: 0 0 0 20px;
|
|
}
|
|
</style>
|
|
<div class="goodsBox">
|
|
<div class="goods_title">
|
|
<div class="goods_title_inner">
|
|
公告通知
|
|
</div>
|
|
</div>
|
|
<div class="goods_edit">
|
|
<form action="#" class="form-inline PromotionForm">
|
|
<if condition="$authArr['add'] eq true">
|
|
<button type="button" class="layui-btn" id="add">新增公告</button>
|
|
</if>
|
|
</form>
|
|
</div>
|
|
<script type="text/html" id="switchTpl">
|
|
|
|
<input type="checkbox" name="status" date-value="{{d.status}}" value="{{d.id}}" <if condition="$authArr['noticeon'] neq true"> disabled </if>
|
|
lay-skin="switch" lay-text="启用|禁用" lay-filter="boxTest" {{ d.stype== 1 ? 'checked' : '' }}>
|
|
|
|
</script>
|
|
<div class="goods_edit">
|
|
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
|
<script type="text/html" id="barDemo">
|
|
<if condition="$authArr['edit'] eq true">
|
|
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
|
|
</if>
|
|
<if condition="$authArr['del'] eq true">
|
|
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
|
|
</if>
|
|
</script>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
layui.use(['form', 'layedit', 'laydate', 'table'], function () {
|
|
// 日期
|
|
var laydate = layui.laydate, form = layui.form;
|
|
var table = layui.table;
|
|
//展示已知数据
|
|
table.render({
|
|
elem: '#test',
|
|
url: "{:U('/Retail/Notice/getNotice')}",
|
|
method:'post',
|
|
cols: [
|
|
[{
|
|
field: 'id',
|
|
title: '序号',
|
|
width: 60
|
|
}, {
|
|
field: 'title',
|
|
title: '标题',
|
|
align: 'center',
|
|
}, {
|
|
field: 'content',
|
|
title: '公告内容',
|
|
align: 'center',
|
|
}, {
|
|
field: 'addtime',
|
|
title: '添加时间',
|
|
align: 'center',
|
|
width: 180
|
|
}, {
|
|
field: 'stype',
|
|
title: '状态',
|
|
templet: '#switchTpl',
|
|
align: 'center',
|
|
width: 100
|
|
}, {
|
|
field: 'right',
|
|
title: '操作',
|
|
align: 'center',
|
|
toolbar: '#barDemo',
|
|
width: 150
|
|
}]
|
|
],
|
|
page: {
|
|
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
|
}, //是否开启分页
|
|
});
|
|
|
|
table.on('tool(demo)', function (obj) {
|
|
var data = obj.data;
|
|
var layEvent = obj.event;
|
|
if (layEvent === 'del') { //删除
|
|
layer.confirm('确定删除这个通知吗?', function (index) {
|
|
layer.close(index);
|
|
$.post("{:U('/Retail/Notice/del')}", {
|
|
id: data.id
|
|
}, function (res) {
|
|
// console.log(res);
|
|
if (res.status == 1) {
|
|
obj.del();
|
|
} else {
|
|
top.layer.msg(res.msg, {time: 1000});
|
|
}
|
|
})
|
|
});
|
|
}else if(layEvent === 'edit'){ //编辑
|
|
layer.open({
|
|
type: 2,
|
|
content: "{:U('/Retail/Notice/edit')}?id="+data.id,
|
|
title: "编辑通知",
|
|
area: ["700px", '400px'],
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
MenuApp.refreshWindow();
|
|
}
|
|
})
|
|
}
|
|
});
|
|
form.on('switch(boxTest)', function(data){
|
|
var id = this.value;
|
|
if(this.checked == true){
|
|
$.ajax({
|
|
url:"{:U('/Retail/Notice/noticeon')}",
|
|
type:"POST",
|
|
data:{id:id},
|
|
success:function(res){
|
|
// console.log(res);
|
|
if(res.status == 1){
|
|
top.layer.msg(res.msg, {time: 1000});
|
|
}else {
|
|
top.layer.msg(res.msg, {time: 1000});
|
|
window.location.reload()
|
|
}
|
|
}
|
|
})
|
|
}else if(this.checked == false){
|
|
$.ajax({
|
|
url:"{:U('/Retail/Notice/noticeoff')}",
|
|
type:"POST",
|
|
data:{id:id},
|
|
success:function(res){
|
|
// console.log(res);
|
|
if(res.status == 1){
|
|
top.layer.msg(res.msg, {time: 1000});
|
|
}else {
|
|
top.layer.msg(res.msg, {time: 1000});
|
|
window.location.reload()
|
|
}
|
|
}
|
|
})
|
|
}
|
|
});
|
|
$('#add').click(function () {
|
|
layer.open({
|
|
type: 2,
|
|
content: "{:U('/Retail/Notice/add')}",
|
|
title: "新增通知",
|
|
area: ["700px", '400px'],
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
MenuApp.refreshWindow();
|
|
}
|
|
})
|
|
|
|
});
|
|
})
|
|
</script>
|