dynamic.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: 'dynamic/dynamic/index' + location.search,
  8. // add_url: 'dynamic/dynamic/add',
  9. edit_url: 'dynamic/dynamic/edit',
  10. del_url: 'dynamic/dynamic/del',
  11. multi_url: 'dynamic/dynamic/multi',
  12. import_url: 'dynamic/dynamic/import',
  13. table: 'dynamic',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {
  29. field: 'type',
  30. title: __('Type'),
  31. searchList: {"image": __('Image'), "video": __('Video')},
  32. formatter: Table.api.formatter.normal
  33. },
  34. {field: 'description', title: __('Description'), operate: 'LIKE'},
  35. {
  36. field: 'attachment_file',
  37. title: __('Attachment_file'),
  38. operate: false,
  39. formatter: Table.api.formatter.file
  40. },
  41. {field: 'address', title: __('Address'), operate: 'LIKE'},
  42. {
  43. field: 'status',
  44. title: __('Status'),
  45. searchList: {"checking": __('Checking'), "normal": __('Normal'), "reject": __('Reject')},
  46. formatter: Table.api.formatter.status
  47. },
  48. {
  49. field: 'createtime',
  50. title: __('Createtime'),
  51. operate: 'RANGE',
  52. addclass: 'datetimerange',
  53. autocomplete: false,
  54. formatter: Table.api.formatter.datetime
  55. },
  56. {field: 'massager.name', title: __('Massager.name'), operate: 'LIKE'},
  57. {field: 'topic.description', title: __('Topic.description'), operate: 'LIKE'},
  58. {
  59. field: 'operate',
  60. title: __('Operate'),
  61. table: table,
  62. events: Table.api.events.operate,
  63. formatter: Table.api.formatter.operate
  64. }
  65. ]
  66. ]
  67. });
  68. // 为表格绑定事件
  69. Table.api.bindevent(table);
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. },
  74. api: {
  75. bindevent: function () {
  76. Form.api.bindevent($("form[role=form]"));
  77. }
  78. }
  79. };
  80. return Controller;
  81. });