coach.js 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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: 'coach/index' + location.search,
  8. add_url: 'coach/add',
  9. edit_url: 'coach/edit',
  10. del_url: 'coach/del',
  11. multi_url: 'coach/multi',
  12. import_url: 'coach/import',
  13. table: 'coach',
  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: 'username', title: __('Username'), operate: 'LIKE'},
  29. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  30. // {field: 'tag_ids', title: __('Tag_ids'), operate: 'LIKE'},
  31. // {field: 'desc', title: __('Desc'), operate: 'LIKE'},
  32. {field: 'firstname', title: __('Firstname'), operate: 'LIKE'},
  33. {field: 'lastname', title: __('Lastname'), operate: 'LIKE'},
  34. // {field: 'password', title: __('Password'), operate: 'LIKE'},
  35. // {field: 'salt', title: __('Salt'), operate: 'LIKE'},
  36. {field: 'email', title: __('Email'), operate: 'LIKE'},
  37. // {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  38. // {field: 'simplemobile', title: __('Simplemobile'), operate: 'LIKE'},
  39. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  40. // {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
  41. // {field: 'successions', title: __('Successions')},
  42. // {field: 'maxsuccessions', title: __('Maxsuccessions')},
  43. // {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. // {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. // {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  46. // {field: 'loginfailure', title: __('Loginfailure')},
  47. // {field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
  48. // {field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  49. // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  50. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51. // {field: 'token', title: __('Token'), operate: 'LIKE'},
  52. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  53. // {field: 'tag.name', title: __('Tag.name'), operate: 'LIKE'},
  54. // {field: 'tag.name_en', title: __('Tag.name_en'), operate: 'LIKE'},
  55. {field: 'whatsapp', title: __('Whatsapp'), operate: 'LIKE'},
  56. {field: 'bgcolor', title: __('Bgcolor'), formatter: Table.api.formatter.colortext},
  57. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  58. ]
  59. ]
  60. });
  61. // 为表格绑定事件
  62. Table.api.bindevent(table);
  63. },
  64. add: function () {
  65. Controller.api.bindevent();
  66. },
  67. edit: function () {
  68. Controller.api.bindevent();
  69. },
  70. vue_add: function () {
  71. Form.api.bindevent($("form[role=form]"), function(data, ret){
  72. window.location.href = ret.url;
  73. })
  74. },
  75. vue_edit: function () {
  76. Form.api.bindevent($("form[role=form]"), function(data, ret){
  77. window.location.href = ret.url;
  78. })
  79. },
  80. api: {
  81. bindevent: function () {
  82. Form.api.bindevent($("form[role=form]"));
  83. }
  84. }
  85. };
  86. return Controller;
  87. });