ad.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: 'ad/index' + location.search,
  8. add_url: 'ad/add',
  9. edit_url: 'ad/edit',
  10. del_url: 'ad/del',
  11. multi_url: 'ad/multi',
  12. import_url: 'ad/import',
  13. table: 'ad',
  14. }
  15. });
  16. var table = $("#table");
  17. let pos=$('#table').data('pos')
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. //{checkbox: true},
  26. {field: 'id', title: __('Id'), operate: false},
  27. {field: 'pos', title: __('Pos'), operate: false,searchList:$.getJSON('ad/pos'),formatter: function (a, b, c) {
  28. return pos[a]
  29. }},
  30. {field: 'img', title: __('Img'), operate: false,formatter: Table.api.formatter.image,events: Table.api.events.image},
  31. /*{field: 'link_type', title: __('Link_type'), operate: false},
  32. {field: 'link_id', title: __('Link_id'), operate: false},*/
  33. {field: 'sort', title: __('Sort'), operate: false},
  34. {field: 'admin.nickname', title: __('通道'), operate: 'like'},
  35. {field: 'upload_admin.nickname', title: __('上传用户'), operate: 'like'},
  36. //{field: 'link', title: __('链接'), operate: false,formatter:Table.api.formatter.url},
  37. {field: 'created_at', title: __('Created_at'), operate: false,formatter: Table.api.formatter.datetime},
  38. {field: 'updated_at', title: __('Updated_at'), operate: false,formatter: Table.api.formatter.datetime},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. },
  46. add: function () {
  47. Controller.api.bindevent();
  48. },
  49. edit: function () {
  50. Controller.api.bindevent();
  51. },
  52. api: {
  53. bindevent: function () {
  54. Form.api.bindevent($("form[role=form]"));
  55. }
  56. }
  57. };
  58. return Controller;
  59. });