company.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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:'audit',
  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/audit/id/{ids}?dialog=1',
  63. target:'_self',
  64. },
  65. ],
  66. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  67. ]
  68. ]
  69. });
  70. // 为表格绑定事件
  71. Table.api.bindevent(table);
  72. },
  73. add: function () {
  74. Controller.api.bindevent();
  75. },
  76. edit: function () {
  77. Controller.api.bindevent();
  78. },
  79. audit: function () {
  80. Controller.api.bindevent();
  81. },
  82. api: {
  83. bindevent: function () {
  84. $("#c-city_id").data("params",function(){
  85. return {custom:{pid:$("#c-province_id").val()}};
  86. });
  87. $("#c-area_id").data("params",function(){
  88. return {custom:{pid:$("#c-city_id").val()}};
  89. });
  90. Form.api.bindevent($("form[role=form]"));
  91. }
  92. }
  93. };
  94. return Controller;
  95. });