12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
- {field: 'enough', title: __('Enough'), operate:'BETWEEN'},
- {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
- {field: 'score', title: __('Score')},
- {field: 'number', title: __('Number')},
- {field: 'stock', title: __('Stock')},
- {field: 'limit', title: __('Limit')},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'usetimestart', title: __('Usetimestart'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {field: 'usetimeend', title: __('Usetimeend'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- // {field: 'gettimestart', title: __('Gettimestart')},
- // {field: 'gettimeend', title: __('Gettimeend')},
- {field: 'company_id', title: __('Company_id')},
- {field: 'company.name', title: __('Company.name'), operate: 'LIKE'},
- {field: 'operate', title: __('Operate'),
- buttons:[
- {
- name:'edit',
- text:'',
- title:'编辑',
- icon:'fa fa-pencil',
- classname:'btn btn-xs btn-success btn-editone',
- url:'coupons/edit/id/{ids}?dialog=1',
- target:'_self',
- hidden:function(row){
- return row.type==1 ? true : false;
- }
- }
- ],
- 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;
- });
|