attribute.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/attribute/index' + location.search,
  8. add_url: 'shop/attribute/add/category_id/' + Config.category_id,
  9. edit_url: 'shop/attribute/edit',
  10. del_url: 'shop/attribute/del',
  11. multi_url: 'shop/attribute/multi',
  12. import_url: 'shop/attribute/import',
  13. table: 'shop_attribute',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [{
  24. checkbox: true
  25. },
  26. {
  27. field: 'id',
  28. title: __('Id')
  29. },
  30. {
  31. field: 'category_id',
  32. title: __('Category_id'),
  33. visible: false
  34. },
  35. {
  36. field: 'name',
  37. title: __('Name'),
  38. operate: 'LIKE'
  39. },
  40. {
  41. field: 'type',
  42. title: __('Type'),
  43. searchList: {
  44. "radio": __('Type radio'),
  45. "checkbox": __('Type checkbox')
  46. },
  47. formatter: Table.api.formatter.normal
  48. },
  49. {
  50. field: 'is_must',
  51. title: __('Is_must'),
  52. searchList: {
  53. "1": __('Yes'),
  54. "0": __('No')
  55. },
  56. table: table,
  57. formatter: Table.api.formatter.toggle
  58. },
  59. {
  60. field: 'is_search',
  61. title: __('Is_search'),
  62. searchList: {
  63. "1": __('Yes'),
  64. "0": __('No')
  65. },
  66. table: table,
  67. formatter: Table.api.formatter.toggle
  68. },
  69. {
  70. field: 'createtime',
  71. title: __('Createtime'),
  72. operate: 'RANGE',
  73. addclass: 'datetimerange',
  74. autocomplete: false,
  75. formatter: Table.api.formatter.datetime
  76. },
  77. {
  78. field: 'updatetime',
  79. title: __('Updatetime'),
  80. operate: 'RANGE',
  81. addclass: 'datetimerange',
  82. autocomplete: false,
  83. formatter: Table.api.formatter.datetime
  84. },
  85. {
  86. field: 'operate',
  87. title: __('Operate'),
  88. table: table,
  89. events: Table.api.events.operate,
  90. formatter: Table.api.formatter.operate,
  91. buttons: [{
  92. name: 'goods_attribute',
  93. title: __('属性值'),
  94. classname: 'btn btn-xs btn-primary btn-dialog',
  95. text: '属性值',
  96. extend: 'data-area=\'["90%","90%"]\'',
  97. url: 'shop/attribute_value/index/attribute_id/{id}',
  98. icon: 'fa fa-plus'
  99. }]
  100. }
  101. ]
  102. ]
  103. });
  104. // 为表格绑定事件
  105. Table.api.bindevent(table);
  106. },
  107. add: function () {
  108. Controller.api.bindevent();
  109. },
  110. edit: function () {
  111. Controller.api.bindevent();
  112. },
  113. api: {
  114. bindevent: function () {
  115. Form.api.bindevent($("form[role=form]"));
  116. }
  117. }
  118. };
  119. return Controller;
  120. });