123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <!-- 原项目丢了 省事直接cv一下老项目代码 -->
- <template>
- <div class="wrapper" ref="wrapper" id="pdf-container">
- <div id="reportdtl" v-if="isshow" :style="{backgroundColor:reportInfo.CanvasColor}">
- <div>
- <div class="html-head-img-box" v-if="reportInfo && !!reportInfo.NeedSplice && reportInfo.HeadImg">
- <img :src="reportInfo.HeadImg" alt="" style="display:block;width:100%">
- <div class="head-layout-item" v-for="item in headImgStyle" :key="item.value"
- :style="{fontFamily:item.family,fontSize:(item.size*2)+'px',fontWeight:item.weight,textAlign:item.align,color:item.color,
- width:item.width,height:item.height,left:item.left,top:item.top
- }">
- {{ layoutBaseInfo[item.value] }}
- </div>
- </div>
- <div class="no-layout-img-box" v-if="reportInfo && !!reportInfo.NeedSplice && (!reportInfo.HeadImg) && (!reportInfo.EndImg)">
- <header>{{reportInfo.Title}}</header>
- <div style=" box-sizing:border-box; color:#666; font-size:24px; overflow:hidden;">
- <span>{{ reportInfo.Author}}</span>
- <span style="float:right;">{{reportInfo.CreateTime}}</span>
- </div>
- </div>
- <div class="abstract" v-if="reportInfo && !!reportInfo.NeedSplice">
- <div>摘要: <span v-html="reportInfo.Abstract"></span></div>
- </div>
- <div id="resetcss" style="overflow:hidden;" v-html="reportInfo.Content"></div>
- <div class="html-end-img-box" v-if="reportInfo && !!reportInfo.NeedSplice && reportInfo.EndImg">
- <img :src="reportInfo.EndImg" alt="" style="display:block;width:100%">
- <div class="head-layout-item" v-for="item in endImgStyle" :key="item.value"
- :style="{fontFamily:item.family,fontSize:(item.size*2)+'px',fontWeight:item.weight,textAlign:item.align,color:item.color,
- width:item.width,height:item.height,left:item.left,top:item.top
- }">
- {{ layoutBaseInfo[item.value] }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { smartReportDetail } from "@/api/api.js";
- export default {
- data() {
- return {
- id: this.$route.query.code || "",
- isshow: false,
- /**
- * NeedSplice 0-不需要 1-需要
- */
- reportInfo: {},
- headImgStyle:null,//版头style
- endImgStyle:null,//版尾style
- layoutBaseInfo:{
- 研报标题:'',
- 研报作者:'',
- 创建时间:''
- }
- };
- },
- mounted() {
- this.getreportdetail();
- window.addEventListener('resize',this.pageResize)
- },
- destroyed() {
- window.removeEventListener('resize',this.pageResize)
- },
- methods: {
- pageResize(){
- const el=document.getElementById('reportdtl')
- const windowWid=document.body.clientWidth
- if(windowWid<800){
- el.style.transform=`scale(${windowWid/800})`
- // el.style.
- }
- },
- async getreportdetail() {
- const { Data, Ret } = await smartReportDetail({ ReportCode: this.id });
- if (Ret !== 200) return;
-
- this.reportInfo = Data.Report;
- this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
- this.headImgStyle.map(st =>{
- st.value=st.value || st.label
- })
- this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
- this.endImgStyle.map(st =>{
- st.value=st.value || st.label
- })
- this.layoutBaseInfo['研报标题']=this.reportInfo.Title
- this.layoutBaseInfo['研报作者']=this.reportInfo.Author
- this.layoutBaseInfo['创建时间']=this.reportInfo.CreateTime
- this.reportInfo.Content=this.setReportContent(this.reportInfo.Content)
- this.isshow = true;
- this.$nextTick(()=>{
- this.pageResize()
- })
- },
- setReportContent(str){
- let ps = str.split('</iframe>')
- let returnStr=''
- for (let i = 0; i < ps.length; i++) {
- const itp = ps[i];
- if(itp.indexOf('chartshow')!=-1){
- returnStr+=itp.replace('<iframe','<eta-chart class="no-wrap"')+'</iframe>'
- }else if(itp.indexOf('sheetshow')!=-1){
- returnStr+=itp.replace('<iframe','<eta-table class="no-wrap"')+'</iframe>'
- }else{
- returnStr+=itp
- }
- }
- return returnStr
- },
- },
- };
- </script>
- <style lang="scss">
- body{
- line-height: normal;
- }
- .wrapper {
- position: relative;
- height: 100%;
- #noaccess {
- width: 100%;
- height: 12rem;
- padding: 5rem 0.6rem 1rem;
- box-sizing: border-box;
- text-align: center;
- position: absolute;
- bottom: 0;
- background: url(~@/assets/img/accessbg.png) no-repeat;
- background-size: 100% auto;
- overflow: hidden;
- > a,
- button {
- width: 12rem;
- height: 2rem;
- background: url(~@/assets/img/newbtn600.png) no-repeat;
- background-size: 100% 100%;
- font-size: 0.48rem;
- color: #fff;
- border: none;
- margin-top: 1.5rem;
- }
- }
- }
- #reportdtl {
- font-size: 14px;
- background: #fff;
- overflow: auto;
- width: 800px;
- padding: 20px 20px 20px 44px;
- margin: 0 auto;
- .top-header {
- background-image: url("@/assets/img/smart_report_bg01.png");
- background-size: cover;
- background-repeat: no-repeat;
- background-position: center;
- padding: 16px;
- color: #fff;
- .title {
- font-size: 16px;
- margin-bottom: 10px;
- }
- .flex {
- font-size: 12px;
- display: flex;
- justify-content: space-between;
- }
- }
- .html-head-img-box,.html-end-img-box{
- position: relative;
- .head-layout-item{
- position: absolute;
- overflow: hidden;
- box-sizing: border-box
- }
- }
- .no-layout-img-box{
- header{
- padding:10px 0; box-sizing:border-box; font-size:28px; font-weight:500; color:#333; background:#fff;
- }
- }
- .abstract{
- padding:10px 0; box-sizing:border-box; font-size:22px; line-height:36px;
- div{
- padding: 10px 20px;
- box-sizing: border-box;
- background: rgba(20, 121, 253, 0.1);
- color: #4099ef;
- border-radius: 10px;
- }
- }
- #resetcss {
- pre {
- white-space: pre-wrap;
- }
- .report-drag-item-wrap{
- padding: 6px;
- margin-bottom: 3px;
- }
- }
- }
- @media screen and (max-width:800px){
- #reportdtl{
- position: absolute;
- transform-origin: 0 0;
- }
- }
- // 不禁止页面打印,不然转pdf会出现空白页
- @media print{
- body{
- display: unset;
- }
- }
- </style>
|