relationmodel.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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: 'example/relationmodel/index',
  8. add_url: '',
  9. edit_url: '',
  10. del_url: 'example/relationmodel/del',
  11. multi_url: '',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. columns: [
  19. [
  20. {field: 'state', checkbox: true, },
  21. {field: 'id', title: 'ID', operate: '='},
  22. {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'},
  23. {field: 'admin.avatar', title: __('Avatar'), operate: false, formatter: Table.api.formatter.image},
  24. {field: 'admin.username', title: __('Username'), operate: 'FIND_IN_SET'},
  25. {field: 'admin.nickname', title: __('Nickname'), operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'},
  26. {field: 'ip', title: __('IP'), operate: '='},
  27. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  28. {field: 'admin.createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  29. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  30. ]
  31. ],
  32. });
  33. // 为表格绑定事件
  34. Table.api.bindevent(table);
  35. },
  36. add: function () {
  37. Form.api.bindevent($("form[role=form]"));
  38. },
  39. edit: function () {
  40. Form.api.bindevent($("form[role=form]"));
  41. },
  42. };
  43. return Controller;
  44. });