| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- let itemid = $("#item-id").val();
- if (itemid > 0) {
- Table.api.init({
- extend: {
- index_url: 'pickup/cardcode/index/ids/' + itemid + location.search,
- add_url: 'pickup/cardcode/add/gpid/' + itemid,
- edit_url: 'pickup/cardcode/edit/gpid/' + itemid,
- batchcreate_url: 'pickup/cardcode/batchcreate/gpid/' + itemid,
- batchexport_url: 'pickup/cardcode/batchexport/gpid/' + itemid,
- del_url: 'pickup/cardcode/del/',
- multi_url: 'pickup/cardcode/multi',
- table: 'gift_cardcode',
- },
- pageSize: 30,
- pageList: [30, 50, 100, 'All'],
- });
- } else {
- Table.api.init({
- extend: {
- index_url: 'pickup/cardcode/index' + location.search,
- add_url: 'pickup/cardcode/add',
- edit_url: 'pickup/cardcode/edit',
- batchcreate_url: 'pickup/cardcode/batchcreate',
- batchexport_url: 'pickup/cardcode/batchexport',
- del_url: 'pickup/cardcode/del',
- multi_url: 'pickup/cardcode/multi',
- table: 'gift_cardcode',
- },
- pageSize: 30,
- pageList: [30, 50, 100, 'All'],
- });
- }
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- // {field: 'gp_id', title: __('Gp_id')},
- {field: 'card_id', title: __('Card_id')},
- {field: 'card_pwd', title: __('Card_pwd')},
- {field: 'card_status', title: __('Card_status'), searchList: {"1": __('Card_status 1'), "2": __('Card_status 2'), "3": __('Card_status 3'), "4": __('Card_status 4')}, formatter: Table.api.formatter.status},
- {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
- {field: 'usedtime', title: __('Usedtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 添加按钮事件
- $(".toolbar").on('click', ".btn-batchcreate", function () {
- var ids = Table.api.selectedids(table);
- var url = $.fn.bootstrapTable.defaults.extend.batchcreate_url;
- Fast.api.open(url, __('卡密批量生成'), $(this).data() || {});
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- batchcreate: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|