pcadmin.js 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: 'pcadmin/index' + location.search,
  8. add_url: 'pcadmin/add',
  9. edit_url: 'pcadmin/edit',
  10. del_url: 'pcadmin/del',
  11. multi_url: 'pcadmin/multi',
  12. import_url: 'pcadmin/import',
  13. table: 'pc_admin',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'company_id', title: __('Company_id')},
  29. {field: 'username', title: __('Username'), operate: 'LIKE'},
  30. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  31. {field: 'gonghao', title: __('Gonghao'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  33. {field: 'password', title: __('Password'), operate: 'LIKE'},
  34. {field: 'salt', title: __('Salt'), operate: 'LIKE'},
  35. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  36. {field: 'loginfailure', title: __('Loginfailure')},
  37. {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  39. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'token', title: __('Token'), operate: 'LIKE'},
  42. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  43. {field: 'email', title: __('Email'), operate: 'LIKE'},
  44. {field: 'is_kefu', title: __('Is_kefu'), searchList: {"0":__('Is_kefu 0'),"1":__('Is_kefu 1')}, formatter: Table.api.formatter.normal},
  45. {field: 'company.companyname', title: __('Company.companyname'), operate: 'LIKE'},
  46. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  47. ]
  48. ]
  49. });
  50. // 为表格绑定事件
  51. Table.api.bindevent(table);
  52. },
  53. pcadmin: function () {
  54. Controller.api.bindevent();
  55. },
  56. add: function () {
  57. Controller.api.bindevent();
  58. },
  59. edit: function () {
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. Form.api.bindevent($("form[role=form]"));
  65. }
  66. }
  67. };
  68. return Controller;
  69. });