jiance.js 5.6 KB

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