usercompany.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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: 'usercompany/index' + location.search,
  8. add_url: 'usercompany/add',
  9. edit_url: 'usercompany/edit',
  10. del_url: 'usercompany/del',
  11. multi_url: 'usercompany/multi',
  12. import_url: 'usercompany/import',
  13. table: 'user_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: 'user_id', title: __('User_id')},
  29. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  30. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  31. {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
  32. {field: 'company_id', title: __('Company_id')},
  33. {field: 'company.companyname', title: __('Company.companyname'), operate: 'LIKE'},
  34. {field: 'projectname', title: __('Projectname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  35. {field: 'projectaddress', title: __('Projectaddress'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. // {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  37. {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'header', title: __('Header'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  40. // {field: 'header_avatar', title: __('Header_avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  41. // {field: 'header_mobile', title: __('Header_mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  42. // {field: 'xiaofang', title: __('Xiaofang'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  43. // {field: 'xiaofang_mobile', title: __('Xiaofang_mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  44. {field: 'weituo', title: __('Weituo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  45. {field: 'fuwujigou', title: __('Fuwujigou'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  46. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  47. ]
  48. ]
  49. });
  50. // 为表格绑定事件
  51. Table.api.bindevent(table);
  52. },
  53. recyclebin: function () {
  54. // 初始化表格参数配置
  55. Table.api.init({
  56. extend: {
  57. 'dragsort_url': ''
  58. }
  59. });
  60. var table = $("#table");
  61. // 初始化表格
  62. table.bootstrapTable({
  63. url: 'usercompany/recyclebin' + location.search,
  64. pk: 'id',
  65. sortName: 'id',
  66. columns: [
  67. [
  68. {checkbox: true},
  69. {field: 'id', title: __('Id')},
  70. {field: 'user_id', title: __('User_id')},
  71. {field: 'company_id', title: __('Company_id')},
  72. {
  73. field: 'deletetime',
  74. title: __('Deletetime'),
  75. operate: 'RANGE',
  76. addclass: 'datetimerange',
  77. formatter: Table.api.formatter.datetime
  78. },
  79. {
  80. field: 'operate',
  81. width: '140px',
  82. title: __('Operate'),
  83. table: table,
  84. events: Table.api.events.operate,
  85. buttons: [
  86. {
  87. name: 'Restore',
  88. text: __('Restore'),
  89. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  90. icon: 'fa fa-rotate-left',
  91. url: 'usercompany/restore',
  92. refresh: true
  93. },
  94. /*{
  95. name: 'Destroy',
  96. text: __('Destroy'),
  97. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  98. icon: 'fa fa-times',
  99. url: 'usercompany/destroy',
  100. refresh: true
  101. }*/
  102. ],
  103. formatter: Table.api.formatter.operate
  104. }
  105. ]
  106. ]
  107. });
  108. // 为表格绑定事件
  109. Table.api.bindevent(table);
  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. });