文件

145 行
5.0 KiB
HTML
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<!--[1.5.22]-->
<style>
table {
border: 1px solid #f1f1f1;
margin-top: 40px;
}
.layui-table-cell {
height: 45px;
line-height: 45px;
padding: 0 15px;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
box-sizing: border-box;
}
</style>
<div class="goodsBox">
<div style="margin:10px;">1.会员卡分享设置只能保留一条规则,支持修改和删除后添加</div>
<if condition="$state eq 2">
<div class="goods_edit">
<if condition="$authArr['addshare'] eq true">
<button type="button" class="layui-btn" id="add">添加</button>
</if>
</div>
</if>
<table class="layui-hide" id="test" lay-filter="demo"></table>
</div>
<script type="text/html" id="barDemo">
<if condition="$authArr['addshare'] eq true">
<a class="layui-btn layui-btn-sm edit" lay-event="edit">编辑</a>
</if>
<if condition="$authArr['delinfo'] eq true">
<a class="layui-btn layui-btn-sm edit" lay-event="delete">删除</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('vipshare')}",
method: 'post',
cols: [
[ //标题栏
{
field: 'id',
title: '序号',
width: 60
},
{
field: 'title',
title: '名片名称',
align: 'center',
}, {
field: 'describe',
title: '描述',
align: 'center',
}, {
field: 'image',
title: '头像',
align: 'center',
width: 160,
style: 'height:100%;',
templet: '<div><img src="{{ d.image}}" style="width: 80px;height: 100%;"></div>'
}, {
fixed: 'right',
title: '操作',
align: 'center',
toolbar: '#barDemo',
width: 300
}
]
],
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') { //编辑
layer.open({
type: 2,
content: "{:U('addshare')}?id=" + data.id,
title: "编辑信息",
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
shade: 0,
offset: 'rb',
end: function () {
table.reload('test', {});
}
})
} else if (obj.event === 'delete') {
layer.confirm("确认删除?", function (index) {
var id = data.id
$.ajax({
url: "{:U('delinfo')}",
type: "post",
data: {id: id},
success: function (res) {
if (res.status == 1) {
layer.msg(res.msg, function () {
MenuApp.refreshWindow();
//window.location.reload();
})
} else {
layer.msg(res.msg, function () {
window.location.reload();
})
}
}
})
});
}
});
$('#add').click(function () {
layer.open({
type: 2,
content: "{:U('addshare')}",
title: "添加信息",
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
shade: 0,
offset: 'rb',
end: function () {
MenuApp.refreshWindow();
}
})
})
function checkPwd(pwd) {
var reg = /^[a-zA-Z0-9]{1,}$/;
if (reg.test(pwd) == false) {
return false;
}
return true;
}
})
</script>