user.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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='gh_id']", form).addClass("selectpage").data("source", "gonghui/index").data("primaryKey", "id").data("field", "name").data("orderBy", "id asc");
  21. Form.events.cxselect(form);
  22. Form.events.selectpage(form);
  23. });
  24. // 初始化表格
  25. table.bootstrapTable({
  26. url: $.fn.bootstrapTable.defaults.extend.index_url,
  27. pk: 'id',
  28. sortName: 'id',
  29. columns: [
  30. [
  31. {checkbox: true},
  32. {field: 'id', title: __('Id')},
  33. // {field: 'gh_id', title: __('Gh_id')},
  34. {field: 'gonghui.name', title: __('Gonghui.name'), operate: false},
  35. {field: 'username', title: __('Username'), operate: 'LIKE'},
  36. // {field: 'truename', title: __('Truename'), operate: 'LIKE'},
  37. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  38. //{field: 'password', title: __('Password'), operate: 'LIKE'},
  39. //{field: 'salt', title: __('Salt'), operate: 'LIKE'},
  40. //{field: 'email', title: __('Email'), operate: 'LIKE'},
  41. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  42. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  43. {field: 'real_status', title: __('Real_status'), searchList: {"-1":__('Real_status -1'),"0":__('Real_status 0'),"1":__('Real_status 1'),"2":__('Real_status 2')}, formatter: Table.api.formatter.status},
  44. {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
  45. //{field: 'height', title: __('Height'), operate: 'LIKE'},
  46. //{field: 'weight', title: __('Weight'), operate: 'LIKE'},
  47. //{field: 'birthday', title: __('Birthday')},
  48. //{field: 'bio', title: __('Bio'), operate: 'LIKE'},
  49. //{field: 'audio_bio', title: __('Audio_bio'), operate: 'LIKE'},
  50. //{field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
  51. //{field: 'idcard_images', title: __('Idcard_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  52. // {field: 'alipay_account', title: __('Alipay_account'), operate: 'LIKE'},
  53. {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},
  54. //{field: 'successions', title: __('Successions')},
  55. //{field: 'maxsuccessions', title: __('Maxsuccessions')},
  56. {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  57. //{field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  58. //{field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  59. //{field: 'loginfailure', title: __('Loginfailure')},
  60. //{field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
  61. //{field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  62. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  63. //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  64. //{field: 'token', title: __('Token'), operate: 'LIKE'},
  65. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  66. //{field: 'verification', title: __('Verification'), operate: 'LIKE'},
  67. //{field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  68. //{field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  69. {field: 'register_from', title: __('Register_from'), operate: 'LIKE'},
  70. {field: 'cityname', title: __('Cityname'), operate: 'LIKE'},
  71. //{field: 'photo_images', title: __('Photo_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  72. //{field: 'education_id', title: __('Education_id')},
  73. //{field: 'hobby_ids', title: __('Hobby_ids'), operate: 'LIKE'},
  74. //{field: 'job_id', title: __('Job_id')},
  75. //{field: 'marital_id', title: __('Marital_id')},
  76. //{field: 'tag_ids', title: __('Tag_ids'), operate: 'LIKE'},
  77. //{field: 'wages_id', title: __('Wages_id')},
  78. //{field: 'hometown_cityid', title: __('Hometown_cityid')},
  79. //{field: 'open_match_video', title: __('Open_match_video'), searchList: {"1":__('Open_match_video 1'),"0":__('Open_match_video 0')}, formatter: Table.api.formatter.normal},
  80. //{field: 'open_match_audio', title: __('Open_match_audio'), searchList: {"1":__('Open_match_audio 1'),"0":__('Open_match_audio 0')}, formatter: Table.api.formatter.normal},
  81. //{field: 'open_match_typing', title: __('Open_match_typing'), searchList: {"1":__('Open_match_typing 1'),"0":__('Open_match_typing 0')}, formatter: Table.api.formatter.normal},
  82. //{field: 'free_video', title: __('Free_video'), searchList: {"1":__('Free_video 1'),"0":__('Free_video 0')}, formatter: Table.api.formatter.normal},
  83. //{field: 'free_audio', title: __('Free_audio'), searchList: {"1":__('Free_audio 1'),"0":__('Free_audio 0')}, formatter: Table.api.formatter.normal},
  84. //{field: 'free_typing', title: __('Free_typing'), searchList: {"1":__('Free_typing 1'),"0":__('Free_typing 0')}, formatter: Table.api.formatter.normal},
  85. //{field: 'gonghui.id', title: __('Gonghui.id')},
  86. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  87. ]
  88. ]
  89. });
  90. // 为表格绑定事件
  91. Table.api.bindevent(table);
  92. },
  93. add: function () {
  94. Controller.api.bindevent();
  95. },
  96. edit: function () {
  97. Controller.api.bindevent();
  98. },
  99. api: {
  100. bindevent: function () {
  101. Form.api.bindevent($("form[role=form]"));
  102. }
  103. }
  104. };
  105. return Controller;
  106. });