products.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: 'product/products/index' + location.search,
  8. add_url: 'product/products/add',
  9. edit_url: 'product/products/edit',
  10. multi_url: 'product/products/multi',
  11. import_url: 'product/products/import',
  12. table: 'products',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'zh_title', title: __('Zh_title'), operate: 'LIKE'},
  26. {field: 'en_title', title: __('En_title'), operate:'BETWEEN'},
  27. {field: 'sort', title: __('Sort')},
  28. {field: 'status', title: __('Status'), searchList: {"1":__('上架'),"0":__('下架')}, formatter: Table.api.formatter.toggle},
  29. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  30. ]
  31. ]
  32. });
  33. // 为表格绑定事件
  34. Table.api.bindevent(table);
  35. },
  36. add: function () {
  37. Controller.api.bindevent();
  38. },
  39. edit: function () {
  40. Controller.api.bindevent();
  41. },
  42. api: {
  43. bindevent: function () {
  44. Form.api.bindevent($("form[role=form]"));
  45. },
  46. }
  47. };
  48. return Controller;
  49. });