dev_oa/app/home/view/note/index.html

126 lines
2.9 KiB
HTML

{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="body-table">
<table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<span class="layui-btn layui-btn-normal layui-btn-sm" lay-event="add">+ 添加公告</span>
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">查看</span><span class="layui-btn layui-btn-xs" lay-event="edit"></span><span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"></span></div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
function init(layui) {
var table = layui.table,
rightpage = layui.rightpage,
form = layui.form;
var tableIns = table.render({
elem: '#test',
title: '公告列表',
toolbar: '#toolbarDemo',
url: "/home/note/index", //数据接口
cols: [
[
{
field: 'id',
title: 'ID号',
align: 'center',
width: 80
}, {
field: 'sort',
title: '排序',
align: 'center',
width: 80
},{
field: 'cate_title',
title: '公告分类',
align: 'center',
width: 136
}, {
field: 'title',
title: '公告标题'
}, {
field: 'cate_title',
title: '公告展示期间',
align: 'center',
width: 196,
templet: function (d) {
var html = d.start_time + ' ~ ' + d.end_time;
return html;
}
},{
field: 'status',
title: '状态',
toolbar: '#status',
align: 'center',
width: 60
}, {
field: 'right',
title: '操作',
toolbar: '#barDemo',
width: 136,
align: 'center'
}
]
]
});
//表头工具栏事件
table.on('toolbar(test)', function(obj){
if (obj.event === 'add') {
rightpage.open("/home/note/add");
return;
}
})
//监听行工具事件
table.on('tool(test)', function(obj) {
var data = obj.data;
if (obj.event === 'view') {
rightpage.open("/home/note/view?id="+data.id);
return;
}
if (obj.event === 'edit') {
rightpage.open("/home/note/add?id="+data.id);
return;
}
if (obj.event === 'del') {
layer.confirm('确定删除该公告吗?', {
icon: 3,
title: '提示'
}, function(index) {
$.ajax({
url: "/home/note/delete",
data: {
id: data.id
},
success: function(res) {
layer.msg(res.msg);
if (res.code == 1) {
obj.del();
}
}
})
layer.close(index);
});
}
});
}
</script>
{include file="common/layui" base='base' extend="['rightpage']" use="['table','form']" callback="init" /}
{/block}
<!-- /脚本 -->