freight.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: 'shop/freight/index' + location.search,
  8. add_url: 'shop/freight/add',
  9. edit_url: 'shop/freight/edit',
  10. del_url: 'shop/freight/del',
  11. multi_url: 'shop/freight/multi',
  12. import_url: 'shop/freight/import',
  13. table: 'shop_freight',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'name', title: __('Name'), operate: 'LIKE'},
  27. {field: 'type', title: __('Type'), searchList: {"1": __('Type 1'), "2": __('Type 2')}, formatter: Table.api.formatter.normal},
  28. {field: 'num', title: __('Num'), operate: 'BETWEEN'},
  29. {field: 'price', title: __('Price'), operate: 'BETWEEN'},
  30. {field: 'continue_num', title: __('Continue_num'), operate: 'BETWEEN'},
  31. {field: 'continue_price', title: __('Continue_price'), operate: 'BETWEEN'},
  32. {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
  33. {field: 'updatetime', title: __('Updatetime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
  34. {field: 'weigh', title: __('Weigh'), operate: false},
  35. {field: 'switch', title: __('Switch'), searchList: {"1": __('Yes'), "0": __('No')}, table: table, formatter: Table.api.formatter.toggle},
  36. {
  37. field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  38. buttons: [{
  39. name: '运费条件',
  40. title: __('运费条件'),
  41. classname: 'btn btn-xs btn-primary btn-dialog',
  42. text: '运费条件',
  43. icon: 'fa fa-sticky-note-o',
  44. extend: 'data-area=\'["90%","90%"]\'',
  45. url: 'shop/freight_items/index/freight_id/{id}'
  46. }]
  47. }
  48. ]
  49. ]
  50. });
  51. // 为表格绑定事件
  52. Table.api.bindevent(table);
  53. },
  54. add: function () {
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. Controller.api.bindevent();
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. }
  64. }
  65. };
  66. return Controller;
  67. });