purchaseRptCommon.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. var myDate = new Date();
  2. var curYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  3. var curMonth = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  4. var curQuarters = Math.floor( ( (curMonth-1) % 3 == 0 ? ( (curMonth-1) / 3 ) : ( (curMonth-1) / 3 + 1 ) ) );
  5. var scopeTitle = '月 度';
  6. myDate.getMonth(); //获取当前月份(0-11,0代表1月)
  7. //调整相应的频度
  8. function tyepChange(){
  9. if($("#attType").val() == "0"){
  10. $("#attMonth").removeAttr("disabled");
  11. $("#attMonth").css("background","");
  12. $("#attQuarters").attr("disabled","disabled");
  13. $("#attQuarters").css("background","#f0f0f0");
  14. scopeTitle = '月 度';
  15. }else if($("#attType").val() == "1"){
  16. $("#attMonth").attr("disabled","disabled");
  17. $("#attMonth").css("background","#f0f0f0");
  18. $("#attQuarters").removeAttr("disabled");
  19. $("#attQuarters").css("background","");
  20. scopeTitle = '季 度';
  21. }else{
  22. $("#attMonth").attr("disabled","disabled");
  23. $("#attMonth").css("background","#f0f0f0");
  24. $("#attQuarters").attr("disabled","disabled");
  25. $("#attQuarters").css("background","#f0f0f0");
  26. scopeTitle = '年 度';
  27. }
  28. }
  29. var _hasSearch=false;
  30. function setDefault(){
  31. if(curMonth<10)
  32. curMonth = "0"+curMonth;
  33. $("#attMonth").val(curMonth);
  34. $("#attYear").val(curYear);
  35. $('#attQuarters').val(curQuarters);
  36. }
  37. var _rpttitle = '报表';
  38. function btn_output(){
  39. if(!_hasSearch){
  40. alert('请先查询数据');
  41. return;
  42. }
  43. var opt = {
  44. type:'excel'
  45. ,fileName:_rpttitle
  46. ,escape:'false'
  47. ,mso:{
  48. fileFormat: 'xlshtml'
  49. ,onMsoNumberFormat: null
  50. ,pageFormat: 'a4'
  51. ,pageOrientation: 'portrait'
  52. ,rtl: false
  53. ,styles: ['background-color',
  54. 'color',
  55. 'font-family',
  56. 'font-size',
  57. 'font-weight',
  58. 'text-align',
  59. 'height',
  60. 'padding',
  61. ,'border-bottom', 'border-top', 'border-left', 'border-right'
  62. ]
  63. // ,worksheetName: 'abc'
  64. }
  65. };
  66. // $('#jqGrid').tableExport(opt);
  67. var ex = $('#jqGrid').clone();
  68. var tbody = ex.find('tbody');
  69. var tds = tbody.find('tr:eq(0)').find('td');
  70. var thead = $("#gbox_jqGrid .ui-jqgrid-htable thead").clone();
  71. tbody.before(thead);
  72. var titleTr =$('<tr></tr>');
  73. var titleTh = $('<th></th>');
  74. titleTr.append(titleTh);
  75. titleTh.append($('.ui-jqgrid-title').clone());
  76. titleTh.attr('colspan',tds.length);
  77. thead.prepend(titleTr);
  78. thead.css('text-align','center');
  79. var footer = $('table.ui-jqgrid-ftable tbody tr');
  80. tbody.append(footer);
  81. // ex.hide();
  82. $('body').append(ex);
  83. ex.tableExport(opt);
  84. ex.remove();
  85. }