company.js 3.6 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: 'company/index' + location.search,
  8. add_url: 'company/add',
  9. edit_url: 'company/edit',
  10. del_url: 'company/del',
  11. multi_url: 'company/multi',
  12. import_url: 'company/import',
  13. table: 'company',
  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: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  30. {field: 'contacts', title: __('Contacts'), operate: 'LIKE'},
  31. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  32. {field: 'province_name', title: __('Province_name'), operate: 'LIKE'},
  33. {field: 'city_name', title: __('City_name'), operate: 'LIKE'},
  34. {field: 'area_name', title: __('Area_name'), operate: 'LIKE'},
  35. {field: 'province_id', title: __('Province_id'), operate: false,visible:false },
  36. {field: 'city_id', title: __('City_id'), operate: false, visible:false },
  37. {field: 'area_id', title: __('Area_id'), operate: false,visible:false },
  38. {field: 'address', title: __('Address'), operate: 'LIKE'},
  39. {field: 'full_address', title: __('Full_address'), operate: 'LIKE'},
  40. {field: 'longitude', title: __('Longitude'), operate: false, visible:false },
  41. {field: 'latitude', title: __('Latitude'), operate: false, visible:false },
  42. {field: 'aptitude_images', title: __('Aptitude_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  43. {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  44. {field: 'is_open', title: __('Is_open'), searchList: {"0":__('Is_open 0'),"1":__('Is_open 1')}, formatter: Table.api.formatter.normal},
  45. {field: 'open_hours', title: __('Open_hours'), operate: 'LIKE'},
  46. {field: 'agent_id', title: __('Agent_id')},
  47. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  48. ]
  49. ]
  50. });
  51. // 为表格绑定事件
  52. Table.api.bindevent(table);
  53. },
  54. add: function () {
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. Controller.api.bindevent();
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. }
  64. }
  65. };
  66. return Controller;
  67. });