volunteer.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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: 'training/volunteer/index' + location.search,
  8. add_url: 'training/volunteer/add',
  9. edit_url: 'training/volunteer/edit',
  10. del_url: 'training/volunteer/del',
  11. multi_url: 'training/volunteer/multi',
  12. import_url: 'training/volunteer/import',
  13. table: 'volunteer',
  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: 'cid', title: __('Cid')},
  27. {field: 'user_id', title: __('User_id')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'phone', title: __('Phone'), operate: 'LIKE'},
  30. {field: 'sex', title: __('Sex'), searchList: {"0":__('Sex 0'),"1":__('Sex 1')}, formatter: Table.api.formatter.normal},
  31. {field: 'birth', title: __('Birth'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  32. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'certificateimage', title: __('Certificateimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'email', title: __('Email'), operate: 'LIKE'},
  35. {field: 'address', title: __('Address'), operate: 'LIKE'},
  36. {field: 'work', title: __('Work'), operate: 'LIKE'},
  37. {field: 'specialty', title: __('Specialty'), operate: 'LIKE'},
  38. {field: 'education', title: __('Education'), operate: 'LIKE'},
  39. {field: 'is_vol', title: __('Is_vol'), searchList: {"0":__('Is_vol 0'),"1":__('Is_vol 1')}, formatter: Table.api.formatter.normal},
  40. {field: 'is_experience', title: __('Is_experience'), searchList: {"0":__('Is_experience 0'),"1":__('Is_experience 1')}, formatter: Table.api.formatter.normal},
  41. {field: 'start_hour', title: __('Start_hour')},
  42. {field: 'end_hour', title: __('End_hour')},
  43. {field: 'work_week', title: __('Work_week'), searchList: {"1":__('Work_week 1'),"2":__('Work_week 2'),"3":__('Work_week 3'),"4":__('Work_week 4'),"5":__('Work_week 5'),"6":__('Work_week 6'),"7":__('Work_week 7')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
  44. {field: 'taste', title: __('Taste'), operate: 'LIKE'},
  45. {field: 'taste_title', title: __('Taste_title'), operate: 'LIKE'},
  46. {field: 'speciali', title: __('Speciali'), operate: 'LIKE'},
  47. {field: 'speciali_title', title: __('Speciali_title'), operate: 'LIKE'},
  48. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  49. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  50. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  51. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  52. ]
  53. ]
  54. });
  55. // 为表格绑定事件
  56. Table.api.bindevent(table);
  57. },
  58. add: function () {
  59. $("#c-user_id").data("params", function (obj) {
  60. return {custom: {cid: $("#c-cid").val()}};
  61. });
  62. Controller.api.bindevent();
  63. },
  64. edit: function () {
  65. $("#c-user_id").data("params", function (obj) {
  66. return {custom: {cid: $("#c-cid").val()}};
  67. });
  68. Controller.api.bindevent();
  69. },
  70. api: {
  71. bindevent: function () {
  72. Form.api.bindevent($("form[role=form]"));
  73. }
  74. }
  75. };
  76. return Controller;
  77. });