rescue.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: 'sos/rescue/index' + location.search,
  8. add_url: 'sos/rescue/add',
  9. edit_url: 'sos/rescue/edit',
  10. del_url: 'sos/rescue/del',
  11. multi_url: 'sos/rescue/multi',
  12. import_url: 'sos/rescue/import',
  13. table: 'rescue',
  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: 'volunteer_id', title: __('Volunteer_id')},
  29. {field: 'institution_id', title: __('Institution_id')},
  30. {field: 'name', title: __('Name'), operate: 'LIKE'},
  31. {field: 'phone', title: __('Phone'), operate: 'LIKE'},
  32. {field: 'address', title: __('Address'), operate: 'LIKE'},
  33. {field: 'certificateimage', title: __('Certificateimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'receive', title: __('Receive')},
  35. {field: 'refuse', title: __('Refuse')},
  36. {field: 'out', title: __('Out')},
  37. {field: 'start_hour', title: __('Start_hour')},
  38. {field: 'end_hour', title: __('End_hour')},
  39. {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},
  40. {field: 'speciali', title: __('Speciali'), operate: 'LIKE'},
  41. {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  42. {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  43. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. add: function () {
  52. $("#c-user_id").data("params", function (obj) {
  53. return {custom: {cid: $("#c-cid").val()}};
  54. });
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. $("#c-user_id").data("params", function (obj) {
  59. return {custom: {cid: $("#c-cid").val()}};
  60. });
  61. Controller.api.bindevent();
  62. },
  63. api: {
  64. bindevent: function () {
  65. Form.api.bindevent($("form[role=form]"));
  66. }
  67. }
  68. };
  69. return Controller;
  70. });