user.js 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: 'user/user/index' + location.search,
  8. add_url: 'user/user/add',
  9. edit_url: 'user/user/edit',
  10. // del_url: 'user/user/del',
  11. multi_url: 'user/user/multi',
  12. import_url: 'user/user/import',
  13. table: 'user',
  14. }
  15. });
  16. var table = $("#table");
  17. //在普通搜索渲染后
  18. table.on('post-common-search.bs.table', function (event, table) {
  19. var form = $("form", table.$commonsearch);
  20. $("input[name='gangwei_id']", form).addClass("selectpage").data("source", "usergangwei/selectpage").data('params',{"isTree":true}).data("primaryKey", "id").data("field", "name").data("orderBy", "weigh desc");
  21. $("input[name='jigou_id']", form).addClass("selectpage").data("source", "userjigou/selectpage").data('params',{"isTree":true}).data("primaryKey", "id").data("field", "name").data("orderBy", "weigh desc");
  22. Form.events.cxselect(form);
  23. Form.events.selectpage(form);
  24. });
  25. // 初始化表格
  26. table.bootstrapTable({
  27. url: $.fn.bootstrapTable.defaults.extend.index_url,
  28. pk: 'id',
  29. sortName: 'id',
  30. fixedColumns: true,
  31. fixedRightNumber: 1,
  32. search:false, //搜索id
  33. columns: [
  34. [
  35. {checkbox: true},
  36. {field: 'id', title: __('Id')},
  37. {field: 'gangwei_id', title: __('Gangwei_id')},
  38. {field: 'gangwei.name', title: __('Gangwei.name'), operate: false},
  39. // {field: 'jigou_id', title: __('Jigou_id')},
  40. // {field: 'jigou.name', title: __('Jigou.name'), operate: false},
  41. {field: 'username', title: __('Username'), operate: 'LIKE'},
  42. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  43. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  44. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  45. {field: 'nickname_time', title: '修改昵称时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46. // {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
  47. // {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  48. // {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  49. // {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  50. // {field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
  51. // {field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  53. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  54. // {field: 'token', title: __('Token'), operate: 'LIKE'},
  55. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  56. {field: 'idcard_status', title: __('Idcard_status'), searchList: {"-1":__('Idcard_status -1'),"0":__('Idcard_status 0'),"1":__('Idcard_status 1'),"2":__('Idcard_status 2')}, formatter: Table.api.formatter.status},
  57. // {field: 'mini_openid', title: __('Mini_openid'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  58. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  59. ]
  60. ]
  61. });
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. },
  68. edit: function () {
  69. Controller.api.bindevent();
  70. },
  71. api: {
  72. bindevent: function () {
  73. Form.api.bindevent($("form[role=form]"));
  74. }
  75. }
  76. };
  77. return Controller;
  78. });