<template>
        <div>
        <div v-if="!isdoc" style="height:600px;overflow:auto;">
                <pre>{{srcmsg}}</pre>
        </div>
        <div v-if="isdoc">
                <embed :src="realdocpath"  style="width:100%;height:600px;"/>
            </div> 
        </div>
</template>
<script>
import Api from "~/service/Api"

export default {
    props:['path'],
    data(){
        return {
            srcmsg:""
        }
    },
    methods:{
        async showDocOrMsg(){
            this.dialogOpen = true
            console.log(this.realdocpath)
            if(!this.isdoc)
            {
                //发出异步请求
                let msg = await Api.pget(this.realdocpath)
                this.srcmsg = msg 
            }
            
        }
    },
    computed:{
        isdoc(){
            if(this.path.endsWith(".pdf"))
                return true
            else
                return false
        },
        realdocpath(){
            return '/gjjs/files'+this.path
        },
        title(){
            if(this.isdoc)
                return "面函展示"
            else
                return "报文展示"
        }
    },
    mounted(){
         this.showDocOrMsg()
    },
    watch:{
        path(newValue,oldValue){
            if(newValue!=oldValue)
                this.showDocOrMsg()
        }
    },
    updated(){
        
    }
}
</script>