company.js 3.6 KB

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