archive.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.columnDefaults.align = 'left';
  6. Table.api.init({
  7. extend: {
  8. index_url: 'equipment/archive/index' + location.search,
  9. add_url: 'equipment/archive/add',
  10. edit_url: 'equipment/archive/edit',
  11. del_url: 'equipment/archive/del',
  12. multi_url: 'equipment/archive/multi',
  13. import_url: 'equipment/archive/import',
  14. table: 'equipment_archive',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true, align: 'center'},
  26. {field: 'id', title: __('Id'), align: 'center', operate: false},
  27. {field: 'model', title: __('Model'), operate: 'LIKE'},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'parameter', title: __('Parameter'), operate: false,
  30. formatter : function(value, row, index, field){
  31. return "<span style='display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;' title='" + row.parameter + "'>" + value + "</span>";
  32. },
  33. cellStyle : function(value, row, index, field){
  34. return {
  35. css: {
  36. "white-space": "nowrap",
  37. "text-overflow": "ellipsis",
  38. "overflow": "hidden",
  39. "max-width": "200px"
  40. }
  41. };
  42. }
  43. },
  44. {field: 'supplier.name', title: __('Supplier_id')},
  45. {field: 'purchasetime_text', title: __('Purchasetime'), operate: false},
  46. {field: 'purchasetime', title: __('Purchasetime'), visible: false, operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
  47. {field: 'amount', title: __('Amount'), table: table, buttons: [
  48. {
  49. name: 'equipments',
  50. text: function (row) {
  51. return row.amount + '台 ' + __('View')
  52. },
  53. title: __('Equipment List'),
  54. extend: 'data-area=\'["100%", "100%"]\'',
  55. classname: 'btn-dialog',
  56. url: 'equipment/equipment?archive_id={id}'},
  57. ], formatter: Table.api.formatter.buttons, operate: false},
  58. {field: 'region', title: __('Region'), operate: 'LIKE'},
  59. {field: 'responsible_user.nickname', title: __('Responsible_uid'), formatter: function(value, row){return value + ',' + row.responsible_user.mobile}, operate: false},
  60. {field: 'document', title: __('Document'), table: table, buttons: [
  61. {
  62. name: 'documents',
  63. text: __('View'),
  64. title: __('View'),
  65. icon: 'fa fa-eye',
  66. extend: 'data-area=\'["100%", "100%"]\'',
  67. classname: 'btn btn-xs btn-primary btn-dialog',
  68. url: function (row) {
  69. return row.document;
  70. },
  71. visible: function (row) {
  72. return row.document !== '';
  73. }
  74. },
  75. ], formatter: Table.api.formatter.buttons, operate: false},
  76. {field: 'remark', title: __('Remark'), operate: false},
  77. {field: 'record', title: __('Record'), table: table, buttons: [
  78. {
  79. name: 'repairs',
  80. title: __('Repair List'),
  81. icon: 'fa fa-wrench',
  82. extend: 'data-area=\'["100%", "100%"]\'',
  83. classname: 'btn btn-xs btn-info btn-dialog',
  84. url: 'equipment/repair/index?archive_id={id}'
  85. },
  86. {
  87. name: 'inspection',
  88. title: __('Inspection List'),
  89. icon: 'fa fa-recycle',
  90. extend: 'data-area=\'["900px", "600px"]\'',
  91. classname: 'btn btn-xs btn-info btn-dialog',
  92. url: 'equipment/record/list?type=inspection&archiveId={id}'
  93. },
  94. {
  95. name: 'maintenance',
  96. title: __('Maintenance List'),
  97. icon: 'fa fa-clock-o',
  98. extend: 'data-area=\'["900px", "600px"]\'',
  99. classname: 'btn btn-xs btn-info btn-dialog',
  100. url: 'equipment/record/list?type=maintenance&archiveId={id}'
  101. }
  102. ], formatter: Table.api.formatter.buttons, operate: false},
  103. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  104. ]
  105. ],
  106. search: false
  107. });
  108. // 导出标签数据
  109. $(document).on("click", ".btn-export-tag", function () {
  110. var ids = Table.api.selectedids(table);
  111. top.location.href = "archive/exportTag?ids=" + ids.join(",");
  112. });
  113. // 为表格绑定事件
  114. Table.api.bindevent(table);
  115. },
  116. recyclebin: function () {
  117. // 初始化表格参数配置
  118. Table.api.init({
  119. extend: {
  120. 'dragsort_url': ''
  121. }
  122. });
  123. var table = $("#table");
  124. // 初始化表格
  125. table.bootstrapTable({
  126. url: 'equipment/archive/recyclebin' + location.search,
  127. pk: 'id',
  128. sortName: 'id',
  129. columns: [
  130. [
  131. {checkbox: true},
  132. {field: 'id', title: __('Id')},
  133. {field: 'model', title: __('Model'), operate: 'LIKE'},
  134. {field: 'name', title: __('Name'), align: 'left'},
  135. {
  136. field: 'deletetime',
  137. title: __('Deletetime'),
  138. operate: 'RANGE',
  139. addclass: 'datetimerange',
  140. formatter: Table.api.formatter.datetime
  141. },
  142. {
  143. field: 'operate',
  144. width: '130px',
  145. title: __('Operate'),
  146. table: table,
  147. events: Table.api.events.operate,
  148. buttons: [
  149. {
  150. name: 'Restore',
  151. text: __('Restore'),
  152. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  153. icon: 'fa fa-rotate-left',
  154. url: 'equipment/archive/restore',
  155. refresh: true
  156. }
  157. ],
  158. formatter: Table.api.formatter.operate
  159. }
  160. ]
  161. ],
  162. search: false,
  163. showToggle: false,
  164. showColumns: false,
  165. showExport: false,
  166. commonSearch: false
  167. });
  168. // 为表格绑定事件
  169. Table.api.bindevent(table);
  170. },
  171. add: function () {
  172. // 员工选择弹窗
  173. $(document).on("click", ".btn-choose-staff", function () {
  174. Fast.api.open('equipment/staff/picker?parent_type=archive', __('Choose_staff'), {
  175. callback: function(value){
  176. var user_id = value.user_id;
  177. var staff_list = Config.staffList;
  178. $('#c-responsible_uid').val(user_id);
  179. $('.responsible_name').val(staff_list[value.user_id]);
  180. }
  181. });
  182. });
  183. Controller.api.bindevent();
  184. },
  185. edit: function () {
  186. // 员工选择弹窗
  187. $(document).on("click", ".btn-choose-staff", function () {
  188. Fast.api.open('equipment/staff/picker?parent_type=archive', __('Choose_staff'), {
  189. callback: function(value){
  190. var user_id = value.user_id;
  191. var staff_list = Config.staffList;
  192. $('#c-responsible_uid').val(user_id);
  193. $('.responsible_name').val(staff_list[value.user_id]);
  194. }
  195. });
  196. });
  197. Controller.api.bindevent();
  198. },
  199. api: {
  200. bindevent: function () {
  201. Form.api.bindevent($("form[role=form]"));
  202. }
  203. }
  204. };
  205. return Controller;
  206. });