store.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: 'store/index' + location.search,
  8. add_url: 'store/add',
  9. edit_url: 'store/edit',
  10. del_url: 'store/del',
  11. multi_url: 'store/multi',
  12. import_url: 'store/import',
  13. table: 'store',
  14. dragsort_url: false,
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'weigh',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. search: false,
  26. columns: [
  27. [
  28. {checkbox: true},
  29. {field: 'id', title: __('Id')},
  30. // {field: 'category_id', title: __('Category_id')},
  31. {field: 'category.name', title: __('Category.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  33. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  35. {field: 'info', title: __('Info'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  37. {field: 'weigh', title: __('Weigh'), operate: false},
  38. {field: 'longitude', title: __('Longitude'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  39. {field: 'latitude', title: __('Latitude'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  40. {field: 'shijian', title: __('Shijian'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  41. {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  42. {field: 'mobile', title: __('Mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  43. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  44. ]
  45. ]
  46. });
  47. // 为表格绑定事件
  48. Table.api.bindevent(table);
  49. },
  50. add: function () {
  51. Controller.api.bindevent();
  52. },
  53. edit: function () {
  54. Controller.api.bindevent();
  55. },
  56. api: {
  57. bindevent: function () {
  58. Form.api.bindevent($("form[role=form]"));
  59. }
  60. }
  61. };
  62. return Controller;
  63. });