<template>
|
<div class="docWrap">
|
<!-- 预览文件的地方(用于渲染) -->
|
<div ref="word"></div>
|
</div>
|
</template>
|
|
<script>
|
import {viewD, exportDoc, urlToBase64, viewWithImg, exportDocWidthImg} from "@/libs/word"
|
|
export default {
|
components: {},
|
data() {
|
return {
|
dataForm: {},
|
imgList: []
|
};
|
},
|
created() {
|
console.log(this.$route.query,'this.$route======')
|
if (this.$route.query) {
|
if(this.$route.query.wordData){
|
// this.dataForm = this.$route.query.wordData
|
this.$nextTick(() => {
|
viewD(this.$route.query.wordData, this.$route.query.src,this.$refs.word)
|
})
|
}else {
|
// this.dataForm = this.$route.query.dawordData
|
this.$nextTick(() => {
|
exportDoc(this.$route.query.wordData, this.$route.query.src,this.$route.query.name);
|
this.$router.push({
|
path: '/pad',
|
})
|
})
|
}
|
}
|
|
},
|
methods: {
|
/*initMS(obj, url, arry, imgSize) { //行政处罚没收财物处理审批表返回的数据和其它表不一样(没有publicOpinion对象)
|
let that = this
|
if (arry.length > 0) {
|
for (let i = 0; i < arry.length; i++) {
|
urlToBase64(obj[arry[i]], function (baseStr) {
|
obj[arry[i]] = baseStr
|
that.$set(obj, arry[i], obj[arry[i]])
|
})
|
}
|
setTimeout(() => {
|
viewWithImg(obj, url, this.$refs.word, imgSize);
|
}, 1000)
|
}
|
},*/
|
initMore(obj, url, arry, imgSize) { //页面有多张签名照片的
|
let that = this
|
if (arry.length > 0) {
|
for (let i = 0; i < arry.length; i++) {
|
if (obj.publicOpinion) {
|
urlToBase64(obj.publicOpinion[arry[i]], function (baseStr) {
|
obj.publicOpinion[arry[i]] = baseStr
|
that.$set(obj, arry[i], obj.publicOpinion[arry[i]])
|
})
|
}
|
}
|
setTimeout(() => {
|
viewWithImg(obj, url, this.$refs.word, imgSize);
|
}, 1000)
|
}
|
},
|
init(obj, url, type, imgSize) { //页面只有一处有照片回显的(包含一处有多张图片)
|
if (type != null && type != '' && type != undefined) {
|
// let aabb = "http://localhost:8080/admin/sys-file/platform/75968ac641154184bce1a1c38b486291.png"
|
if (obj[type] != '') {
|
let img = obj[type].split(',')
|
let that = this;
|
let imgList = []
|
for (let i = 0; i < img.length; i++) {
|
urlToBase64(img[i], function (baseStr) {
|
img[i] = baseStr;
|
imgList.push({
|
img: img[i]
|
})
|
})
|
that.$set(obj, 'imgList', imgList)
|
}
|
setTimeout(() => {
|
viewWithImg(obj, url, that.$refs.word, imgSize);
|
}, 1000)
|
} else {
|
viewD(obj, url, this.$refs.word);
|
}
|
} else {
|
viewD(obj, url, this.$refs.word);
|
}
|
|
},
|
exportDocMS(obj, url, name, arry, imgSize) { //行政处罚没收财物处理审批表返回的数据和其它表不一样(没有publicOpinion对象)
|
let that = this
|
if (arry.length > 0) {
|
for (let i = 0; i < arry.length; i++) {
|
urlToBase64(obj[arry[i]], function (baseStr) {
|
obj[arry[i]] = baseStr
|
that.$set(obj, arry[i], obj[arry[i]])
|
})
|
}
|
}
|
setTimeout(() => {
|
exportDocWidthImg(obj, url, name, imgSize)
|
}, 1000)
|
},
|
exportDocMore(obj, url, name, arry, imgSize) { //页面有多张签名照片的
|
let that = this
|
if (arry.length > 0) {
|
for (let i = 0; i < arry.length; i++) {
|
if (obj.publicOpinion) {
|
urlToBase64(obj.publicOpinion[arry[i]], function (baseStr) {
|
obj.publicOpinion[arry[i]] = baseStr
|
that.$set(obj, arry[i], obj.publicOpinion[arry[i]])
|
})
|
}
|
}
|
}
|
setTimeout(() => {
|
exportDocWidthImg(obj, url, name, imgSize)
|
}, 1000)
|
},
|
exportDoc(obj, url, name, type, imgSize) {
|
this.imgList = []
|
let that = this
|
if (type != null && type != '') {
|
let img = obj[type].split(',')
|
for (let i = 0; i < img.length; i++) {
|
urlToBase64(img[i], function (baseStr) {
|
img[i] = baseStr;
|
that.imgList.push({
|
img: img[i]
|
})
|
})
|
that.$set(obj, 'imgList', that.imgList)
|
// exportDocWidthImg(obj,url,name,imgSize);
|
}
|
|
setTimeout(() => {
|
exportDocWidthImg(obj, url, name, imgSize)
|
}, 1000)
|
// await exportDocWidthImg(obj,url,name,imgSize);
|
} else {
|
exportDoc(obj, url, name);
|
}
|
|
},
|
}
|
};
|
</script>
|
|
<style>
|
.docx-wrapper {
|
background: white !important;
|
}
|
|
.docx p {
|
text-align: center;
|
}
|
|
.docx p:nth-child(0) > span:nth-child(3) {
|
margin-left: -45px;
|
}
|
</style>
|