sos.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/sos/index' + location.search,
  8. add_url: 'sos/sos/add',
  9. edit_url: 'sos/sos/edit',
  10. del_url: 'sos/sos/del',
  11. multi_url: 'sos/sos/multi',
  12. import_url: 'sos/sos/import',
  13. table: 'sos',
  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: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  29. {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  30. {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  31. {field: 'rescuers_id', title: __('Rescuers_id')},
  32. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ]
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. },
  42. add: function () {
  43. $("#c-user_id").data("params", function (obj) {
  44. return {custom: {cid: $("#c-cid").val()}};
  45. });
  46. $("#c-rescuers_id").data("params", function (obj) {
  47. return {custom: {cid: $("#c-cid").val()}};
  48. });
  49. Controller.api.bindevent();
  50. },
  51. edit: function () {
  52. $("#c-user_id").data("params", function (obj) {
  53. return {custom: {cid: $("#c-cid").val()}};
  54. });
  55. $("#c-rescuers_id").data("params", function (obj) {
  56. return {custom: {cid: $("#c-cid").val()}};
  57. });
  58. Controller.api.bindevent();
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. }
  64. }
  65. };
  66. return Controller;
  67. });