coupons.js 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'coupons/index' + location.search,
  8. add_url: 'coupons/add',
  9. edit_url: 'coupons/edit',
  10. // del_url: 'coupons/del',
  11. multi_url: 'coupons/multi',
  12. import_url: 'coupons/import',
  13. table: 'coupons',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. // {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  29. {field: 'enough', title: __('Enough'), operate:'BETWEEN'},
  30. {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
  31. {field: 'score', title: __('Score')},
  32. {field: 'number', title: __('Number')},
  33. {field: 'stock', title: __('Stock')},
  34. {field: 'limit', title: __('Limit')},
  35. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'usetimestart', title: __('Usetimestart'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'usetimeend', title: __('Usetimeend'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. // {field: 'gettimestart', title: __('Gettimestart')},
  40. // {field: 'gettimeend', title: __('Gettimeend')},
  41. {field: 'company_id', title: __('Company_id')},
  42. {field: 'company.name', title: __('Company.name'), operate: 'LIKE'},
  43. {field: 'operate', title: __('Operate'),
  44. buttons:[
  45. {
  46. name:'edit',
  47. text:'',
  48. title:'编辑',
  49. icon:'fa fa-pencil',
  50. classname:'btn btn-xs btn-success btn-editone',
  51. url:'coupons/edit/id/{ids}?dialog=1',
  52. target:'_self',
  53. hidden:function(row){
  54. return row.type==1 ? true : false;
  55. }
  56. }
  57. ],
  58. table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  59. ]
  60. ]
  61. });
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. },
  68. edit: function () {
  69. Controller.api.bindevent();
  70. },
  71. api: {
  72. bindevent: function () {
  73. Form.api.bindevent($("form[role=form]"));
  74. }
  75. }
  76. };
  77. return Controller;
  78. });