Commit 5ca35fda by 李少勇

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

parent 95137887
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -387,15 +387,8 @@ ...@@ -387,15 +387,8 @@
<c-col>&nbsp;</c-col> <c-col>&nbsp;</c-col>
<c-col :span="12" v-if="title != 'MT799'"> <c-col :span="12" v-if="title != 'MT799'">
<el-form-item <el-form-item label="地址修改" label-width="120px">
label="地址修改" <el-input type="textarea" v-model="dialog.adrblk" :rows="4" />
label-width="120px"
>
<el-input
type="textarea"
v-model="dialog.adrblk"
:rows="4"
/>
</el-form-item> </el-form-item>
</c-col> </c-col>
<c-col :span="12" v-else> <c-col :span="12" v-else>
...@@ -419,38 +412,28 @@ ...@@ -419,38 +412,28 @@
empty-text=" " empty-text=" "
max-height="430px" max-height="430px"
> >
<el-table-column label="报文类型" sortable> <el-table-column label="报文类型" sortable> </el-table-column>
</el-table-column> <el-table-column label="地址" sortable> </el-table-column>
<el-table-column label="地址" sortable> <el-table-column label="Authentication" sortable>
</el-table-column>
<el-table-column
label="Authentication"
sortable
>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
</c-col> </c-col>
<c-col v-if="title != 'MT799'" <c-col v-if="title != 'MT799'"
><el-form-item label="面函日期"> ><el-form-item label="面函日期">
<el-date-picker <el-date-picker type="date" v-model="dialog.docdat">
type="date"
v-model="dialog.docdat"
>
</el-date-picker </el-date-picker
></el-form-item> ></el-form-item>
</c-col> </c-col>
<c-col v-if="this.suppress!=true" <c-col v-if="this.suppress != true"
><el-form-item label="Contact" ><el-form-item label="Contact"
><el-input v-model="dialog.ptcnam" ><el-input v-model="dialog.ptcnam"
/></el-form-item> /></el-form-item>
</c-col> </c-col>
<c-col :span="22" v-if="this.suppress!=true" <c-col :span="22" v-if="this.suppress != true"
><el-form-item ><el-form-item
:label=" :label="
title == 'MT799' title == 'MT799' ? 'Sender to Rec. information' : 'Remark'
? 'Sender to Rec. information'
: 'Remark'
" "
> >
<div v-if="title == 'MT799'"> <div v-if="title == 'MT799'">
...@@ -470,41 +453,39 @@ ...@@ -470,41 +453,39 @@
</div> </div>
</el-form-item> </el-form-item>
</c-col> </c-col>
<c-col :span="2" v-if="this.suppress!=true"> <c-col :span="2" v-if="this.suppress != true">
<c-button size="mini" icon="el-icon-more"> </c-button> <c-button size="mini" icon="el-icon-more"> </c-button>
</c-col> </c-col>
</c-row> </c-row>
</el-form> </el-form>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<c-button type="primary" @click="saveDialog" <c-button type="primary" @click="saveDialog">确 定</c-button>
>确 定</c-button <c-button
> type="primary"
<c-button type="primary" @click="activateDialog" v-if="dialog.delflg=='D'" @click="activateDialog"
v-if="dialog.delflg == 'D'"
>应用</c-button >应用</c-button
> >
<c-button type="primary" @click="suppressDialog" v-else-if="dialog.lev=='1'||dialog.mliflg!=''" <c-button
type="primary"
@click="suppressDialog"
v-else-if="dialog.lev == '1' || dialog.mliflg != ''"
>禁用</c-button >禁用</c-button
> >
<c-button type="primary" @click="activateDialog" v-else <c-button type="primary" @click="activateDialog" v-else
>删除</c-button >删除</c-button
> >
<c-button @click="centerDialogVisible = false" <c-button @click="centerDialogVisible = false">取 消</c-button>
>取 消</c-button
>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<div ref="file"></div>
</div> </div>
</template> </template>
<script> <script>
import commonProcess from "~/mixin/commonProcess"; import commonProcess from '~/mixin/commonProcess';
import Api from "~/service/Api"; import Api from '~/service/Api';
import Utils from "~/utils/index";
import DocUtils from "~/utils/DocUtils";
let docx = require("docx-preview");
export default { export default {
inject: ['root'], inject: ['root'],
props: ['model', 'codes'], props: ['model', 'codes'],
...@@ -645,49 +626,8 @@ export default { ...@@ -645,49 +626,8 @@ export default {
width: 1000, width: 1000,
}); });
} else { } else {
// let url = rtnmsg.data.trnmod_trndoc_smh_docpth;
this.title = '面函'; this.title = '面函';
let viewurl = '/#/docpan/show'; let viewurl = '/#/docpan/show';
let XMLdata;
let base64Str = rtnmsg.data.executeDocpan;
let bstr = window.atob(base64Str); // 解码 base-64 编码的字符串,base-64 编码使用方法是 btoa()
let length = bstr.length;
let u8arr = new Uint8Array(length); // 创建初始化为0的,包含length个元素的无符号整型数组
while (length--) {
u8arr[length] = bstr.charCodeAt(length); // 返回在指定的位置的字符的 Unicode 编码
}
let blob = new Blob([u8arr]);
docx.renderAsync(blob, this.$refs.file);
let hrefUrl = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = hrefUrl;
a.download = 'fileName.docx'; // 下载后文件名
document.body.appendChild(a);
a.click(); // 点击下载
document.body.removeChild(a); // 下载完成移除元素
if (row.pandsc.startsWith('elcs.')) {
window.sessionStorage.docXML = '';
window.sessionStorage.docTXT = '';
rtnmsg.data.trnmod_trndoc_doceot[row.idx].doctxt.rows.forEach(
(element) => {
window.sessionStorage.docTXT += element + '\r\n';
}
);
} else if (row.pandsc == 'MT799') {
window.sessionStorage.docTXT = '';
XMLdata = rtnmsg.data.litbenl1blk;
} else {
//参考后台Doceot.butshw order=1000
let execution = 'P',
structure = 'l';
let attr = DocUtils.getDocAttribute(docnam, structure, execution);
console.log(attr);
window.sessionStorage.docTXT = '';
window.sessionStorage.docXML = rtnmsg.data[attr];
window.sessionStorage.docuil = doceot.docuil;
}
// console.log( window.sessionStorage.docTXT);
// console.log( window.sessionStorage.docXML);
window.open( window.open(
viewurl, viewurl,
'newwindow', 'newwindow',
......
<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 (this.model.docXML != "")
getPdf({ xml: this.model.docXML, doclang: window.sessionStorage.docuil }).then((res) => {
if (res.respCode == SUCCESS) { if (res.respCode == SUCCESS) {
this.pdf ="data:application/pdf;base64,"+ res.data; let base64Str = res.data.executeDocpan;
let bstr = window.atob(base64Str); // 解码 base-64 编码的字符串,base-64 编码使用方法是 btoa()
let length = bstr.length;
let u8arr = new Uint8Array(length); // 创建初始化为0的,包含length个元素的无符号整型数组
while (length--) {
u8arr[length] = bstr.charCodeAt(length); // 返回在指定的位置的字符的 Unicode 编码
}
let blob = new Blob([u8arr]);
renderAsync(blob, this.$refs.file)
}
}
} }
});
},
}; };
</script> </script>
<style scoped> <style scoped>
::v-deep .docx-wrapper {
width: 100%;
height: 100vh;
padding: 0;
overflow: auto;
}
</style> </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