worker.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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: 'worker/index' + location.search,
  8. add_url: 'worker/add',
  9. edit_url: 'worker/edit',
  10. del_url: 'worker/del',
  11. multi_url: 'worker/multi',
  12. import_url: 'worker/import',
  13. table: 'worker',
  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: 'company_id', title: __('Company_id')},
  29. {field: 'company.companyname', title: __('Company.companyname'), operate: 'LIKE'},
  30. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  31. {field: 'level', title: __('Level'), operate: 'LIKE'},
  32. {field: 'truename', title: __('Truename'), operate: 'LIKE'},
  33. {field: 'gonghao', title: __('Gonghao'), operate: 'LIKE'},
  34. {field: 'mobile', title: __('Mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  35. {field: 'password', title: __('Password'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  37. {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  40. {field: 'idcard_z_image', title: __('Idcard_z_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  41. {field: 'idcard_f_image', title: __('Idcard_f_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  42. {field: 'jineng_image', title: __('Jineng_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  43. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  44. ]
  45. ]
  46. });
  47. // 为表格绑定事件
  48. Table.api.bindevent(table);
  49. },
  50. recyclebin: function () {
  51. // 初始化表格参数配置
  52. Table.api.init({
  53. extend: {
  54. 'dragsort_url': ''
  55. }
  56. });
  57. var table = $("#table");
  58. // 初始化表格
  59. table.bootstrapTable({
  60. url: 'worker/recyclebin' + location.search,
  61. pk: 'id',
  62. sortName: 'id',
  63. columns: [
  64. [
  65. {checkbox: true},
  66. {field: 'id', title: __('Id')},
  67. {field: 'company_id', title: __('Company_id')},
  68. {field: 'truename', title: __('Truename'), operate: 'LIKE'},
  69. {field: 'mobile', title: __('Mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  70. {
  71. field: 'deletetime',
  72. title: __('Deletetime'),
  73. operate: 'RANGE',
  74. addclass: 'datetimerange',
  75. formatter: Table.api.formatter.datetime
  76. },
  77. {
  78. field: 'operate',
  79. width: '140px',
  80. title: __('Operate'),
  81. table: table,
  82. events: Table.api.events.operate,
  83. buttons: [
  84. {
  85. name: 'Restore',
  86. text: __('Restore'),
  87. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  88. icon: 'fa fa-rotate-left',
  89. url: 'worker/restore',
  90. refresh: true
  91. },
  92. /*{
  93. name: 'Destroy',
  94. text: __('Destroy'),
  95. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  96. icon: 'fa fa-times',
  97. url: 'worker/destroy',
  98. refresh: true
  99. }*/
  100. ],
  101. formatter: Table.api.formatter.operate
  102. }
  103. ]
  104. ]
  105. });
  106. // 为表格绑定事件
  107. Table.api.bindevent(table);
  108. },
  109. add: function () {
  110. Controller.api.bindevent();
  111. },
  112. edit: function () {
  113. Controller.api.bindevent();
  114. },
  115. api: {
  116. bindevent: function () {
  117. Form.api.bindevent($("form[role=form]"));
  118. }
  119. }
  120. };
  121. return Controller;
  122. });