allocatr/public/assets/js/backend/coupons.js
2025-03-08 15:39:17 +08:00

63 lines
2.7 KiB
JavaScript

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'coupons/index' + location.search,
add_url: 'coupons/add',
edit_url: 'coupons/edit',
del_url: 'coupons/del',
multi_url: 'coupons/multi',
import_url: 'coupons/import',
table: 'coupons',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'code', title: __('Code'), operate: 'LIKE'},
{field: 'description', title: __('Description'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'discount_type', title: __('Discount_type'), searchList: {"fixed":__('Fixed'),"percentage":__('Percentage')}, formatter: Table.api.formatter.normal},
{field: 'min_order', title: __('Min_order'), operate:'BETWEEN'},
{field: 'max_discount', title: __('Max_discount'), operate:'BETWEEN'},
{field: 'status', title: __('Status'), searchList: {"active":__('Active'),"inactive":__('Inactive')}, formatter: Table.api.formatter.status},
{field: 'threshold', title: __('Threshold'), operate:'BETWEEN'},
{field: 'discount_value', title: __('Discount_value'), operate:'BETWEEN'},
{field: 'created_at', title: __('Created_at')},
{field: 'updated_at', title: __('Updated_at')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});