third.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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: 'third/index' + location.search,
  8. add_url: 'third/add',
  9. edit_url: 'third/edit',
  10. del_url: 'third/del',
  11. multi_url: 'third/multi',
  12. table: 'third',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. fixedColumns: true,
  22. fixedRightNumber: 1,
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. {field: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search},
  28. {field: 'user.nickname', title: __('Nickname')},
  29. {field: 'platform', title: __('Platform'), formatter: Table.api.formatter.flag, searchList: {'wechat': '微信', 'qq': 'QQ', 'weibo': '微博'}, custom: {'wechat': 'success', 'qq': 'info', 'weibo': 'danger'}},
  30. {field: 'apptype', title: __('Apptype'), formatter: Table.api.formatter.normal, searchList: {'mp': '公众号', 'wxapp': '小程序', 'web': 'PC端'}},
  31. {field: 'openid', title: __('Openid')},
  32. {field: 'unionid', title: __('Unionid')},
  33. {field: 'openname', title: __('Openname'), formatter: Table.api.formatter.search},
  34. {field: 'createtime', title: __('Createtime'), sortable: true, operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  35. {field: 'updatetime', title: __('Updatetime'), visible: false, sortable: true, operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  36. {field: 'logintime', title: __('Logintime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  37. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  38. ]
  39. ]
  40. });
  41. // 为表格绑定事件
  42. Table.api.bindevent(table);
  43. },
  44. add: function () {
  45. Controller.api.bindevent();
  46. },
  47. edit: function () {
  48. Controller.api.bindevent();
  49. },
  50. api: {
  51. bindevent: function () {
  52. Form.api.bindevent($("form[role=form]"));
  53. }
  54. }
  55. };
  56. return Controller;
  57. });