Compare commits

...

2 Commits

4 changed files with 312 additions and 211 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,8 @@
"@aligov/jssdk-mgop": "^3.0.0", "@aligov/jssdk-mgop": "^3.0.0",
"axios": "^0.21.4", "axios": "^0.21.4",
"element-ui": "^2.15.6", "element-ui": "^2.15.6",
"html2canvas": "^1.3.2",
"jquery": "^3.6.0",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"less": "^4.1.1", "less": "^4.1.1",
"less-loader": "^4.1.0", "less-loader": "^4.1.0",

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="container"> <div class="container">
<div class="pdf"> <div class="pdf" ref="image">
<div id="printdiv"> <div id="printdiv">
<!-- 表格1 --> <!-- 表格1 -->
<table <table
@@ -461,14 +461,35 @@
</p> </p>
</div> </div>
</div> </div>
<div class="button"> <!-- 底部按钮 -->
<div class="bottom">
<a href="#" download="">
<el-button type="primary">保存到相册</el-button> <el-button type="primary">保存到相册</el-button>
</a>
</div> </div>
</div> </div>
</template> </template>
<script src="https://cdn.bootcss.com/html2canvas/0.5.0-beta4/html2canvas.js"></script>
<script> <script>
import "./evaluateResult.js"; import jquery from "jquery";
export default {}; import html2canvas from "html2canvas";
// import "./evaluateResult.js";
export default {
data() {
return {};
},
methods: {},
mounted() {
html2canvas(this.$refs.image).then(canvas => {
canvas.id = "mycanvas";
var base64 = canvas.toDataURL("image/png");
jquery("a").prop("href", base64);
// var newImg = document.createElement("img");
// newImg.src = dataUrl;
// document.body.appendChild(newImg);
});
}
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@@ -568,7 +589,7 @@ export default {};
} }
} }
} }
.button { .bottom {
text-align: center; text-align: center;
margin-bottom: 20px; margin-bottom: 20px;
} }

View File

@@ -1,23 +1,40 @@
<template> <template>
<div> <div>
<pdf :src="url"></pdf> <pdf :src="url"></pdf>
<div ref="content" class="content">被保存的内容</div>
<div class="bottom">
<a href="" download="">
<el-button type="primary">保存到相册</el-button>
</a>
</div>
</div> </div>
</template> </template>
<script src="https://cdn.bootcss.com/html2canvas/0.5.0-beta4/html2canvas.js"></script>
<script> <script>
import pdf from 'vue-pdf'; import pdf from "vue-pdf";
import jquery from "jquery";
import html2canvas from "html2canvas";
export default { export default {
components: { components: {
pdf, pdf
}, },
data() { data() {
return { return {
url: '', url: ""
}; };
}, },
created() { created() {
this.onInit(); this.onInit();
console.log('pdf'); console.log("pdf");
},
mounted() {
// 截图
html2canvas(this.$refs.content).then(canvas => {
canvas.id = "mycanvas";
const base64 = canvas.toDataURL("image/png");
jquery("a").prop("href", base64);
});
}, },
methods: { methods: {
onInit() { onInit() {
@@ -26,7 +43,18 @@ export default {
onLoadData() { onLoadData() {
console.log(this.$route.params); console.log(this.$route.params);
this.url = this.$route.params.url; this.url = this.$route.params.url;
}, }
}, }
}; };
</script> </script>
<style lang="less" scoped>
.content {
text-align: center;
height: 200px;
line-height: 200px;
}
.bottom {
text-align: center;
margin-bottom: 20px;
}
</style>