105 行
3.4 KiB
HTML
可执行文件
105 行
3.4 KiB
HTML
可执行文件
<!--[1.5.22]-->
|
|
<style>
|
|
table {
|
|
border: 1px solid #f1f1f1;
|
|
margin-top: 40px;
|
|
}
|
|
|
|
.layui-table-cell {
|
|
height: auto;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
<div>
|
|
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
|
<script type="text/html" id="barDemo">
|
|
<if condition="$authArr['delUser'] eq true">
|
|
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
|
|
</if>
|
|
</script>
|
|
</div>
|
|
<script>
|
|
layui.use(['form', 'layedit', 'laydate', 'table'], function () {
|
|
// 日期
|
|
var laydate = layui.laydate;
|
|
var table = layui.table;
|
|
//展示已知数据
|
|
table.render({
|
|
elem: '#test',
|
|
url: "{:U('getData')}",
|
|
method: 'post',
|
|
cols: [
|
|
[ //标题栏
|
|
{
|
|
field: 'id',
|
|
title: 'ID',
|
|
width: 60
|
|
}, {
|
|
field: 'name',
|
|
title: '昵称'
|
|
}, {
|
|
field: 'phone',
|
|
title: '联系方式'
|
|
}, {
|
|
field: 'email',
|
|
title: '邮箱',
|
|
}, {
|
|
field: 'addtime',
|
|
title: '提交时间',
|
|
width: 180
|
|
}, {
|
|
field: 'content',
|
|
title: '内容',
|
|
},
|
|
{
|
|
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) {
|
|
top.layer.msg(res.msg, {icon: 1, time: 1000});
|
|
obj.del();
|
|
} else {
|
|
top.layer.msg(res.msg, {icon: 4, time: 1000})
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
});
|
|
})
|
|
</script>
|