You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
2.6 KiB

  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: 'unishop/ads/index' + location.search,
  8. add_url: 'unishop/ads/add',
  9. edit_url: 'unishop/ads/edit',
  10. del_url: 'unishop/ads/del',
  11. multi_url: 'unishop/ads/multi',
  12. table: 'unishop_ads',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'weigh',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
  26. {field: 'product_id', title: __('product_id'),visible:false},
  27. {field: 'product.title', title: __('Product title')},
  28. {field: 'background', title: __('Background'),formatter:function (value, row, index) {
  29. return '<p style="background:'+value+'">'+value+'</p>';
  30. }},
  31. {field: 'position', title: __('Position'),visible:false},
  32. {field: 'status', title: __('Status'),formatter: Table.api.formatter.toggle},
  33. {field: 'weigh', title: __('Weigh')},
  34. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  35. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. },
  43. add: function () {
  44. Controller.api.bindevent();
  45. },
  46. edit: function () {
  47. Controller.api.bindevent();
  48. },
  49. api: {
  50. bindevent: function () {
  51. Form.api.bindevent($("form[role=form]"));
  52. }
  53. }
  54. };
  55. return Controller;
  56. });