- 新增服务品类和服务类型筛选选项 - 新增订单距离筛选功能 - 新增admin-table-layout组件实现表格操作列固定 - 重构后台表格列布局,优化显示效果 - 新增位置相关工具函数及测试用例 - 升级版本号至1.0.89
103 行
4.8 KiB
JavaScript
103 行
4.8 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
|
|
|
|
function syncCouponTypeInputs() {
|
|
var $type = $('#c-type');
|
|
if (!$type.length) return;
|
|
var apply = function () {
|
|
var val = $type.val();
|
|
if (val === 'discount') {
|
|
$('#box-coupon-amount').hide();
|
|
$('#box-coupon-discount').show();
|
|
} else {
|
|
$('#box-coupon-amount').show();
|
|
$('#box-coupon-discount').hide();
|
|
}
|
|
};
|
|
$type.on('change changed.bs.select', apply);
|
|
apply();
|
|
}
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'coupon/index' + location.search,
|
|
detail_url: 'coupon/detail',
|
|
add_url: 'coupon/add',
|
|
edit_url: 'coupon/edit',
|
|
del_url: 'coupon/del',
|
|
multi_url: 'coupon/multi',
|
|
table: 'coupon',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
sortOrder: 'desc',
|
|
fixedColumns: false,
|
|
fixedRightNumber: 0,
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '60px'},
|
|
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
|
{field: 'type', title: __('Type'), searchList: {"cash":__('Cash'),"discount":__('Discount')}, formatter: Table.api.formatter.label, custom: {cash: 'danger', discount: 'warning'}},
|
|
{field: 'amount', title: '优惠力度', operate: false, formatter: function (v, row) {
|
|
if (row.type === 'discount') {
|
|
var d = (Number(row.discount || 1) * 10).toFixed(1).replace(/\.0$/, '');
|
|
return '<strong class="text-warning">' + d + ' 折</strong>';
|
|
}
|
|
return '<strong class="text-danger">¥' + Number(v || 0).toFixed(2) + '</strong>';
|
|
}},
|
|
{field: 'min_amount', title: '使用门槛', operate: 'BETWEEN', formatter: function (v) {
|
|
return Number(v) > 0 ? ('满 ¥' + Number(v).toFixed(2)) : '<span class="text-success">无门槛</span>';
|
|
}},
|
|
{field: 'real_claimed', title: '已领取', operate: false},
|
|
{field: 'total', title: '发行总量', operate: false},
|
|
{field: 'used_count', title: '已核销', operate: false, formatter: function (v) {
|
|
return Number(v) > 0 ? '<span class="label label-success">' + v + ' 张</span>' : '<span class="text-muted">0 张</span>';
|
|
}},
|
|
{field: 'start_time', title: '开始时间', operate: false, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD'},
|
|
{field: 'end_time', title: '结束时间', operate: false, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD'},
|
|
{field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
|
|
buttons: [
|
|
{
|
|
name: 'detail',
|
|
text: '领用数据',
|
|
title: '卡券领取与核销详情',
|
|
classname: 'btn btn-xs btn-info btn-detailone',
|
|
extend: 'data-area=\'["880px","84%"]\''
|
|
}
|
|
],
|
|
formatter: Table.api.formatter.operate}
|
|
]
|
|
]
|
|
});
|
|
|
|
Table.api.bindevent(table);
|
|
},
|
|
detail: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
add: function () {
|
|
syncCouponTypeInputs();
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
syncCouponTypeInputs();
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|