173 行
5.6 KiB
HTML
可执行文件
173 行
5.6 KiB
HTML
可执行文件
<!--[1.5.22]-->
|
|
<style>
|
|
table {
|
|
border: 1px solid #f1f1f1;
|
|
margin-top: 40px;
|
|
}
|
|
|
|
.layui-table-cell {
|
|
height: auto;
|
|
text-align: center;
|
|
}
|
|
.layui-laypage .layui-laypage-curr .layui-laypage-em{
|
|
background-color: #409EFF;
|
|
}
|
|
.layui-table-page .layui-laypage a:hover, .layui-table-page .layui-laypage span:hover{
|
|
color: #409EFF;
|
|
}
|
|
.layui-btn{
|
|
background-color: #409EFF;
|
|
}
|
|
|
|
.layui-btn:hover{
|
|
opacity: 0.8;
|
|
color: #409EFF!important;
|
|
}
|
|
</style>
|
|
<div id="news" class="goodsBox">
|
|
<if condition="$authArr['addnews'] eq true">
|
|
<el-button type="primary" size="small" id="add">添加新闻</el-button>
|
|
</if>
|
|
|
|
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
|
<script type="text/html" id="newsinfo">
|
|
<if condition="$authArr['newsinfo'] eq true">
|
|
<span style="color: #409EFF;" lay-event="newsshow">查看详情</span>
|
|
</if>
|
|
</script>
|
|
<script type="text/html" id="barDemo">
|
|
<if condition="$authArr['addnews'] eq true">
|
|
<span type="text" style="color: #409EFF;" lay-event="edit">编辑</span>
|
|
</if>
|
|
<if condition="$authArr['delUser'] eq true">
|
|
<span type="text" style="color: #999;" lay-event="del">删除</span>
|
|
</if>
|
|
</script>
|
|
</div>
|
|
<script>
|
|
new Vue({
|
|
el: '#news',
|
|
methods: {}
|
|
})
|
|
layui.use(['table'], function () {
|
|
// 日期
|
|
var table = layui.table;
|
|
//展示已知数据
|
|
table.render({
|
|
elem: '#test',
|
|
url: "{:U('getData')}",
|
|
method: 'post',
|
|
cols: [
|
|
[{
|
|
field: 'index',
|
|
title: '序号',
|
|
width: 60
|
|
}, {
|
|
field: 'title',
|
|
title: '新闻名称',
|
|
align: 'center'
|
|
}, {
|
|
field: 'docuat',
|
|
title: '新闻简介',
|
|
align: 'center'
|
|
}, {
|
|
field: 'image',
|
|
title: '新闻图片',
|
|
style: 'height:100%;',
|
|
align: 'center',
|
|
templet: '<div><img src="{{ d.image}}" style="width: 80px;"></div>'
|
|
}, {
|
|
field: 'content',
|
|
title: '新闻内容',
|
|
align: 'center',
|
|
toolbar: '#newsinfo'
|
|
},
|
|
{
|
|
field: 'right',
|
|
title: '操作',
|
|
align: 'center',
|
|
toolbar: '#barDemo'
|
|
}]
|
|
],
|
|
page: {
|
|
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
|
}, //是否开启分页
|
|
});
|
|
$('#Preservation').click(function () {
|
|
table.reload('test', {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
}
|
|
, where: {
|
|
keyword: $('#keyword').val()
|
|
}
|
|
});
|
|
})
|
|
table.on('tool(demo)', function (obj) {
|
|
var data = obj.data;
|
|
var layEvent = obj.event;
|
|
var tr = obj.tr;
|
|
if (layEvent === 'detail') { //查看
|
|
//do somehing
|
|
window.location.href = "{:U('shiftingdetail')}?id=" + data.id;
|
|
} else if (layEvent === 'del') { //删除
|
|
layer.confirm('确定删除这个新闻吗?', function (index) {
|
|
layer.close(index);
|
|
//向服务端发送删除指令
|
|
$.ajax({
|
|
url: "{:U('delUser')}",
|
|
data: {id: data.id},
|
|
type: 'post',
|
|
success: function (res) {
|
|
if (res.status == 1) {
|
|
obj.del();
|
|
} else {
|
|
top.layer.msg(res.msg, {icon: 4, time: 1000})
|
|
}
|
|
}
|
|
})
|
|
});
|
|
} else if (obj.event === 'edit') {
|
|
layer.open({
|
|
type: 2,
|
|
title: "编辑",
|
|
content: "{:U('addnews')}?id=" + data.id,
|
|
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
|
|
offset: 'rb',
|
|
shade: 0,
|
|
end: function () {
|
|
MenuApp.refreshWindow();
|
|
// table.reload('test', {})
|
|
}
|
|
})
|
|
} else if (obj.event === 'newsshow') {
|
|
layer.open({
|
|
type: 2,
|
|
title: "新闻内容",
|
|
area: ["600px", "600px"],
|
|
content: "{:U('newsinfo')}?id=" + data.id,
|
|
end: function () {
|
|
|
|
}
|
|
})
|
|
}
|
|
});
|
|
$('#add').click(function () {
|
|
layer.open({
|
|
type: 2,
|
|
content: "{:U('addnews')}",
|
|
title: "添加新闻",
|
|
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
|
|
offset: 'rb',
|
|
shade: 0,
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
MenuApp.refreshWindow();
|
|
// table.reload('test', {});
|
|
}
|
|
})
|
|
|
|
})
|
|
})
|
|
</script>
|