Commit 5ca35fda by 李少勇

配合联调报文面函的word文件预览问题

parent 95137887
This source diff could not be displayed because it is too large. You can view the blob instead.
<template> <template>
<div> <div class="width: 100%;height: 100vh;overflow: auto;" ref="file"></div>
<div style="height: 800px; overflow: auto">
<embed
v-if="this.model.docXML && pdf"
:src="pdf"
type="application/pdf"
height="100%"
width="100%"
/>
<c-row v-if="!this.model.docXML">
<c-col v-for="(item, index) in model.docTXT" :key="index" >
<c-col :offset="4" :span="8">
{{ item[0] }}
</c-col>
<c-col :span="12">
{{ item[1] }}
</c-col>
</c-col>
</c-row>
</div>
</div>
</template> </template>
<script> <script>
import { getPdf } from "~/service/business/file"; import { renderAsync } from 'docx-preview';
import Api from '~/service/Api';
import commonProcess from '~/mixin/commonProcess';
export default { export default {
data() { data() {
return { return {
model: { docXML: "" }, model: { docXML: '' },
pdf: "", pdf: '',
}; };
}, },
created() { mixins: [commonProcess],
let doclang= window.sessionStorage.doclang||""; mounted() {
this.model.docXML = window.sessionStorage.docXML; this.loadWordBlob()
this.model.docTXT = window.sessionStorage.docTXT },
.split("\r\n") methods: {
.filter((item) => item) async loadWordBlob () {
.map((item) => { let routeQuery = this.$route.query
let idx = item.indexOf(":"); const params = {
return [ index: routeQuery.idx,
item.substring(0, idx).trim(), };
item.substring(idx + 1).trim(), let res = await Api.post('/service/gitopn/executeDocpan', this.wrapper(params));
]; if (res.respCode == SUCCESS) {
}); let base64Str = res.data.executeDocpan;
if (this.model.docXML != "") let bstr = window.atob(base64Str); // 解码 base-64 编码的字符串,base-64 编码使用方法是 btoa()
getPdf({ xml: this.model.docXML, doclang: window.sessionStorage.docuil }).then((res) => { let length = bstr.length;
if (res.respCode == SUCCESS) { let u8arr = new Uint8Array(length); // 创建初始化为0的,包含length个元素的无符号整型数组
this.pdf ="data:application/pdf;base64,"+ res.data; while (length--) {
} u8arr[length] = bstr.charCodeAt(length); // 返回在指定的位置的字符的 Unicode 编码
}); }
}, let blob = new Blob([u8arr]);
renderAsync(blob, this.$refs.file)
}
}
}
}; };
</script> </script>
<style scoped> <style scoped>
</style> ::v-deep .docx-wrapper {
\ No newline at end of file width: 100%;
height: 100vh;
padding: 0;
overflow: auto;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment