147 行
5.0 KiB
HTML
可执行文件
147 行
5.0 KiB
HTML
可执行文件
<!--[1.5.22]-->
|
||
<style>
|
||
table {
|
||
border: 1px solid #f1f1f1;
|
||
margin-top: 40px;
|
||
}
|
||
</style>
|
||
<div>
|
||
<div class="goods_edit">
|
||
<div class="goods_edit_input">
|
||
<input class="searchInput form-control" value="" type="text" placeholder="标题" id="keyword">
|
||
</div>
|
||
<button type="button" class="layui-btn" id="Preservation">查询</button>
|
||
<if condition="$authArr['add'] eq true">
|
||
<button type="button" class="layui-btn" id="add">添加</button>
|
||
</if>
|
||
</div>
|
||
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
||
</div>
|
||
|
||
<script type="text/html" id="barDemo">
|
||
<if condition="$authArr['editad'] eq true">
|
||
<a class="layui-btn layui-btn-sm edit" lay-event="edit">编辑</a>
|
||
</if>
|
||
<if condition="$authArr['del'] eq true">
|
||
<a class="layui-btn layui-btn-danger layui-btn-sm del" lay-event="del">删除</a>
|
||
</if>
|
||
</script>
|
||
<script>
|
||
layui.use(['form', 'layedit', 'laydate', 'table'], function () {
|
||
// 日期
|
||
var laydate = layui.laydate;
|
||
var table = layui.table;
|
||
var form = layui.form
|
||
//展示已知数据
|
||
table.render({
|
||
elem: '#test',
|
||
url: "{:U('Content/getcontent')}",
|
||
method: 'post',
|
||
limit: 8,
|
||
cols: [
|
||
[ //标题栏
|
||
{
|
||
field: 'id',
|
||
title: '序号',
|
||
width: 60
|
||
}, {
|
||
field: 'name',
|
||
title: '菜单名称',
|
||
align: 'center',
|
||
}, {
|
||
field: 'titles',
|
||
title: '标题',
|
||
align: 'center',
|
||
}, {
|
||
fixed: 'right',
|
||
title: '操作',
|
||
align: 'center',
|
||
toolbar: '#barDemo',
|
||
width: 250
|
||
}
|
||
]
|
||
],
|
||
page: {
|
||
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
||
}, //是否开启分页
|
||
});
|
||
|
||
table.on('tool(demo)', function (obj) { //注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值"
|
||
var data = obj.data; //获得当前行数据
|
||
if (obj.event === 'edit') { //编辑
|
||
// console.log(data.id);
|
||
top.layer.open({
|
||
type: 2,
|
||
content: "{:U('Content/editad')}?id=" + data.id,
|
||
title: "编辑-内容信息",
|
||
area: ["45%", '90%'],
|
||
btnAlign: 'c',
|
||
end: function () {
|
||
table.reload('test', {});
|
||
}
|
||
})
|
||
} else if (obj.event == 'del') {
|
||
id = data.id;
|
||
console.log(data.id);
|
||
layer.confirm("您确认要删除该菜单吗?", function (index) {
|
||
$.ajax({
|
||
url: "{:U('Super/Content/del')}",
|
||
type: "POST",
|
||
data: {id: data.id},
|
||
success: function (res) {
|
||
if (res.status == 1) {
|
||
layer.msg(res.msg, {
|
||
icon: 1,
|
||
time: 1000
|
||
}, function () {
|
||
table.reload('test', {})
|
||
layer.close(index);
|
||
})
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
icon: 1,
|
||
time: 1000
|
||
})
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}
|
||
});
|
||
|
||
//查询
|
||
$('#Preservation').click(function () {
|
||
//执行重载
|
||
table.reload('test', {
|
||
page: {
|
||
curr: 1 //重新从第 1 页开始
|
||
}
|
||
, where: {
|
||
keyword: $('#keyword').val()
|
||
}
|
||
});
|
||
})
|
||
$('#add').click(function () {
|
||
top.layer.open({
|
||
type: 2,
|
||
content: "{:U('Content/add')}",
|
||
title: "添加内容",
|
||
area: ["45%", "90%"],
|
||
btnAlign: 'c',
|
||
end: function () {
|
||
table.reload('test', {});
|
||
}
|
||
})
|
||
|
||
})
|
||
|
||
function checkPwd(pwd) {
|
||
var reg = /^[a-zA-Z0-9]{1,}$/;
|
||
if (reg.test(pwd) == false) {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
})
|
||
</script>
|