company.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'companyname', title: __('Companyname'), operate: 'LIKE'},
  27. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  28. {field: 'mobile', title: __('Mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  29. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  30. {field: 'aboutus_image', title: __('Aboutus_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  31. {field: 'operate', title: __('Operate'), table: table,
  32. buttons:[
  33. {
  34. name:'pcadmin',
  35. text:'管理员',
  36. title:'管理员',
  37. icon:'fa fa-exclamation-circle',
  38. classname:'btn btn-xs btn-info btn-dialog btn-pcadmin',
  39. url:function(row){
  40. return 'pcadmin/pcadmin/company_id/'+ row.id +'?dialog=1'
  41. },
  42. },
  43. ],
  44. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. recyclebin: function () {
  52. // 初始化表格参数配置
  53. Table.api.init({
  54. extend: {
  55. 'dragsort_url': ''
  56. }
  57. });
  58. var table = $("#table");
  59. // 初始化表格
  60. table.bootstrapTable({
  61. url: 'company/recyclebin' + location.search,
  62. pk: 'id',
  63. sortName: 'id',
  64. columns: [
  65. [
  66. {checkbox: true},
  67. {field: 'id', title: __('Id')},
  68. {field: 'companyname', title: __('Companyname'), operate: 'LIKE'},
  69. {
  70. field: 'deletetime',
  71. title: __('Deletetime'),
  72. operate: 'RANGE',
  73. addclass: 'datetimerange',
  74. formatter: Table.api.formatter.datetime
  75. },
  76. {
  77. field: 'operate',
  78. width: '140px',
  79. title: __('Operate'),
  80. table: table,
  81. events: Table.api.events.operate,
  82. buttons: [
  83. {
  84. name: 'Restore',
  85. text: __('Restore'),
  86. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  87. icon: 'fa fa-rotate-left',
  88. url: 'company/restore',
  89. refresh: true
  90. },
  91. /*{
  92. name: 'Destroy',
  93. text: __('Destroy'),
  94. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  95. icon: 'fa fa-times',
  96. url: 'company/destroy',
  97. refresh: true
  98. }*/
  99. ],
  100. formatter: Table.api.formatter.operate
  101. }
  102. ]
  103. ]
  104. });
  105. // 为表格绑定事件
  106. Table.api.bindevent(table);
  107. },
  108. pcadmin: function () {
  109. Controller.api.bindevent();
  110. },
  111. add: function () {
  112. Controller.api.bindevent();
  113. },
  114. edit: function () {
  115. Controller.api.bindevent();
  116. },
  117. api: {
  118. bindevent: function () {
  119. Form.api.bindevent($("form[role=form]"));
  120. }
  121. }
  122. };
  123. return Controller;
  124. });