admin.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: 'agent/admin/index',
  8. // add_url: 'agent/admin/add',
  9. // edit_url: 'agent/admin/edit',
  10. // del_url: 'agent/admin/del',
  11. // multi_url: 'agent/admin/multi',
  12. }
  13. });
  14. var table = $("#table");
  15. //在表格内容渲染完成后回调的事件
  16. table.on('post-body.bs.table', function (e, json) {
  17. $("tbody tr[data-index]", this).each(function () {
  18. if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
  19. $("input[type=checkbox]", this).prop("disabled", true);
  20. }
  21. });
  22. });
  23. // 初始化表格
  24. table.bootstrapTable({
  25. url: $.fn.bootstrapTable.defaults.extend.index_url,
  26. searchFormVisible: true,
  27. searchFormTemplate: 'customformtpl',
  28. columns: [
  29. [
  30. // {field: 'state', checkbox: true, },
  31. {field: 'id', title: '平台ID'},
  32. {field: 'username', title: __('Username')},
  33. {field: 'nickname', title: __('Nickname')},
  34. // {field: 'user_id', title: __('用户ID')},
  35. // {field: 'sharing_ratio', title: __('用户分成比率%')},
  36. // {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
  37. // {field: 'email', title: __('Email')},
  38. {field: 'week_sum_money', title: __('本周流水')},
  39. {field: 'extend_name', title: __('推广等级')},
  40. {field: 'extra_reward', title: __('额外分成%')},
  41. {field: 'extra_moeny', title: __('分成金额')},
  42. {field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
  43. // {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  44. {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'/*, sortable: true*/},
  45. /*{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
  46. if(row.id == Config.admin.id){
  47. return '';
  48. }
  49. return Table.api.formatter.operate.call(this, value, row, index);
  50. }}*/
  51. ]
  52. ]
  53. });
  54. // 为表格绑定事件
  55. Table.api.bindevent(table);
  56. },
  57. add: function () {
  58. Form.api.bindevent($("form[role=form]"));
  59. },
  60. edit: function () {
  61. Form.api.bindevent($("form[role=form]"));
  62. }
  63. };
  64. return Controller;
  65. });