|
|
@ -21,20 +21,21 @@ |
|
|
|
</div> |
|
|
|
<div class="main-content"> |
|
|
|
<div class="content-list">原文列表</div> |
|
|
|
<div class="content-right"> |
|
|
|
<div v-show="loading" class="well loading"> |
|
|
|
<div v-loading="loading" class="content-right"> |
|
|
|
<!-- <div v-show="loading" class="well loading"> |
|
|
|
正在加载中,请耐心等待... |
|
|
|
</div> |
|
|
|
<div v-show="!loading" id="printArea" ref="output" class="well-box" /> |
|
|
|
</div> --> |
|
|
|
<div id="printArea" ref="output" class="well-box" /> |
|
|
|
<div class="water-mask" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div></template> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getExtend, readBuffer, render } from '@/components/util' |
|
|
|
import { parse } from 'qs' |
|
|
|
import { timeFormate } from '@/utils/index' |
|
|
|
// import { timeFormate } from '@/utils/index' |
|
|
|
import { watermark } from '@/utils/waterMark' |
|
|
|
import html2canvas from 'html2canvas' // 转图片打印需要先安装html2Canvas和print-js |
|
|
|
import printJS from 'print-js' |
|
|
@ -56,7 +57,6 @@ export default { |
|
|
|
last: null, |
|
|
|
// 隐藏头部,当基于消息机制渲染,将隐藏 |
|
|
|
hidden: false, |
|
|
|
isOfd: false, |
|
|
|
printObj: { |
|
|
|
id: 'printArea', |
|
|
|
popTitle: '配置页眉标题', // 打印配置页上方的标题 |
|
|
@ -78,9 +78,10 @@ export default { |
|
|
|
// }, 2000) |
|
|
|
// }, |
|
|
|
standard: '', |
|
|
|
extarCss: '', |
|
|
|
watermarkInfo: null |
|
|
|
} |
|
|
|
extarCss: '' |
|
|
|
}, |
|
|
|
watermarkInfo: null, |
|
|
|
timer: null |
|
|
|
} |
|
|
|
}, |
|
|
|
created() { |
|
|
@ -119,16 +120,25 @@ export default { |
|
|
|
async handleChange(e) { |
|
|
|
this.loading = true |
|
|
|
try { |
|
|
|
clearTimeout(this.timer) |
|
|
|
const [file] = e.target.files |
|
|
|
const arrayBuffer = await readBuffer(file) |
|
|
|
this.loading = false |
|
|
|
|
|
|
|
this.last = await this.displayResult(arrayBuffer, file) |
|
|
|
this.$nextTick(() => { |
|
|
|
// 取得扩展名 |
|
|
|
const extend = getExtend(file.name) |
|
|
|
// 加水印 |
|
|
|
const maskDiv = document.getElementsByClassName('mask_div') |
|
|
|
// const imgMaskDiv = document.getElementsByClassName('water-mask') |
|
|
|
const imgMaskDiv = document.getElementsByClassName('weterbox') |
|
|
|
|
|
|
|
if (imgMaskDiv.length === 1) { |
|
|
|
document.getElementsByClassName('water-mask')[0].removeChild(imgMaskDiv[0]) |
|
|
|
} |
|
|
|
// docx-wrapper docx |
|
|
|
for (var j = maskDiv.length - 1; j >= 0; j--) { |
|
|
|
document.getElementsByClassName('water-mask')[0].removeChild(maskDiv[j]) |
|
|
|
} |
|
|
|
|
|
|
|
this.watermarkInfo = { |
|
|
|
'id': '9C5384EE889C0A977FC8F6', |
|
|
@ -138,25 +148,23 @@ export default { |
|
|
|
'context': '安全水印', |
|
|
|
'isEnable': true |
|
|
|
} |
|
|
|
// docx-wrapper docx |
|
|
|
for (var j = maskDiv.length - 1; j >= 0; j--) { |
|
|
|
document.getElementsByClassName('water-mask')[0].removeChild(maskDiv[j]) |
|
|
|
} |
|
|
|
|
|
|
|
if (!extend.includes('pdf')) { |
|
|
|
watermark({ watermark_txt: '徐华姣' + timeFormate() }, 'water-mask', 'text') |
|
|
|
// watermark({ watermark_txt: '徐华姣' + timeFormate() }, 'water-mask', 'text') |
|
|
|
// watermark({ watermark_txt: this.logo }, 'water-mask', 'img') |
|
|
|
// watermark({ |
|
|
|
// watermark_txt: this.watermarkInfo.context, |
|
|
|
// watermark_color: this.watermarkInfo.transparency, |
|
|
|
// watermark_fontsize: this.watermarkInfo.watermarkFont + 'px' |
|
|
|
// }, 'water-mask', 'text') |
|
|
|
watermark({ |
|
|
|
watermark_txt: this.watermarkInfo.context, |
|
|
|
watermark_color: this.watermarkInfo.transparency, |
|
|
|
watermark_fontsize: this.watermarkInfo.watermarkFont + 'px' |
|
|
|
}, 'water-mask', 'text') |
|
|
|
} |
|
|
|
}) |
|
|
|
} catch (e) { |
|
|
|
console.error(e) |
|
|
|
} finally { |
|
|
|
this.loading = false |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
this.loading = false |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
}, |
|
|
|
displayResult(buffer, file) { |
|
|
|