|
@@ -121,8 +121,8 @@ let rptArchiveObj = {
|
|
|
let me = rptArchiveObj;
|
|
|
if (me.currentNode && me.currentArchiveUuid) {
|
|
|
try {
|
|
|
- let uuIdUrl = "/getArchivedFileByUUID/" + me.currentArchiveUuid + "/" + stringUtil.replaceAll(me.currentNode.name, "#", "_");
|
|
|
- console.log(uuIdUrl);
|
|
|
+ // let uuIdUrl = "/getArchivedFileByUUID/" + me.currentArchiveUuid + "/" + stringUtil.replaceAll(me.currentNode.name, "#", "_");
|
|
|
+ // console.log(uuIdUrl);
|
|
|
$('#iframe_made').html('<iframe src="/archive/pdf/show?file=https://measure-sign-pdf.oss-cn-shenzhen.aliyuncs.com/archive/'+ me.currentArchiveUuid +'.PDF" height="750px" width="100%" style="border: none;"></iframe>');
|
|
|
// NetcaPDFSeal.openPDFWithUrl(window.location.href);
|
|
|
// window.location = uuIdUrl;
|
|
@@ -329,3 +329,71 @@ function _dataURLtoFile(dataurl, filename) {
|
|
|
return new File([u8arr], filename, {type:mime});
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * 获取 blob
|
|
|
+ * @param {String} url 目标文件地址
|
|
|
+ * @return {Promise}
|
|
|
+ */
|
|
|
+function getBlob(url) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+
|
|
|
+ xhr.open('GET', url, true);
|
|
|
+ xhr.responseType = 'blob';
|
|
|
+ xhr.onload = () => {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ resolve(xhr.response);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.send();
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 保存
|
|
|
+ * @param {Blob} blob
|
|
|
+ * @param {String} filename 想要保存的文件名称
|
|
|
+ */
|
|
|
+function saveAs(blob, filename) {
|
|
|
+ if (window.navigator.msSaveOrOpenBlob) {
|
|
|
+ navigator.msSaveBlob(blob, filename);
|
|
|
+ } else {
|
|
|
+ const link = document.createElement('a');
|
|
|
+ const body = document.querySelector('body');
|
|
|
+
|
|
|
+ link.href = window.URL.createObjectURL(blob);
|
|
|
+ link.download = filename;
|
|
|
+
|
|
|
+ // fix Firefox
|
|
|
+ link.style.display = 'none';
|
|
|
+ body.appendChild(link);
|
|
|
+
|
|
|
+ link.click();
|
|
|
+ body.removeChild(link);
|
|
|
+
|
|
|
+ window.URL.revokeObjectURL(link.href);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 下载
|
|
|
+ * @param {String} url 目标文件地址
|
|
|
+ * @param {String} filename 想要保存的文件名称
|
|
|
+ */
|
|
|
+function download(url, filename) {
|
|
|
+ getBlob(url).then(blob => {
|
|
|
+ saveAs(blob, filename);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+$(function () {
|
|
|
+ $('#download_file').click(function () {
|
|
|
+ console.log(rptArchiveObj.currentArchiveUuid);
|
|
|
+ if (rptArchiveObj.currentArchiveUuid) {
|
|
|
+ download(`https://measure-sign-pdf.oss-cn-shenzhen.aliyuncs.com/archive/${rptArchiveObj.currentArchiveUuid}.PDF`, `${rptArchiveObj.currentNode.name} ${rptArchiveObj.currentArchiveDateStr}.pdf`);
|
|
|
+ } else {
|
|
|
+ alert('请选择打开一个报表!');
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|