procuremenexport.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. Table.api.init({
  5. extend: {
  6. index_url: 'procuremenexport/index' + location.search,
  7. table: 'purchase_month_export_log',
  8. }
  9. });
  10. var table = $("#table");
  11. table.bootstrapTable({
  12. url: $.fn.bootstrapTable.defaults.extend.index_url,
  13. pk: 'id',
  14. sortName: 'id',
  15. sortOrder: 'desc',
  16. columns: [
  17. [
  18. {field: 'id', title: __('Id')},
  19. {field: 'ym', title: '月份', operate: 'LIKE'},
  20. {field: 'admin_name', title: '导出人', operate: 'LIKE'},
  21. {field: 'row_count', title: '明细行数', operate: false},
  22. {field: 'total_amount_text', title: '金额合计', operate: false},
  23. {field: 'createtime_text', title: '导出时间', operate: false}
  24. ]
  25. ]
  26. });
  27. Table.api.bindevent(table);
  28. $(document).off('click.procuremenExportMonth', '#btn-export-month-outward').on('click.procuremenExportMonth', '#btn-export-month-outward', function () {
  29. var d = new Date();
  30. var ymDefault = d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2);
  31. var escYm = String(ymDefault).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  32. var html = ''
  33. + '<div style="padding:14px 18px 6px;">'
  34. + '<div class="form-group" style="margin-bottom:0;">'
  35. + '<input type="month" id="export-outward-ym-input" class="form-control" value="' + escYm + '" style="max-width:220px;" />'
  36. + '</div>'
  37. + '</div>';
  38. Layer.open({
  39. type: 1,
  40. title: '月份外发明细导出',
  41. area: ['370px', 'auto'],
  42. shadeClose: true,
  43. content: html,
  44. btn: ['导出 Excel'],
  45. yes: function (index, layero) {
  46. var v = (layero.find('#export-outward-ym-input').val() || '').trim();
  47. if (!/^\d{4}-\d{2}$/.test(v)) {
  48. Toastr.warning('请选择有效月份');
  49. return;
  50. }
  51. Layer.close(index);
  52. var url = Fast.api.fixurl('procuremen/export_month_outward?ym=' + encodeURIComponent(v));
  53. setTimeout(function () {
  54. window.open(url, '_blank');
  55. }, 100);
  56. setTimeout(function () {
  57. table.bootstrapTable('refresh');
  58. }, 1500);
  59. }
  60. });
  61. });
  62. },
  63. api: {
  64. bindevent: function () {
  65. Form.api.bindevent($("form[role=form]"));
  66. }
  67. }
  68. };
  69. return Controller;
  70. });