resize.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function(doc, win) {
  2. var docEl = doc.documentElement,
  3. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  4. recalc = function() {
  5. var clientWidth = docEl.clientWidth;
  6. if(!clientWidth) return;
  7. if(clientWidth >= 1080) {
  8. docEl.style.fontSize = '100px';
  9. } else {
  10. docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
  11. }
  12. };
  13. if(!doc.addEventListener) return;
  14. win.addEventListener(resizeEvt, recalc, false);
  15. doc.addEventListener('DOMContentLoaded', recalc, false);
  16. var docEl = document.documentElement;
  17. var clientWidth = docEl.clientHeight;
  18. })(document, window);
  19. // 导出
  20. function downloadExcel(data, fileName) {
  21. if (!data) { return }
  22. const a = moment().format('YYYYMMDDHHmmss')
  23. const fname = fileName + a
  24. const blob = new Blob([data], { type: 'application/vnd.ms-excel' })
  25. if (window.navigator && window.navigator.msSaveOrOpenBlob) {
  26. console.log('22222')
  27. navigator.msSaveBlob(blob, fname + '.xlsx')
  28. } else {
  29. const link = document.createElement('a')
  30. link.style.display = 'none'
  31. var href = URL.createObjectURL(blob)
  32. link.href = href
  33. alert('111111')
  34. // window.location.href = 'https://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/sendOutOrderImport.xlsx'
  35. link.setAttribute('download', fname + '.xlsx')
  36. document.body.appendChild(link)
  37. link.click()
  38. document.body.removeChild(link)
  39. window.URL.revokeObjectURL(href) // 释放掉blob对象
  40. }
  41. }