|
@@ -168,7 +168,9 @@ export default {
|
|
|
// 底部文本域
|
|
|
textarea1: "",
|
|
|
// 地图底图列表
|
|
|
- mapList: []
|
|
|
+ mapList: [],
|
|
|
+ // 导出图片blob数据暂存
|
|
|
+ imgBlob: []
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -275,9 +277,23 @@ export default {
|
|
|
this.cutDiv();
|
|
|
}
|
|
|
},
|
|
|
+ // base64转file对象
|
|
|
+ base64ToFile(base64, fileName) {
|
|
|
+ let arr = base64.split(",");
|
|
|
+ let mime = arr[0].match(/:(.*?);/)[1];
|
|
|
+ let bstr = atob(arr[1]);
|
|
|
+ let n = bstr.length;
|
|
|
+ let u8arr = new Uint8Array(n);
|
|
|
+ while (n--) {
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
|
+ }
|
|
|
+ // image/png
|
|
|
+ return new File([u8arr], fileName, { type: mime });
|
|
|
+ },
|
|
|
// div转图片
|
|
|
cutDiv() {
|
|
|
try {
|
|
|
+ this.imgBlob = [];
|
|
|
this.doPrintLoading = true;
|
|
|
var container = document.getElementById("doPrint").innerHTML;
|
|
|
const _width = container.offsetWidth;
|
|
@@ -326,6 +342,7 @@ export default {
|
|
|
html2canvas(this.$refs.doPrint, ops).then(
|
|
|
canvas => {
|
|
|
document.getElementById("imgOut").setAttribute("src", canvas.toDataURL("image/png"));
|
|
|
+ this.imgBlob = canvas;
|
|
|
setTimeout(() => {
|
|
|
if (that.doPrintLoading) {
|
|
|
that.doPrint(parentNodeList, svgElemNodeList, canvasList);
|
|
@@ -373,6 +390,48 @@ export default {
|
|
|
document.body.appendChild(new_iframe);
|
|
|
doc = new_iframe.contentWindow.document;
|
|
|
var obj = document.getElementById("imgBox");
|
|
|
+
|
|
|
+ try {
|
|
|
+ let fileParams = {
|
|
|
+ columnId: "776",
|
|
|
+ paraName: "print.png",
|
|
|
+ type: "3",
|
|
|
+ file: base64ToFile(this.imgBlob, "print.png")
|
|
|
+ };
|
|
|
+ this.$Post(this.urlsCollection.proxyDmsFileUploadFile, fileParams).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ let filePath = res.content;
|
|
|
+ // 开始提交
|
|
|
+ let createTaskForm = {
|
|
|
+ c_print_user_id: localStorage.getItem("USER_ID"),
|
|
|
+ print_file: filePath,
|
|
|
+ c_print_time: parseInt(new Date().getTime() / 1000) * 1000
|
|
|
+ };
|
|
|
+ let params = new FormData();
|
|
|
+ params.append("columnId", "1405");
|
|
|
+ params.append("modelId", "776");
|
|
|
+ params.append("content", JSON.stringify(createTaskForm));
|
|
|
+ this.$Post(this.urlsCollection.addContent, params).then(
|
|
|
+ res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message.success(res.message);
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ this.submitLoading = false;
|
|
|
+ this.$message.error(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ this.$message.error("文件上传失败:" + e);
|
|
|
+ }
|
|
|
+
|
|
|
doc.write(obj.innerHTML);
|
|
|
doc.close();
|
|
|
this.showMapSvgAndRemoveMapCanvas(parentNodeList, svgElemNodeList, canvasList);
|