vue页面:
<template>
<div class="showbox">
<!-- 表单查看 -->
<div class="top_main" id="a">
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item >调查任务</el-breadcrumb-item>
<el-breadcrumb-item >调查详情</el-breadcrumb-item>
<el-breadcrumb-item >查看表单</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="main_box">
<div class="btn_main">
<div>调查表单</div>
<div>
<el-button class="styleBtn" id="btnWord" type="primary" @click="btnWord">导出word</el-button>
<el-button class="styleBtn" type="primary" @click="close">返回</el-button>
</div>
</div>
<!-- 填写表单 -->
<div class="from_main">
<iframe ref="iframe" id="iframe" name="iframe" style=" width: 100%;height: 800px;" :src="fromUrl" > </iframe>
</div>
</div>
</div>
</template>
<script>
import '../../../static/js/jquery-1.11.1.min'
import saveAs from 'file-saver';
import '../../../static/js/FileSaver'
import '../../../static/js/jquery.wordexport'
import {mapGetters} from 'vuex'
// import saveAs from "file-saver"
// import '@/components/FileSaver';
// import '@/components/jquery-1.11.1.min';
// import '@/components/jquery.wordexport';
// import axios from "axios";
var config = require('@/components/utils/Common_Config.js');
var Cookies =require("js-cookie");
export default{
data(){
return {
fromsId:'',
fromUrl:'',
outData: {},
myUrl:"",
}
},
computed:{
...mapGetters(['location'])
},
methods:{
close(){
console.log("要返回这个页面:"+this.location)
this.$router.push({path: this.location});//跳到列表页
// this.$router.go(-1);
},
// btnWord() {
// var obj = document.getElementById("iframe").contentWindow;
// alert(obj.document.getElementById("dwSurveyName").innerText)
// // alert(obj.document.getElementById("dw_body_content").innerHTML)
// console.log(obj.document.getElementById("dw_body_content").innerHTML)
// // alert(obj.document.getElementById("dwSurveyName").value)
// // console.log(obj.document.getElementById("dwSurveyName").innerText)
// var fileName = obj.document.getElementById("dwSurveyName").innerText
// var content = obj.document.querySelector("dw_body_content")
// var that = this;
// axios.post(config.apiHost + "/exportWord/makeCaseDoc",{
// fileName: fileName,
// content: content
// }).then((res)=>{
// if (res.data.status == 200) {
// window.open(res.data.body.completeSavePath,'_blank')
// } else {
// that.$message.error(res.data.body.message);
// }
// });
// }
btnWord() {
alert(jQuery.fn.jquery);
// alert($('#a').wordExport)
// console.log($('#a').wordExport)
// $('#a').wordExport("标题")
var obj = document.getElementById("iframe").contentWindow;
var fileName = obj.document.getElementById("dwSurveyName").innerText;
// obj.document.getElementById("dw_body_content").wordExport(fileName ,'');
console.log(obj.$("#dw_body_content"))
console.log('word77',obj.$("#dw_body_content").wordExport)
// window.open(obj.$("#dw_body_content").context.URL, '_blank')
// obj.$("#dw_body_content").wordExport(fileName)
var obj2 = obj.$("#dw_body_content")
console.log('obj:',obj2)
console.log('obj函数:',obj2.wordExport)
// obj.$("#dw_body_content").wordExport(fileName)
obj2.wordExport(fileName)
},
},
created(){
// console.log("输出表单Id");
this.formId=this.$route.params.formId;
this.eventId=this.$route.params.eventId;
this.caseType=this.$route.params.caseType;
this.caseId=this.$route.params.caseId;
// http://192.168.1.169:8020/cdcform
this.fromUrl=config.apiUrl+ "preview_answer.html?formId="+this.formId+"&eventId="+this.eventId+"&caseType="+this.caseType+"&caseId="+this.caseId+"&token="+Cookies.get('token');
// console.log(this.fromsId);
console.log('vuex',this.$store);
console.log('route',this.$route);
}
}
</script>