box.js 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: 'box/box/index' + location.search,
  8. add_url: 'box/box/add',
  9. edit_url: 'box/box/edit',
  10. del_url: 'box/box/del',
  11. multi_url: 'box/box/multi',
  12. import_url: 'box/box/import',
  13. status_url: 'box/box/status',
  14. table: 'box',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'box.id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'category.name', title: __('Category_name'), operate: 'LIKE', visible: false},
  27. {field: 'category_name', title: __('Category_name'), operate: false},
  28. {field: 'box_name', title: __('Box_name'), operate: 'LIKE'},
  29. {field: 'box_banner_images', title: __('Box_banner_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  30. {field: 'coin_price', title: __('Coin_price')},
  31. {field: 'box_foot_images', title: __('Box_foot_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  32. {field: 'box.is_hot', title: __('Is_hot'), searchList: {"1":__('Is_hot 1'),"0":__("Is_hot 0")}, visible: false},
  33. {field: 'is_hot', title: __('Is_hot'), searchList: {"1":__('Is_hot 1'),"0":""}, custom: {1:"warning"}, formatter: Table.api.formatter.flag, operate: false},
  34. {field: 'box.is_cheap', title: __('Is_cheap'), searchList: {"1":__('Is_cheap 1'),"0":__("Is_cheap 0")}, visible: false},
  35. {field: 'is_cheap', title: __('Is_cheap'), searchList: {"1":__('Is_cheap 1'),"0":""}, custom: {1:"warning"}, formatter: Table.api.formatter.flag, operate: false},
  36. {field: 'box.is_try', title: __('Is_try'), searchList: {"1":__('Is_try 1'),"0":__('Is_try 0')}, formatter: Table.api.formatter.flag, visible: false},
  37. {field: 'switch', title: __('开关'), searchList: {"1":__('显示'),"0":__('隐藏')}, formatter: Table.api.formatter.toggle},
  38. {field: 'is_try', title: __('Is_try'), searchList: {"1":__('Is_try 1'),"0":""}, custom: {1:"success"}, formatter: Table.api.formatter.flag, operate: false},
  39. {
  40. field: 'buttons',
  41. title: __('查看商品'),
  42. table: table,
  43. events: Table.api.events.operate,
  44. buttons: [
  45. {
  46. name: 'show',
  47. text: __('查看商品'),
  48. classname: 'btn btn-xs btn-info btn-addtabs',
  49. icon: 'fa fa-list',
  50. url: 'box/detail?boxid={id}',
  51. }
  52. ],
  53. formatter: Table.api.formatter.buttons
  54. },
  55. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  56. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  57. ]
  58. ],
  59. searchFormVisible: true,
  60. search:false,
  61. showToggle: false,
  62. showColumns: false
  63. });
  64. // 为表格绑定事件
  65. Table.api.bindevent(table);
  66. },
  67. add: function () {
  68. Controller.api.bindevent();
  69. },
  70. edit: function () {
  71. Controller.api.bindevent();
  72. },
  73. api: {
  74. bindevent: function () {
  75. Form.api.bindevent($("form[role=form]"));
  76. }
  77. }
  78. };
  79. return Controller;
  80. });