user.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  37. //{field: 'password', title: __('Password'), operate: 'LIKE'},
  38. //{field: 'salt', title: __('Salt'), operate: 'LIKE'},
  39. //{field: 'email', title: __('Email'), operate: 'LIKE'},
  40. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  41. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  42. {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},
  43. {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
  44. //{field: 'height', title: __('Height'), operate: 'LIKE'},
  45. //{field: 'weight', title: __('Weight'), operate: 'LIKE'},
  46. //{field: 'birthday', title: __('Birthday')},
  47. //{field: 'bio', title: __('Bio'), operate: 'LIKE'},
  48. //{field: 'audio_bio', title: __('Audio_bio'), operate: 'LIKE'},
  49. {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},
  50. //{field: 'successions', title: __('Successions')},
  51. //{field: 'maxsuccessions', title: __('Maxsuccessions')},
  52. {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  53. //{field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  54. //{field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  55. //{field: 'loginfailure', title: __('Loginfailure')},
  56. //{field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
  57. //{field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  58. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  59. //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  60. //{field: 'token', title: __('Token'), operate: 'LIKE'},
  61. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  62. //{field: 'verification', title: __('Verification'), operate: 'LIKE'},
  63. //{field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  64. //{field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  65. {field: 'register_from', title: __('Register_from'), operate: 'LIKE'},
  66. {field: 'cityname', title: __('Cityname'), operate: 'LIKE'},
  67. //{field: 'photo_images', title: __('Photo_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  68. //{field: 'education_id', title: __('Education_id')},
  69. //{field: 'hobby_ids', title: __('Hobby_ids'), operate: 'LIKE'},
  70. //{field: 'job_id', title: __('Job_id')},
  71. //{field: 'marital_id', title: __('Marital_id')},
  72. //{field: 'tag_ids', title: __('Tag_ids'), operate: 'LIKE'},
  73. //{field: 'wages_id', title: __('Wages_id')},
  74. //{field: 'hometown_cityid', title: __('Hometown_cityid')},
  75. //{field: 'open_match_video', title: __('Open_match_video'), searchList: {"1":__('Open_match_video 1'),"0":__('Open_match_video 0')}, formatter: Table.api.formatter.normal},
  76. //{field: 'open_match_audio', title: __('Open_match_audio'), searchList: {"1":__('Open_match_audio 1'),"0":__('Open_match_audio 0')}, formatter: Table.api.formatter.normal},
  77. //{field: 'open_match_typing', title: __('Open_match_typing'), searchList: {"1":__('Open_match_typing 1'),"0":__('Open_match_typing 0')}, formatter: Table.api.formatter.normal},
  78. //{field: 'free_video', title: __('Free_video'), searchList: {"1":__('Free_video 1'),"0":__('Free_video 0')}, formatter: Table.api.formatter.normal},
  79. //{field: 'free_audio', title: __('Free_audio'), searchList: {"1":__('Free_audio 1'),"0":__('Free_audio 0')}, formatter: Table.api.formatter.normal},
  80. //{field: 'free_typing', title: __('Free_typing'), searchList: {"1":__('Free_typing 1'),"0":__('Free_typing 0')}, formatter: Table.api.formatter.normal},
  81. //{field: 'gonghui.id', title: __('Gonghui.id')},
  82. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  83. ]
  84. ]
  85. });
  86. // 为表格绑定事件
  87. Table.api.bindevent(table);
  88. },
  89. add: function () {
  90. Controller.api.bindevent();
  91. },
  92. edit: function () {
  93. Controller.api.bindevent();
  94. },
  95. api: {
  96. bindevent: function () {
  97. Form.api.bindevent($("form[role=form]"));
  98. }
  99. }
  100. };
  101. return Controller;
  102. });