【优化】-打印页面样式的调整和内容的增加

This commit is contained in:
fengchenchen
2021-12-28 15:37:03 +08:00
parent 48c808b2d8
commit 90469290f4
+98 -32
View File
@@ -2,7 +2,6 @@
<div> <div>
<div id="needPrint"> <div id="needPrint">
<div class="sheet-box"> <div class="sheet-box">
<div class="sendName">{{ userInfo.realname }}</div> <div class="sendName">{{ userInfo.realname }}</div>
<div class="sendPhone">{{ userInfo.phone }}</div> <div class="sendPhone">{{ userInfo.phone }}</div>
@@ -27,6 +26,13 @@
<div class="arriveCity"></div> <div class="arriveCity"></div>
<div class="arrivePostNo">{{ mailDetail.postalCode }}</div> <div class="arrivePostNo">{{ mailDetail.postalCode }}</div>
<!-- 增加寄件人签署的签名功能-->
<div class="other-send-name">{{ userInfo.realname }}</div>
<div class="send-time">{{ currentTime }}</div>
<div class="inner-info-name">{{isContract ? '合同' : '发票'}}</div>
<div class="remark">如无法投出,请退收寄局,不要退原址</div>
</div> </div>
</div> </div>
</div> </div>
@@ -36,15 +42,19 @@
import Vue from 'vue' import Vue from 'vue'
import { USER_INFO } from '../../store/mutation-types' import { USER_INFO } from '../../store/mutation-types'
import { getPrintPostContactByMailId } from '../../api/incomePaymentsApi' import { getPrintPostContactByMailId } from '../../api/incomePaymentsApi'
import AImg from './bg.jpg'
export default { export default {
name: 'PrintPage', name: 'PrintPage',
data() { data() {
return { return {
AImg,
// 邮寄项目信息 // 邮寄项目信息
mailDetail: {}, mailDetail: {},
// 用户信息 // 用户信息
userInfo: {}, userInfo: {},
// 当前时间 8 寄件人签署 处需要
currentTime: `${new Date().getFullYear()} ${new Date().getMonth() + 1} ${new Date().getDate()}`,
sendCompanyName: '', sendCompanyName: '',
sendAddress: '', sendAddress: '',
sendPostCode: '', sendPostCode: '',
@@ -94,17 +104,19 @@ export default {
// 将整体dom替换为需要打印的部分 // 将整体dom替换为需要打印的部分
window.document.body.innerHTML = printDom window.document.body.innerHTML = printDom
// 调用页面的打印方法打印整个页面 // 调用页面的打印方法打印整个页面
window.print() // window.print()
// 恢复原页面显示 // 恢复原页面显示
window.document.body.innerHTML = oldDom // window.document.body.innerHTML = oldDom
// 关闭本标签页 // 关闭本标签页
window.close() // window.close()
} }
} }
} }
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@page-top: 12pt;
@page-left: 5pt;
.sheet-box { .sheet-box {
position: relative; position: relative;
font-size: 10px; font-size: 10px;
@@ -123,32 +135,34 @@ export default {
.sendName { .sendName {
position: absolute; position: absolute;
left: 57pt; left: calc(57pt + @page-left);
top: 74pt; top: calc(74pt + @page-top);
} }
.sendPhone { .sendPhone {
position: absolute; position: absolute;
top: 74pt; left: calc(181pt + @page-left);
left: 181pt; top: calc(74pt + @page-top);
} }
.sendCompanyName { .sendCompanyName {
position: absolute; position: absolute;
left: 65pt; left: calc(65pt + @page-left);
top: 94pt; top: calc(94pt + @page-top);
} }
.sendCode { .sendCode {
position: absolute; position: absolute;
left: 236pt; left: calc(236pt + @page-left);
top: 96pt; top: calc(96pt + @page-top);
} }
.sendAddress { .sendAddress {
position: absolute; position: absolute;
left: 48pt; //left: 48pt;
top: 110pt; //top: 110pt;
left: calc(60pt + @page-left);
top: calc(110pt + @page-top);
width: 236pt; width: 236pt;
word-break: break-all; word-break: break-all;
white-space: pre-wrap; white-space: pre-wrap;
@@ -156,22 +170,29 @@ export default {
.sendPostNo { .sendPostNo {
position: absolute; position: absolute;
left: 64pt; //left: 64pt;
top: 135pt; //top: 135pt;
left: calc(64pt + @page-left);
top: calc(135pt + @page-top);
} }
.sendPostCode { .sendPostCode {
position: absolute; position: absolute;
left: 218pt; //left: 218pt;
top: 137pt; //top: 137pt;
left: calc(218pt + @page-left);
top: calc(137pt + @page-top);
font-size: 16px; font-size: 16px;
letter-spacing: 8.3pt; letter-spacing: 8.3pt;
} }
.arriveName { .arriveName {
position: absolute; position: absolute;
left: 53pt; //left: 53pt;
top: 163pt; //top: 163pt;
left: calc(53pt + @page-left);
top: calc(163pt + @page-top);
word-break: break-all; word-break: break-all;
white-space: pre-wrap; white-space: pre-wrap;
width: 97pt; width: 97pt;
@@ -179,14 +200,18 @@ export default {
.arrivePhone { .arrivePhone {
position: absolute; position: absolute;
top: 163pt; //top: 163pt;
left: 183pt; //left: 183pt;
left: calc(183pt + @page-left);
top: calc(163pt + @page-top);
} }
.arriveCompanyName { .arriveCompanyName {
position: absolute; position: absolute;
left: 66pt; //left: 66pt;
top: 180pt; //top: 180pt;
left: calc(66pt + @page-left);
top: calc(180pt + @page-top);
width: 138pt; width: 138pt;
word-break: break-all; word-break: break-all;
white-space: pre-wrap; white-space: pre-wrap;
@@ -194,14 +219,18 @@ export default {
.arriveCode { .arriveCode {
position: absolute; position: absolute;
left: 240pt; //left: 240pt;
top: 180pt; //top: 180pt;
left: calc(240pt + @page-left);
top: calc(180pt + @page-top);
} }
.arriveAddress { .arriveAddress {
position: absolute; position: absolute;
left: 48pt; //left: 48pt;
top: 195pt; //top: 195pt;
left: calc(58pt + @page-left);
top: calc(195pt + @page-top);
width: 270pt; width: 270pt;
word-break: break-all; word-break: break-all;
white-space: pre-wrap; white-space: pre-wrap;
@@ -209,15 +238,52 @@ export default {
.arriveCity { .arriveCity {
position: absolute; position: absolute;
left: 69pt; //left: 69pt;
top: 243pt; //top: 243pt;
left: calc(69pt + @page-left);
top: calc(243pt + @page-top);
} }
.arrivePostNo { .arrivePostNo {
position: absolute; position: absolute;
left: 218pt; //left: 218pt;
top: 243pt; //top: 243pt;
left: calc(218pt + @page-left);
top: calc(243pt + @page-top);
font-size: 16px; font-size: 16px;
letter-spacing: 8.3pt; letter-spacing: 8.3pt;
} }
// 备注
.remark{
position: absolute;
left: calc(460pt + @page-left);
top: calc(273pt + @page-top);
font-size: 14px;
line-height: 20px;
//letter-spacing: 0pt;
width: 120pt;
}
// 内部品名
.inner-info-name{
position: absolute;
left: calc(63pt + @page-left);
top: calc(292pt + @page-top);
word-break: break-all;
white-space: pre-wrap;
}
// 寄件人签署 - 签名
.other-send-name{
position: absolute;
font-size: 14px;
left: calc(475pt + @page-left);
top: calc(148pt + @page-top);
}
.send-time{
position: absolute;
font-size: 14px;
left: calc(450pt + @page-left);
top: calc(168pt + @page-top);
white-space: pre;
}
</style> </style>