users.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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: 'users/users/index' + location.search,
  8. add_url: 'users/users/add',
  9. edit_url: 'users/users/edit',
  10. del_url: 'users/users/del',
  11. multi_url: 'users/users/multi',
  12. table: 'users',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'user_id',
  20. sortName: 'user_id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'user_id', title: __('User_id')},
  25. {field: 'user_nickname', title: __('User_nickname')},
  26. {field: 'user_tel', title: __('User_tel')},
  27. {
  28. field: 'user_avatar',
  29. title: __('User_avatar'),
  30. events: Table.api.events.image,
  31. formatter: Table.api.formatter.image
  32. },
  33. {
  34. field: 'user_level',
  35. title: __('等级'),
  36. operate: false,
  37. formatter: Table.api.formatter.status,
  38. searchList: {1: '普通用户', 2: '店长会员', 3: '经理会员', 4: '总监会员 ', 5: '董事会员', 6: 'vip会员'}
  39. },
  40. {field: 'user_money', title: __('User_money'), operate: 'BETWEEN'},
  41. {field: 'user_redbean', title: __('User_redbean'), operate: 'BETWEEN'},
  42. {field: 'user_whitebean', title: __('User_whitebean'), operate: 'BETWEEN'},
  43. {
  44. field: 'create_time',
  45. title: __('Create_time'),
  46. operate: 'RANGE',
  47. addclass: 'create_time',
  48. formatter: Table.api.formatter.datetime
  49. },
  50. {
  51. field: 'update_time',
  52. title: __('Update_time'),
  53. operate: 'RANGE',
  54. addclass: 'update_time',
  55. formatter: Table.api.formatter.datetime
  56. },
  57. {
  58. field: 'status_switch',
  59. title: __('状态'),
  60. searchList: {1: __('启用'), 0: __('禁用')},
  61. formatter: Table.api.formatter.toggle
  62. },
  63. {
  64. field: 'operate',
  65. title: __('Operate'),
  66. table: table,
  67. events: Table.api.events.operate,
  68. formatter: Table.api.formatter.operate
  69. }
  70. ]
  71. ]
  72. });
  73. // 为表格绑定事件
  74. Table.api.bindevent(table);
  75. },
  76. add: function () {
  77. Controller.api.bindevent();
  78. },
  79. edit: function () {
  80. Controller.api.bindevent();
  81. },
  82. api: {
  83. bindevent: function () {
  84. Form.api.bindevent($("form[role=form]"));
  85. }
  86. }
  87. };
  88. return Controller;
  89. });