repair.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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/repair/index' + location.search,
  9. add_url: 'equipment/repair/add',
  10. edit_url: 'equipment/repair/edit',
  11. del_url: 'equipment/repair/del',
  12. multi_url: 'equipment/repair/multi',
  13. import_url: 'equipment/repair/import',
  14. table: 'equipment_repair',
  15. detail_url: 'equipment/repair/detail',
  16. register_url: 'equipment/repair/register',
  17. failure_cause_url: 'equipment/failure_cause/index',
  18. }
  19. });
  20. var table = $("#table");
  21. // 初始化表格
  22. table.bootstrapTable({
  23. url: $.fn.bootstrapTable.defaults.extend.index_url,
  24. pk: 'id',
  25. sortName: 'id',
  26. columns: [
  27. [
  28. // {checkbox: true, align: 'center'},
  29. {field: 'id', title: __('Id'), align: 'center', operate: false},
  30. {field: 'repair_code', title: __('Repair_code'), operate: 'LIKE', formatter: function (value) {
  31. return (value === "" || value === null || value === undefined ) ? '-' : value;
  32. }},
  33. {field: 'archive.model', title: __('Model'), operate: 'LIKE'},
  34. {field: 'archive.name', title: __('Name'), operate: 'LIKE'},
  35. {field: 'equipment.equipment_code', title: __('Equipment_code'), operate: 'LIKE'},
  36. {field: 'register_user.nickname', title: __('Register_uid')},
  37. {field: 'registertime', title: __('Registertime'), operate: 'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY年MM月DD日 HH:mm"},
  38. {field: 'assigntime', title: __('Assigntime'), operate: 'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY年MM月DD日 HH:mm"},
  39. {field: 'failure_cause.name', title: __('Failure_cause'), operate: false},
  40. {field: 'repair_user.nickname', title: __('Repair_uid')},
  41. {field: 'repairtime', title: __('Repairtime'), operate: 'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY年MM月DD日 HH:mm"},
  42. {field: 'status', title: __('Status'), searchList: {'pending': __('Pending'), 'registered': __('Registered'), 'repaired': __('Repaired'), 'scrapped': __('Scrapped')}, custom: {'pending': 'warning', 'registered': 'info', 'repaired': 'success', 'scrapped': 'danger'}, formatter:Table.api.formatter.label},
  43. {field: 'operate', title: __('Operate'), table: table, buttons: [
  44. {
  45. name: 'assignment',
  46. text: __('Assignment'),
  47. title: __('Assignment_staff'),
  48. icon: 'fa fa-hand-pointer-o',
  49. classname: 'btn btn-xs btn-warning btn-dialog',
  50. url: 'equipment/staff/picker?parent_id={id}&parent_type=repair',
  51. visible: function (row) {
  52. if (row.status === 'pending' || row.status === 'registered') {
  53. return true;
  54. } else {
  55. return false;
  56. }
  57. }
  58. },
  59. {
  60. name: 'registers',
  61. text: __('Register'),
  62. title: __('Repair_content'),
  63. icon: 'fa fa-pencil',
  64. classname: 'btn btn-xs btn-success btn-dialog',
  65. url: 'equipment/repair/register?id={id}',
  66. visible: function (row) {
  67. if (row.status === 'registered') {
  68. return true;
  69. } else {
  70. return false;
  71. }
  72. }
  73. },
  74. {
  75. name: 'details',
  76. text: __('View'),
  77. title: __('Repair_detail'),
  78. icon: 'fa fa-eye',
  79. classname: 'btn btn-xs btn-info btn-dialog',
  80. url: 'equipment/repair/detail?id={id}'
  81. },
  82. ], events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  83. ]
  84. ],
  85. search: false
  86. });
  87. // 故障原因管理弹窗
  88. $(document).on("click", ".btn-failure-cause", function () {
  89. Fast.api.open('equipment/failure_cause/index', __('Failure_cause'));
  90. });
  91. // 派单通知人员管理弹窗
  92. $(document).on("click", ".btn-reminder-users", function () {
  93. Fast.api.open('equipment/reminder_users/index?type=assign_repair', __('Reminder_users'));
  94. });
  95. // 为表格绑定事件
  96. Table.api.bindevent(table);
  97. },
  98. recyclebin: function () {
  99. // 初始化表格参数配置
  100. Table.api.init({
  101. extend: {
  102. 'dragsort_url': ''
  103. }
  104. });
  105. var table = $("#table");
  106. // 初始化表格
  107. table.bootstrapTable({
  108. url: 'equipment/repair/recyclebin' + location.search,
  109. pk: 'id',
  110. sortName: 'id',
  111. columns: [
  112. [
  113. {checkbox: true},
  114. {field: 'id', title: __('Id')},
  115. {
  116. field: 'deletetime',
  117. title: __('Deletetime'),
  118. operate: 'RANGE',
  119. addclass: 'datetimerange',
  120. formatter: Table.api.formatter.datetime
  121. },
  122. {
  123. field: 'operate',
  124. width: '130px',
  125. title: __('Operate'),
  126. table: table,
  127. events: Table.api.events.operate,
  128. buttons: [
  129. {
  130. name: 'Restore',
  131. text: __('Restore'),
  132. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  133. icon: 'fa fa-rotate-left',
  134. url: 'equipment/repair/restore',
  135. refresh: true
  136. }
  137. ],
  138. formatter: Table.api.formatter.operate
  139. }
  140. ]
  141. ],
  142. search: false,
  143. showToggle: false,
  144. showColumns: false,
  145. showExport: false,
  146. commonSearch: false
  147. });
  148. // 为表格绑定事件
  149. Table.api.bindevent(table);
  150. },
  151. add: function () {
  152. Controller.api.bindevent();
  153. },
  154. edit: function () {
  155. Controller.api.bindevent();
  156. },
  157. assignment: function () {
  158. Controller.api.bindevent();
  159. },
  160. register: function () {
  161. Controller.api.bindevent();
  162. },
  163. detail: function () {
  164. Controller.api.bindevent();
  165. },
  166. api: {
  167. bindevent: function () {
  168. Form.api.bindevent($("form[role=form]"));
  169. }
  170. }
  171. };
  172. return Controller;
  173. });