goods.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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: 'goods/index' + location.search,
  8. add_url: 'goods/add',
  9. edit_url: 'goods/edit',
  10. del_url: 'goods/del',
  11. multi_url: 'goods/multi',
  12. import_url: 'goods/import',
  13. table: 'goods',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'category_id', title: __('Category_id')},
  29. {field: 'category_name', title: __('Category_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  30. {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  31. {field: 'little_image', title: __('Little_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  32. {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  33. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  34. {field: 'describe', title: __('Describe'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  35. {field: 'dynamic', title: __('Dynamic'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. // {field: 'dynamic_ids', title: __('Dynamic_ids'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  37. {field: 'weigh', title: __('Weigh'), operate: false},
  38. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. // {field: 'category.id', title: __('Category.id')},
  41. // {field: 'category.title', title: __('Category.title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  42. // {field: 'category.pid', title: __('Category.pid')},
  43. // {field: 'category.image', title: __('Category.image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  44. // {field: 'category.weigh', title: __('Category.weigh')},
  45. // {field: 'category.createtime', title: __('Category.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46. // {field: 'category.updatetime', title: __('Category.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  47. // {field: 'category.status_switch', title: __('Category.status_switch'), table: table, formatter: Table.api.formatter.toggle},
  48. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  49. ]
  50. ]
  51. });
  52. // 为表格绑定事件
  53. Table.api.bindevent(table);
  54. },
  55. recyclebin: function () {
  56. // 初始化表格参数配置
  57. Table.api.init({
  58. extend: {
  59. 'dragsort_url': ''
  60. }
  61. });
  62. var table = $("#table");
  63. // 初始化表格
  64. table.bootstrapTable({
  65. url: 'goods/recyclebin' + location.search,
  66. pk: 'id',
  67. sortName: 'id',
  68. columns: [
  69. [
  70. {checkbox: true},
  71. {field: 'id', title: __('Id')},
  72. {field: 'title', title: __('Title'), align: 'left'},
  73. {
  74. field: 'deletetime',
  75. title: __('Deletetime'),
  76. operate: 'RANGE',
  77. addclass: 'datetimerange',
  78. formatter: Table.api.formatter.datetime
  79. },
  80. {
  81. field: 'operate',
  82. width: '140px',
  83. title: __('Operate'),
  84. table: table,
  85. events: Table.api.events.operate,
  86. buttons: [
  87. {
  88. name: 'Restore',
  89. text: __('Restore'),
  90. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  91. icon: 'fa fa-rotate-left',
  92. url: 'goods/restore',
  93. refresh: true
  94. },
  95. {
  96. name: 'Destroy',
  97. text: __('Destroy'),
  98. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  99. icon: 'fa fa-times',
  100. url: 'goods/destroy',
  101. refresh: true
  102. }
  103. ],
  104. formatter: Table.api.formatter.operate
  105. }
  106. ]
  107. ]
  108. });
  109. // 为表格绑定事件
  110. Table.api.bindevent(table);
  111. },
  112. add: function () {
  113. Controller.api.bindevent();
  114. },
  115. edit: function () {
  116. Controller.api.bindevent();
  117. },
  118. api: {
  119. bindevent: function () {
  120. Form.api.bindevent($("form[role=form]"));
  121. }
  122. }
  123. };
  124. return Controller;
  125. });