You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

10 months ago
  1. export default {
  2. export(url, searchParameter, filenameRep) {
  3. ajax.file(url, JSON.stringify(searchParameter),
  4. resp => {
  5. var filename = filenameRep || "export.xls";
  6. var linkelem = document.createElement("a");
  7. try {
  8. var blob = new Blob([resp], {
  9. type: "application/octet-stream"
  10. });
  11. if (typeof window.navigator.msSaveBlob !== "undefined") {
  12. window.navigator.msSaveBlob(blob, filename);
  13. } else {
  14. var URL = window.URL || window.webkitURL;
  15. var downloadUrl = URL.createObjectURL(blob);
  16. if (filename) {
  17. var a = document.createElement("a");
  18. if (typeof a.download === "undefined") {
  19. window.location = downloadUrl;
  20. } else {
  21. a.href = downloadUrl;
  22. a.download = filename;
  23. document.body.appendChild(a);
  24. a.target = "_blank";
  25. a.click();
  26. }
  27. } else {
  28. window.location = downloadUrl;
  29. }
  30. }
  31. } catch (ex) {
  32. console.log(ex);
  33. }
  34. },
  35. error => {
  36. console.error(error);
  37. }
  38. );
  39. },
  40. };