user.js 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. define(['jquery', 'table', 'form'], function($, Table, Form) {
  2. var Controller = {
  3. index: function() {
  4. Table.init = {
  5. table_elem: '#currentTable',
  6. table_render_id: 'currentTable',
  7. add_url: "user.user/add",
  8. edit_url: "user.user/edit",
  9. delete_url: "user.user/del",
  10. multi_url: 'user.user/multi',
  11. };
  12. Table.render({
  13. init: Table.init,
  14. toolbar: ['refresh', 'add', 'delete', {
  15. text: '更多',
  16. auth: 'multi',
  17. icon: 'iconfont icon-more-line',
  18. class: 'layui-btn layui-btn-sm layui-btn-primary layui-border btn-disabled layui-btn-disabled',
  19. extend: 'id="dropdown-more"',
  20. }],
  21. url: 'user.user/index',
  22. lineStyle: 'height: 45px;',
  23. cols: [
  24. [
  25. { type: 'checkbox', fixed: 'left' },
  26. { field: 'id', width: 90, title: 'ID' },
  27. { field: 'group.name', width: 110, title: '用户组' },
  28. { field: 'username', width: 150, title: '用户名', searchOp: 'like' },
  29. { field: 'nickname', title: '昵称', searchOp: 'like' },
  30. { field: 'avatar', width: 70, align: "center", title: '头像', search: false, templet: Table.formatter.image },
  31. { field: 'mobile', width: 120, title: '手机', searchOp: 'like' },
  32. { field: 'email', width: 180,title: '邮箱', searchOp: 'like' },
  33. { field: 'reg_ip', width: 120,title: '注册IP' },
  34. { field: 'last_login_time', width: 160, title: '最后登录', search: 'range', templet: Table.formatter.datetime },
  35. { field: 'amount', width: 90, title: '余额',search: 'between', searchTip: '余额' },
  36. { field: 'point', width: 90, title: '积分',search: 'between', searchTip: '积分' },
  37. { field: 'status', width: 80, title: '状态', templet: Table.formatter.status, selectList: { 0: '禁用', 1: '正常' } },
  38. { fixed: 'right', width: 90, title: '操作', templet: Table.formatter.tool, operat: ['edit', 'delete'] }
  39. ]
  40. ],
  41. page: {},
  42. done: function() {
  43. //更多操作
  44. layui.dropdown.render({
  45. elem: '#dropdown-more',
  46. data: [{
  47. title: '设置正常',
  48. templet: '<i class="iconfont icon-eye-line"></i>&nbsp;设置正常',
  49. params:'status=1'
  50. }, {
  51. title: '设置禁用',
  52. templet: '<i class="iconfont icon-eye-close-line"></i>&nbsp;设置禁用',
  53. params:'status=0'
  54. }],
  55. click: function(obj) {
  56. tableId = Table.init.table_render_id;
  57. var ids = Table.api.selectedids(tableId);
  58. if (ids.length <= 0) {
  59. Toastr.error('请勾选需要操作的数据');
  60. return false;
  61. }
  62. Yzn.api.ajax({
  63. url: Table.init.multi_url,
  64. data: { id: ids, param: obj.params }
  65. }, function(data, ret) {
  66. layui.table.reload(tableId);
  67. });
  68. }
  69. });
  70. }
  71. });
  72. Table.api.bindevent();
  73. },
  74. add: function() {
  75. Controller.api.bindevent();
  76. },
  77. edit: function() {
  78. Controller.api.bindevent();
  79. },
  80. api: {
  81. bindevent: function() {
  82. Form.api.bindevent($("form.layui-form"));
  83. }
  84. }
  85. };
  86. return Controller;
  87. });