修复导出pdf图片

des
吕天方 7 months ago
parent ad3e9f77da
commit 3d41ca2207

@ -5,8 +5,8 @@ VUE_APP_TITLE = 金鸡湖现代服务业品牌管理系统
ENV = 'development'
# 金鸡湖现代服务业品牌管理系统/开发环境
VUE_APP_BASE_API = 'http://192.168.0.118:9040'
# VUE_APP_BASE_API = 'http://39.101.188.84:9040'
# VUE_APP_BASE_API = 'http://192.168.0.118:9040'
VUE_APP_BASE_API = 'http://39.101.188.84:9040'
# VUE_APP_BASE_API = 'https://idp.sipac.gov.cn/api'
# 路由懒加载

@ -1,6 +1,6 @@
{
"name": "ruoyi",
"version": "1.0.202406211520",
"version": "1.0.202406240902",
"description": "金鸡湖现代服务业品牌管理系统",
"author": "若依",
"license": "MIT",

@ -201,24 +201,159 @@ div::-webkit-scrollbar {
section::-webkit-scrollbar {
display: none;
}
.detail_content {
display: flex;
justify-content: space-between;
// height: calc(100vh - 160px);
height: calc(100% - 40px);
.left_content {
// height: calc(100vh - 160px);
height: 100%;
width: 69.5%;
overflow: auto;
background-color: #fff;
padding: 20px;
}
.right_content {
#detail_content_two {
width: 100%;
#reportId {
display: flex;
justify-content: space-between;
// height: calc(100vh - 160px);
height: 100%;
width: 30%;
background-color: #fff;
width: 100%;
.left_content {
// height: calc(100vh - 160px);
width: 69.5%;
background-color: #fff;
padding: 20px;
}
.right_content {
// height: calc(100vh - 160px);
width: 30%;
background-color: #fff;
.left_title {
height: 77px;
padding-top: 20px;
background-color: #fff;
margin-bottom: 4px;
}
.tab_content {
// height: calc(100vh - 240px);
height: calc(100% - 77px);
// overflow: auto;
background-color: #fff;
padding: 0 20px;
::v-deep .el-tabs__content {
padding: 0;
height: calc(100% - 50px);
.el-tab-pane {
height: 100%;
}
}
.empty {
// height: calc(100vh - 300px);
// height: calc(100% - 100px);
height: 100%;
padding: 10px 15px 0 15px;
overflow: auto;
.top {
font-size: 12px;
color: #737373;
margin-bottom: 10px;
}
.bottom {
text-align: center;
color: #737373;
}
.step_contain {
position: relative;
line-height: 35px;
border-left: 2px solid green;
padding-bottom: 40px;
z-index: 2;
.drop_style {
position: absolute;
width: 24px;
height: 24px;
top: -4px;
left: -12px;
background-color: #fff;
border-radius: 12px;
box-shadow: 0 0 10px #ccc;
z-index: 2;
}
.out_drop_style {
position: absolute;
width: 6px;
height: 6px;
top: 6px;
left: -3px;
background-color: #4eb997;
border-radius: 3px;
z-index: 2;
}
.out_drop_style_one {
background-color: #000;
}
.contain_main {
background-color: #f8fafb;
color: #192a92;
margin-left: 25px;
border-radius: 2px;
width: 100%;
.attach {
// display: flex;
width: 100%;
// padding-right: 100px;
position: relative;
.attach_left {
position: absolute;
width: 140px;
}
.attach_right {
// flex: 1;
// flex-direction: column;
// justify-content: space-between;
padding: 0 80px 0 50px;
.attach_item {
width: 85%;
display: flex;
// justify-content: space-between;
align-items: center;
padding: 0 5px;
color: inherit;
border: 1px solid #e4e7ed;
border-radius: 2px;
margin: 10px 20px 10px 0;
a {
display: flex;
// justify-content: space-between;
align-items: center;
}
.li_img {
width: 25px;
height: 30px;
margin-right: 10px;
padding: 2px;
}
.icon_name {
text-overflow: ellipsis;
overflow: hidden;
word-wrap: break-word;
white-space: nowrap;
}
}
}
}
}
.right-img {
position: absolute;
z-index: 2;
top: 0;
bottom: 40px;
right: 20px;
display: flex;
align-items: center;
.approval_img {
width: 85px;
height: 80px;
}
}
}
.step_contain_one {
border: none;
}
}
}
}
}
}

@ -4749,27 +4749,47 @@ export default {
/* 打印 */
printOutpdf() {
let name = `${this.templateInfo.templateName}_${this.baseInfo.enterpriseName}`;
let domName = this.$refs.pdf;
let _this = this;
let targetDom = domName; //div
let clonedNode = targetDom.cloneNode(true); //
clonedNode.setAttribute(
"style",
`width: ${targetDom.clientHeight};height: ${targetDom.clientWidth};`
);
document.body.appendChild(clonedNode); //body
html2canvas(clonedNode, {
allowTaint: true,
taintTest: false,
}).then((canvas) => {
let canvasImg = canvas.toDataURL("image/png");
_this.downLoadFile(name, canvasImg);
document.body.removeChild(clonedNode);
});
},
let name = ''
name = `${this.templateInfo.templateName}_${this.baseInfo.enterpriseName}`
let modalDiv = this.$refs.pdf
let newDiv = modalDiv.cloneNode(true)
newDiv.classList.remove('detail_content');
newDiv.id = 'reportId'
let newTwoDiv = document.createElement('div');
newTwoDiv.id = 'detail_content_two'
document.body.appendChild(newTwoDiv)
newTwoDiv.appendChild(newDiv)
let obj = document.getElementById('reportId')
setTimeout(()=>{
html2canvas(obj).then(function(canvas) {
let contentWidth = canvas.width
let contentHeight = canvas.height
let pageHeight = contentWidth / 592.28 * 841.89
let leftHeight = contentHeight
let position = 0
let imgWidth = 595.28
let imgHeight = 592.28 / contentWidth * contentHeight
let pageData = canvas.toDataURL('image/jpeg', 1.0)
let PDF = new JsPDF('p', 'pt', 'a4') // [592.28 * 841.89]
console.log(pageData);
if (leftHeight < pageHeight) {
PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
} else {
// 5
while (leftHeight > 5) {
PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
leftHeight -= pageHeight
position -= 841.89
if (leftHeight > 5) {
PDF.addPage()
}
}
}
PDF.save(name + '.pdf')
newTwoDiv.remove()
})
},200)
}
},
};
</script>
@ -5067,7 +5087,7 @@ li {
}
.form {
height: calc(100% - 150px);
// height: calc(100% - 150px);
background-color: #fff;
padding: 15px;
.table-content {

@ -309,6 +309,13 @@
</el-form-item>
</el-col>
</el-row>
<!-- <el-row>
<el-col :span="24">
<el-form-item label="政务通账户名" prop="userType">
<el-input v-model="form.userName" placeholder="请输入政务通账户名" maxlength="30" />
</el-form-item>
</el-col>
</el-row> -->
<el-row>
<el-col :span="24">
<el-form-item label="企业信息" prop="enterpriseId">

Loading…
Cancel
Save