plan.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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: 'equipment/plan/index' + location.search,
  8. add_url: 'equipment/plan/add',
  9. edit_url: 'equipment/plan/edit',
  10. del_url: 'equipment/plan/del',
  11. multi_url: 'equipment/plan/multi',
  12. import_url: 'equipment/plan/import',
  13. table: 'equipment_plan',
  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: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'first_duetime', title: __('First_duetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  30. {field: 'last_duetime', title: __('Last_duetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  31. {field: 'periodicity', title: __('Periodicity')},
  32. {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
  33. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ],
  38. search: false
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. },
  43. recyclebin: function () {
  44. // 初始化表格参数配置
  45. Table.api.init({
  46. extend: {
  47. 'dragsort_url': ''
  48. }
  49. });
  50. var table = $("#table");
  51. // 初始化表格
  52. table.bootstrapTable({
  53. url: 'equipment/plan/recyclebin' + location.search,
  54. pk: 'id',
  55. sortName: 'id',
  56. columns: [
  57. [
  58. {checkbox: true},
  59. {field: 'id', title: __('Id')},
  60. {field: 'name', title: __('Name'), align: 'left'},
  61. {
  62. field: 'deletetime',
  63. title: __('Deletetime'),
  64. operate: 'RANGE',
  65. addclass: 'datetimerange',
  66. formatter: Table.api.formatter.datetime
  67. },
  68. {
  69. field: 'operate',
  70. width: '130px',
  71. title: __('Operate'),
  72. table: table,
  73. events: Table.api.events.operate,
  74. buttons: [
  75. {
  76. name: 'Restore',
  77. text: __('Restore'),
  78. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  79. icon: 'fa fa-rotate-left',
  80. url: 'equipment/plan/restore',
  81. refresh: true
  82. },
  83. {
  84. name: 'Destroy',
  85. text: __('Destroy'),
  86. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  87. icon: 'fa fa-times',
  88. url: 'equipment/plan/destroy',
  89. refresh: true
  90. }
  91. ],
  92. formatter: Table.api.formatter.operate
  93. }
  94. ]
  95. ]
  96. });
  97. // 为表格绑定事件
  98. Table.api.bindevent(table);
  99. },
  100. list: function () {
  101. // 初始化表格参数配置
  102. Table.api.init();
  103. var table = $("#table");
  104. // 初始化表格
  105. table.bootstrapTable({
  106. url: 'equipment/plan/list' + location.search,
  107. pk: 'id',
  108. sortName: 'id',
  109. columns: [
  110. [
  111. {field: 'equipment_code', title: __('EquipmentCode')},
  112. {field: 'coding', title: __('QrcodeTag'), table: table, buttons: [
  113. {
  114. name: 'qrcode',
  115. text: '',
  116. title: __('QrcodeTag'),
  117. icon: 'fa fa-qrcode',
  118. extend: 'data-area=\'["350px", "380px"]\'',
  119. classname: 'btn btn-xs btn-primary btn-dialog',
  120. url: function(row) {
  121. return 'equipment/equipment/qrcode?coding=' + row.coding + '&equipment_code=' + row.equipment_code;
  122. },
  123. },
  124. ], formatter: Table.api.formatter.buttons, operate: false
  125. },
  126. {field: 'archive.model', title: __('EquipmentModel')},
  127. {field: 'archive.name', title: __('EquipmentName')},
  128. {field: 'archive.load_supplier.name', title: __('SupplierId')},
  129. {field: 'archive.purchasetime_text', title: __('Purchasetime')},
  130. {field: 'archive.region', title: __('Region'), operate: false},
  131. {field: 'archive.load_responsible_user.nickname', title: __('ResponsibleUid'), formatter: function(value, row){return value + ',' + row.archive.load_responsible_user.mobile}, operate: false},
  132. ]
  133. ],
  134. search: false,
  135. showToggle: false,
  136. showColumns: false,
  137. showExport: false,
  138. commonSearch: false
  139. });
  140. // 为表格绑定事件
  141. Table.api.bindevent(table);
  142. },
  143. add: function () {
  144. Controller.api.bindevent();
  145. },
  146. edit: function () {
  147. Controller.api.bindevent();
  148. },
  149. api: {
  150. bindevent: function () {
  151. Form.api.bindevent($("form[role=form]"));
  152. }
  153. },
  154. };
  155. return Controller;
  156. });