company.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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,
  54. buttons:[
  55. {
  56. name:'guanlian',
  57. text:'关联分公司',
  58. title:'关联分公司',
  59. icon:'fa fa-exclamation-circle',
  60. classname:'btn btn-xs btn-info btn-dialog',
  61. extend: 'data-area=["80%","80%"]',
  62. url:'company/guanlian/ids/{ids}?dialog=1',
  63. target:'_self',
  64. hidden:function($row){
  65. if($row.status == -1){
  66. return false;
  67. }
  68. return true;
  69. }
  70. },
  71. {
  72. name:'audit',
  73. text:'平台审核',
  74. title:'平台审核',
  75. icon:'fa fa-exclamation-circle',
  76. classname:'btn btn-xs btn-info btn-dialog',
  77. extend: 'data-area=["80%","80%"]',
  78. url:'company/audit/ids/{ids}?dialog=1',
  79. target:'_self',
  80. hidden:function($row){
  81. if($row.status == 0 || $row.status == 1 || $row.status == 2){
  82. return false;
  83. }
  84. return true;
  85. }
  86. },
  87. ],
  88. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  89. ]
  90. ]
  91. });
  92. // 为表格绑定事件
  93. Table.api.bindevent(table);
  94. },
  95. add: function () {
  96. Controller.api.bindevent();
  97. },
  98. edit: function () {
  99. Controller.api.bindevent();
  100. },
  101. guanlian: function () {
  102. Controller.api.bindevent();
  103. },
  104. audit: function () {
  105. Controller.api.bindevent();
  106. },
  107. api: {
  108. bindevent: function () {
  109. $("#c-city_id").data("params",function(){
  110. return {custom:{pid:$("#c-province_id").val()}};
  111. });
  112. $("#c-area_id").data("params",function(){
  113. return {custom:{pid:$("#c-city_id").val()}};
  114. });
  115. $("[data-toggle='addresspicker']").data("callback", function(res){
  116. //其中res则是包含了address/lat/lng等信息的JSON对象
  117. });
  118. Form.api.bindevent($("form[role=form]"));
  119. }
  120. }
  121. };
  122. return Controller;
  123. });