You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
3.9 KiB

<template>
<div >
2 years ago
<!-- <div style="width: 100%;height: 100%">
<iframe class="iframe"
:src="srcHtml"
frameborder="0"
ref="iframes"
style="width: 100%;height: 100%"
>
</iframe>
2 years ago
</div>-->
<button @click="goPreview">点击预览word文件</button>
2 years ago
<div class="docWrap">
<!-- 预览文件的地方用于渲染 -->
<div ref="file"></div>
</div>
</div>
2 years ago
</template>
<script>
2 years ago
const VALIDATE_NO_PASSED = Symbol()
import pick from 'lodash.pick'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
2 years ago
import { getAction,downFile} from '@/api/manage';
let docx = require("docx-preview");
export default {
2 years ago
name: "ProcessMaterialPlan",
mixins:[JeecgListMixin,mixinDevice],
props:{
materWared:{
type: String,
2 years ago
},
/**/
procInstId: {
type: String,
default: '',
2 years ago
required: false
2 years ago
},
pictureId: {
type: String,
default: '',
2 years ago
required: false
2 years ago
},
lcModa: {
type: Object,
required: false
}
},
2 years ago
data(){
return{
showSessionId : '',
srcHtml : '',
url:{
2 years ago
list: "/hy/processUdgetPlan/getPlanTable",
2 years ago
queryPlanApply:'/word/queryPlanApply'
},
2 years ago
Wslist: null,
}
},
mounted() {
this.showSessionId = window.location.search;
2 years ago
this.srcHtml = '../static/采购申请表.html';
2 years ago
// this.sendMesFroIframe();
},
created() {
2 years ago
this.goPreview();
// this.loadData();
},
2 years ago
activated() {
2 years ago
2 years ago
},
beforeMount() {
2 years ago
},
computed: {
importExcelUrl: function(){
return `${window._CONFIG['domianURL']}/${this.url.queryPlanApply}`;
}
},
methods:{
2 years ago
// //方法:
// async sendMesFroIframe() {
// await this.loadData();
// let a = this.Wslist
// console.log("执行了>>>>>>>>>>>>>>>>>>>>>>>",this.queryParam);
//
//
// const mapFrame = this.$refs['iframes']
// if (mapFrame.attachEvent) { // 兼容浏览器判断
// mapFrame.attachEvent('onload', function() {
// const iframeWin = mapFrame.contentWindow
// iframeWin.postMessage(a, '*')
// // data传递的参数 *写成子页面的域名或者是ip
// })
// } else {
// mapFrame.onload = function() {
// const iframeWin = mapFrame.contentWindow
// iframeWin.postMessage(a, '*')
// }
// }
//
// },
// 预览
goPreview() {
downFile('/word/queryPlanApply', {id:this.queryParam.id }).then((data) => {
console.log(data)
docx.renderAsync(data,this.$refs.file)
})
},
2 years ago
loadData() {
return new Promise((resolve, reject) => {
if(!this.url.list){
this.$message.error("请设置url.list属性!")
return
}
2 years ago
console.log("KLJKLJKLJKLJKL",this.materWared);
this.queryParam.id = this.materWared;
getAction(this.url.list, this.queryParam).then((res) => {
console.log(res);
if (res.success) {
2 years ago
this.Wslist = res.result;
console.log("this.Wslist>>>>>>>>>>>>>>>>>>>>>>>>>>>>", res.result)
}
if(res.code===510){
this.$message.warning(res.message)
}
this.loading = false;
resolve( this.Wslist );
})
})
},
}
}
</script>
<style scoped>
2 years ago
.docWrap {
width: 100%;
height: 100%;
overflow-x: auto;
}
.iframe {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
background: #fff;
overflow-y: hidden;
}
</style>