usertrain.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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: 'usertrain/index' + location.search,
  8. add_url: 'usertrain/add',
  9. edit_url: 'usertrain/edit',
  10. del_url: 'usertrain/del',
  11. multi_url: 'usertrain/multi',
  12. import_url: 'usertrain/import',
  13. table: 'user_train',
  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. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'train_id', title: __('Train_id')},
  27. {field: 'active.name', title: __('Active.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  28. {field: 'active.number', title: __('Active.number'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  29. {field: 'user_id', title: __('User_id')},
  30. // {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  31. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  32. // {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
  33. {field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'user.idcard_status', title: __('User.idcard_status'), searchList: {"-1":__('User.idcard_status -1'),"0":__('User.idcard_status 0'),"1":__('User.idcard_status 1'),"2":__('User.idcard_status 2')}, formatter: Table.api.formatter.status},
  35. {field: 'sign_time', title: __('Sign_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  37. {field: 'sign_image', title: __('Sign_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. api: {
  52. bindevent: function () {
  53. Form.api.bindevent($("form[role=form]"));
  54. }
  55. }
  56. };
  57. return Controller;
  58. });