<template> <div> <el-dialog v-dialogDrag title="报文展示" :visible.sync="messageVisible" width="60%" @close="handleCloseMessage" destroy-on-close :modal-append-to-body="false" v-if="messageVisible"> <div class="contentTable"> <el-table :data="messageData" style="width: 100%"> <el-table-column prop="docfil" label="报文标识号" width="140" :show-overflow-tooltip="true" fixed="left"> </el-table-column> <el-table-column prop="extkey" label="业务编号" :show-overflow-tooltip="true" width="120"> </el-table-column> <el-table-column prop="docpth" label="报文路径" :show-overflow-tooltip="true" width="120"> </el-table-column> <el-table-column prop="nam" label="报文描述" :show-overflow-tooltip="true" width="120"> </el-table-column> <el-table-column prop="sndkey" label="收报行" :show-overflow-tooltip="true" width="120"> </el-table-column> <el-table-column prop="cortyp" label="报文类型" width="120"> </el-table-column> <el-table-column prop="credattim" label="收报时间" :show-overflow-tooltip="true" width="120"> </el-table-column> <c-table-column fixed="right" prop="op" label="操作" width="220px"> <template slot-scope="{ scope }"> <el-button type="primary" @click="showMsg(scope.row)">show</el-button> </template> </c-table-column> </el-table> </div> </el-dialog> <!-- 报文 --> <message-view ref="msgView"></message-view> </div> </template> <script> import Api from "~/service/Api"; import MessageView from "~/components/business/docpan/views/MessageView"; export default { props: { visible: { type: Boolean, default: false } }, components:{MessageView}, data() { return { messageVisible: false, messageData: [], modelVisible: false, opType: "", }; }, methods: { async init() { let params = {} if(this.$route.query.businessType==='TRN'){ params.trninr=this.$route.query.businessInr; } if(this.$route.query.businessType==='SPT'){ params.sptinr=this.$route.query.businessInr; } let res = await Api.post("/public/quesel/showSmhList", params); if (res.respCode == SUCCESS) { // 一条直接展示多条展示列表 if (res.data.smhList.length == 1) { this.messageVisible = false; this.$nextTick(()=>{ this.$refs.msgView.fileViewDispaly(-1,{smhinr:res.data.smhList[0].inr}) }) }else{ this.messageVisible = true; this.messageData = res.data.smhList; } } }, async showMsg(row) { this.$refs.msgView.fileViewDispaly(-1,{smhinr:row.inr}) }, viewPdf(content) { if (!content) { console.log(content); this.$message.error("暂无报文"); return; } const blob = this.base64ToBlob(content); if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob); } else { const fileURL = URL.createObjectURL(blob); this.viewPdfUrl = fileURL; } }, base64ToBlob(code) { code = code.replace(/[\n\r]/g, ""); const raw = window.atob(code); const rawLength = raw.length; const uInt8Array = new Uint8Array(rawLength); for (let i = 0; i < rawLength; ++i) { uInt8Array[i] = raw.charCodeAt(i); } return new Blob([uInt8Array], { type: "application/pdf" }); }, handleCloseMessage() { this.$emit("onClose"); }, onClose() { this.modelVisible = false; } } }; </script> <style scoped lang="less"> </style>