- 新增服务品类和服务类型筛选选项 - 新增订单距离筛选功能 - 新增admin-table-layout组件实现表格操作列固定 - 重构后台表格列布局,优化显示效果 - 新增位置相关工具函数及测试用例 - 升级版本号至1.0.89
90 行
5.6 KiB
JavaScript
90 行
5.6 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'user_coupon/index' + location.search,
|
|
del_url: 'user_coupon/del',
|
|
multi_url: 'user_coupon/multi',
|
|
table: 'user_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: 'id', title: '记录ID', width: '75px'},
|
|
{field: 'user.nickname', title: '领用会员', operate: 'LIKE', align: 'left', formatter: function (v, row) {
|
|
var name = (row.user && (row.user.nickname || row.user.username)) ? (row.user.nickname || row.user.username) : ('用户#' + row.user_id);
|
|
var mob = (row.user && row.user.mobile) ? ' <small class="text-muted">(' + Fast.api.escape(row.user.mobile) + ')</small>' : '';
|
|
return '<strong>' + Fast.api.escape(name) + '</strong>' + mob;
|
|
}},
|
|
{field: 'user.mobile', title: '会员手机', visible: false, operate: 'LIKE'},
|
|
{field: 'coupon.name', title: '优惠券名称', operate: 'LIKE', align: 'left', formatter: function (v, row) {
|
|
var cname = (row.coupon && row.coupon.name) ? row.coupon.name : ('卡券#' + row.coupon_id);
|
|
return '<span style="font-weight:600;color:#1e293b;">' + Fast.api.escape(cname) + '</span>';
|
|
}},
|
|
{field: 'coupon.type', title: '券类型', operate: false, formatter: function (v, row) {
|
|
var tp = row.coupon ? row.coupon.type : '';
|
|
if (tp === 'discount') {
|
|
return '<span class="label label-info">折扣券</span>';
|
|
}
|
|
return '<span class="label label-warning">满减现金券</span>';
|
|
}},
|
|
{field: 'coupon_rule', title: '抵扣面额与门槛', operate: false, align: 'left', formatter: function (v, row) {
|
|
if (!row.coupon || !row.coupon.id) {
|
|
return '<span class="text-muted">-</span>';
|
|
}
|
|
var c = row.coupon;
|
|
var minTxt = parseFloat(c.min_amount) > 0 ? ('满 ¥' + parseFloat(c.min_amount).toFixed(2) + ' 可用') : '无门槛';
|
|
if (c.type === 'discount') {
|
|
var disc = (parseFloat(c.discount || 1) * 10).toFixed(1).replace(/\.0$/, '');
|
|
return '<strong style="color:#ea580c;">' + disc + ' 折</strong> <small class="text-muted">(' + minTxt + ')</small>';
|
|
}
|
|
return '<strong style="color:#ea580c;">减 ¥' + parseFloat(c.amount || 0).toFixed(2) + '</strong> <small class="text-muted">(' + minTxt + ')</small>';
|
|
}},
|
|
{field: 'status', title: '使用状态', searchList: {"unused":"未使用","used":"已核销","expired":"已过期"}, formatter: Table.api.formatter.label, custom: {unused: 'primary', used: 'success', expired: 'default'}},
|
|
{field: 'order.order_no', title: '核销关联订单', operate: 'LIKE', formatter: function (v, row) {
|
|
var no = (row.order && row.order.order_no) ? row.order.order_no : '';
|
|
if (no) {
|
|
return '<code>' + Fast.api.escape(no) + '</code>';
|
|
}
|
|
return row.order_id > 0 ? ('#' + row.order_id) : '<span class="text-muted">-</span>';
|
|
}},
|
|
{field: 'createtime', title: '领取时间', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, width: '155px'},
|
|
{field: 'use_time', title: '核销时间', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, width: '155px'},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
|
var that = $.extend({}, this);
|
|
if (row.status === 'used') {
|
|
var tbl = $(that.table).clone(true);
|
|
$(tbl).data('operate-del', null);
|
|
that.table = tbl;
|
|
}
|
|
return Table.api.formatter.operate.call(that, value, row, index);
|
|
}}
|
|
]
|
|
]
|
|
});
|
|
|
|
Table.api.bindevent(table);
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|