company.js 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. search:false,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field: 'id', title: __('Id')},
  29. // {field: 'user_id', title: __('User_id')},
  30. {field: 'name', title: __('Name'), operate: 'LIKE'},
  31. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  32. {field: 'contacts', title: __('Contacts'), operate: 'LIKE'},
  33. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  34. // {field: 'province_name', title: __('Province_name'), operate: 'LIKE'},
  35. // {field: 'city_name', title: __('City_name'), operate: 'LIKE'},
  36. // {field: 'area_name', title: __('Area_name'), operate: 'LIKE'},
  37. // {field: 'province_id', title: __('Province_id')},
  38. // {field: 'city_id', title: __('City_id')},
  39. // {field: 'area_id', title: __('Area_id')},
  40. // {field: 'address', title: __('Address'), operate: 'LIKE'},
  41. {field: 'full_address', title: __('Full_address'), operate: 'LIKE'},
  42. // {field: 'longitude', title: __('Longitude'), operate:'BETWEEN'},
  43. // {field: 'latitude', title: __('Latitude'), operate:'BETWEEN'},
  44. // {field: 'aptitude_images', title: __('Aptitude_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  45. {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  46. {field: 'is_open', title: __('Is_open'), searchList: {"0":__('Is_open 0'),"1":__('Is_open 1')}, formatter: Table.api.formatter.normal},
  47. {field: 'open_hours', title: __('Open_hours'), operate: 'LIKE'},
  48. // {field: 'agent_id', title: __('Agent_id')},
  49. // {field: 'mini_code', title: __('Mini_code'), operate: 'LIKE'},
  50. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52. {field: 'wallet.money', title: __('Wallet.money'), operate:'BETWEEN'},
  53. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  54. ]
  55. ]
  56. });
  57. // 为表格绑定事件
  58. Table.api.bindevent(table);
  59. },
  60. add: function () {
  61. Controller.api.bindevent();
  62. },
  63. edit: function () {
  64. Controller.api.bindevent();
  65. },
  66. api: {
  67. bindevent: function () {
  68. $("#c-city_id").data("params",function(){
  69. return {custom:{pid:$("#c-province_id").val()}};
  70. });
  71. $("#c-area_id").data("params",function(){
  72. return {custom:{pid:$("#c-city_id").val()}};
  73. });
  74. Form.api.bindevent($("form[role=form]"));
  75. }
  76. }
  77. };
  78. return Controller;
  79. });