prints_log.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1400px","480px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'prints_log/index' + location.search,
  9. add_url: 'prints_log/add',
  10. edit_url: 'prints_log/edit',
  11. del_url: 'prints_log/del',
  12. multi_url: 'prints_log/multi',
  13. import_url: 'prints_log/import',
  14. table: 'prints_log',
  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},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'print_id_text', title: __('Print_id')},
  28. {field: 'number', title: __('打印编号')},
  29. {field: 'count', title: __('Count')},
  30. {field: 'return', title: __('Return'),formatter:function(value){return value==1?'归还':'无需归还';}},
  31. {field: 'status', title: __('Status'),formatter:function(value,row){
  32. if(row.return == 1){
  33. return value==1?'<span class="text-success">已归还</span>':'<span class="text-danger">未归还</span>';
  34. }else{
  35. return '无需归还';
  36. }
  37. }},
  38. {field: 'people_id_text', title: __('People_id')},
  39. {field: 'admin_id_text', title: __('Admin_id')},
  40. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'count2', title: __('归还份数')},
  42. {field: 'returntime', title: __('归还时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. {field: 'remark', title: __('备注说明')},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  45. buttons:[
  46. {
  47. name: 'detail', text: '归还',
  48. title: '归还文件',
  49. icon: 'fa fa-cart-arrow-down',
  50. classname: 'btn btn-xs btn-info btn-dialog',
  51. url: function(row){return 'prints_log/return_file?ids='+row.id;},
  52. extend: 'data-area= \'["410px", "600px"]\'',
  53. visible:function(row){
  54. if(row.status == 1 || row.return == 0)return false;
  55. return true;
  56. }
  57. },
  58. {
  59. name: 'detail', text: '已归还',
  60. title: '归还文件',
  61. icon: '',
  62. classname: 'btn btn-xs btn-success',
  63. visible:function(row){
  64. if(row.status == 0 || row.return == 0)return false;
  65. return true;
  66. }
  67. },
  68. {
  69. name: 'detail', text: '无需归还',
  70. title: '无需归还',
  71. icon: '',
  72. classname: 'btn btn-xs btn-grey',
  73. visible:function(row){
  74. if(row.return == 1)return false;
  75. return true;
  76. }
  77. }
  78. ]
  79. }
  80. ]
  81. ]
  82. });
  83. // 为表格绑定事件
  84. Table.api.bindevent(table);
  85. table.on('post-body.bs.table',function(){
  86. $(".btn-editone").data("area",["1000px","360px"]);
  87. })
  88. },
  89. add: function () {
  90. Controller.api.bindevent();
  91. Form.api.bindevent("form[role=form]", function(data, ret){
  92. console.log(data)
  93. console.log(ret)
  94. var url = '/weboffice/WebDocPrint.php?fileType='+data.type+'&fileaddr='+data.file+'&number='+data.number+'&title='+data.title
  95. window.open(url);
  96. //这里只要返回false,就会阻止我们的弹窗自动关闭和自动提示
  97. // return false;
  98. });
  99. },
  100. return_file:function(){
  101. Controller.api.bindevent();
  102. $("#c-count").on('keyup',function(){
  103. var max = $(this).data('max');
  104. if($(this).val()>max){
  105. Toastr.error("该数量不能大于剩余归还份数");
  106. $(this).val(max);
  107. }
  108. });
  109. $("#c-count").on('change',function(){
  110. var max = $(this).data('max');
  111. if($(this).val()>max){
  112. Toastr.error("该数量不能大于剩余归还份数");
  113. $(this).val(max);
  114. }
  115. });
  116. }
  117. ,
  118. return_multiple: function () {
  119. // 初始化表格参数配置
  120. Table.api.init({
  121. extend: {
  122. index_url: 'prints_log/index' + location.search,
  123. add_url: 'prints_log/add',
  124. edit_url: 'prints_log/edit',
  125. del_url: 'prints_log/del',
  126. multi_url: 'prints_log/multi',
  127. import_url: 'prints_log/import',
  128. table: 'prints_log',
  129. }
  130. });
  131. var table = $("#table");
  132. // 初始化表格
  133. table.bootstrapTable({
  134. url: $.fn.bootstrapTable.defaults.extend.index_url,
  135. pk: 'id',
  136. sortName: 'id',
  137. commonSearch: false,
  138. showToggle: false,
  139. showColumns: false,
  140. visible: false,
  141. showExport: false,
  142. search:false,
  143. columns: [
  144. [
  145. {checkbox: true},
  146. {field: 'order_number', title: __('Id')},
  147. {field: 'print_id_text', title: __('Print_id')},
  148. {field: 'count', title: __('Count')},
  149. {field: 'return', title: __('Return'),formatter:function(value){return value==1?'归还':'无需归还';}},
  150. {field: 'status', title: __('Status'),formatter:function(value,row){
  151. if(row.return == 1){
  152. return value==1?'已归还':'未归还';
  153. }else{
  154. return '无需归还';
  155. }
  156. }},
  157. {field: 'people_id_text', title: __('People_id')},
  158. {field: 'admin_id_text', title: __('Admin_id')},
  159. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  160. {field: 'returntime', title: __('归还时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  161. {field: 'remark', title: __('备注说明')},
  162. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  163. buttons:[
  164. {
  165. name: 'detail', text: '归还',
  166. title: '归还文件',
  167. icon: 'fa fa-cart-arrow-down',
  168. classname: 'btn btn-xs btn-info btn-dialog',
  169. url: function(row){return 'prints_log/return_file?ids='+row.id;},
  170. extend: 'data-area= \'["410px", "600px"]\'',
  171. visible:function(row){
  172. if(row.status == 1)return false;
  173. return true;
  174. }
  175. },
  176. {
  177. name: 'detail', text: '已归还',
  178. title: '归还文件',
  179. icon: '',
  180. classname: 'btn btn-xs btn-success',
  181. visible:function(row){
  182. if(row.status == 0)return false;
  183. return true;
  184. }
  185. }
  186. ]
  187. }
  188. ]
  189. ]
  190. });
  191. // 为表格绑定事件
  192. Table.api.bindevent(table);
  193. }
  194. ,
  195. edit: function () {
  196. Controller.api.bindevent();
  197. },
  198. api: {
  199. bindevent: function () {
  200. Form.api.bindevent($("form[role=form]"));
  201. }
  202. }
  203. };
  204. return Controller;
  205. });