<div class="layui-fluid layui-anim febs-anim" id="febs-coupon-rule" lay-title="优惠卷管理">
|
<div class="layui-row febs-container">
|
<div class="layui-col-md12">
|
<div class="layui-card">
|
<div class="layui-card-body febs-table-full">
|
<form class="layui-form layui-table-form" lay-filter="coupon-table-form">
|
<div class="layui-row">
|
<div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
|
<div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add">
|
新增
|
</div>
|
<div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
|
<i class="layui-icon"></i>
|
</div>
|
<div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
|
<i class="layui-icon"></i>
|
</div>
|
</div>
|
</div>
|
</form>
|
<table lay-filter="couponRuleTable" lay-data="{id: 'couponRuleTable'}"></table>
|
<style type="text/css">
|
.layui-table-cell{
|
text-align:center;
|
height: auto;
|
white-space: nowrap; /*文本不会换行,在同一行显示*/
|
overflow: hidden; /*超出隐藏*/
|
text-overflow: ellipsis; /*省略号显示*/
|
}
|
.layui-table img{
|
max-width:100px
|
}
|
::-webkit-scrollbar {
|
height: 20px !important;
|
background-color: #f4f4f4;
|
}
|
</style>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<!-- 表格操作栏 start -->
|
<script type="text/html" id="user-option">
|
<span shiro:lacksPermission="user:view,user:update,user:delete">
|
<span class="layui-badge-dot febs-bg-orange"></span> 无权限
|
</span>
|
<a lay-event="edit" shiro:hasPermission="user:update"><i
|
class="layui-icon febs-edit-area febs-blue"></i></a>
|
</script>
|
<style>
|
.layui-form-onswitch {
|
background-color: #5FB878 !important;
|
}
|
</style>
|
|
<script type="text/html" id="isStateSwitch">
|
{{# if(d.state === 2) { }}
|
<input type="checkbox" value={{d.id}} lay-text="上架|下架" checked lay-skin="switch" lay-filter="isStateSwitch">
|
{{# } else { }}
|
<input type="checkbox" value={{d.id}} lay-text="上架|下架" lay-skin="switch" lay-filter="isStateSwitch">
|
{{# } }}
|
</script>
|
<!-- 表格操作栏 end -->
|
<script data-th-inline="none" type="text/javascript">
|
// 引入组件并初始化
|
layui.use([ 'jquery', 'form', 'table', 'febs'], function () {
|
var $ = layui.jquery,
|
febs = layui.febs,
|
form = layui.form,
|
table = layui.table,
|
$view = $('#febs-coupon-rule'),
|
$query = $view.find('#query'),
|
$reset = $view.find('#reset'),
|
$searchForm = $view.find('form'),
|
$add = $view.find('#add'),
|
sortObject = {field: 'phone', type: null},
|
tableIns;
|
|
form.render();
|
|
// 表格初始化
|
initTable();
|
|
// 初始化表格操作栏各个按钮功能
|
table.on('tool(couponRuleTable)', function (obj) {
|
var data = obj.data,
|
layEvent = obj.event;
|
if (layEvent === 'couponRuleDel') {
|
febs.modal.confirm('删除', '确认删除['+data.name+']优惠卷?', function () {
|
couponRuleDel(data.id);
|
});
|
}
|
if (layEvent === 'couponRuleUpdate') {
|
febs.modal.open('优惠卷编辑', 'modules/goods/goodsCouponUpdate/' + data.id, {
|
btn: ['提交', '取消'],
|
area:['100%','100%'],
|
yes: function (index, layero) {
|
$('#febs-coupon-rule-update').find('#submit').trigger('click');
|
},
|
btn2: function () {
|
layer.closeAll();
|
}
|
});
|
}
|
});
|
function couponRuleDel(id) {
|
febs.get(ctx + 'admin/goods/couponRuleDel/' + id, null, function () {
|
febs.alert.success('操作成功');
|
$query.click();
|
});
|
}
|
|
form.on('switch(isStateSwitch)', function (data) {
|
if (data.elem.checked) {
|
upCoupon(data.value);
|
} else {
|
downCoupon(data.value);
|
}
|
})
|
|
function upCoupon(id) {
|
febs.get(ctx + 'admin/goods/upCoupon/' + id, null, function () {
|
febs.alert.success('操作成功');
|
$query.click();
|
});
|
}
|
function downCoupon(id) {
|
febs.get(ctx + 'admin/goods/downCoupon/' + id, null, function () {
|
febs.alert.success('操作成功');
|
$query.click();
|
});
|
}
|
|
// 查询按钮
|
$query.on('click', function () {
|
var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
|
tableIns.reload({where: params, page: {curr: 1}});
|
});
|
|
// 刷新按钮
|
$reset.on('click', function () {
|
$searchForm[0].reset();
|
sortObject.type = 'null';
|
tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
|
});
|
|
$add.on('click', function () {
|
febs.modal.open('优惠卷新增', 'modules/goods/goodsCouponAdd/', {
|
btn: ['提交', '取消'],
|
area:['100%','100%'],
|
yes: function (index, layero) {
|
$('#febs-coupon-rule-add').find('#submit').trigger('click');
|
},
|
btn2: function () {
|
layer.closeAll();
|
}
|
});
|
});
|
|
function initTable() {
|
tableIns = febs.table.init({
|
elem: $view.find('table'),
|
id: 'couponRuleTable',
|
url: ctx + 'admin/goods/couponRuleList',
|
cols: [[
|
{field: 'name', title: '名称', minWidth: 200,align:'left'},
|
{field: 'isState', title: '是否生效', templet: '#isStateSwitch', minWidth: 100,align:'center'},
|
{field: 'costAmount', title: '满足金额', minWidth: 200,align:'left'},
|
{field: 'realAmount', title: '减免金额', minWidth: 200,align:'left'},
|
{field: 'expireDay', title: '过期天数', minWidth: 200,align:'left'},
|
{field: 'createdTime', title: '创建时间', minWidth: 140,align:'left'},
|
{title: '操作',
|
templet: function (d) {
|
if (d.state === 1) {
|
return ''
|
+ '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="couponRuleUpdate" shiro:hasPermission="user:update">编辑</button>'
|
+ '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-red" lay-event="couponRuleDel" shiro:hasPermission="user:update">删除</button>'
|
|
}else{
|
return '';
|
|
}
|
},minWidth: 160,align:'center'}
|
]]
|
});
|
}
|
|
// 获取查询参数
|
function getQueryParams() {
|
return {
|
};
|
}
|
|
})
|
</script>
|