
<template>
 <Modal v-model="modalflag" :width="currentWidth" :title="myConfig.title" :footer-hide="true" @on-visible-change="ondestroy">
    <div v-if="modalflag">
        <iframe ref="bill" :src="myConfig.url"  width="100%" :height="currentHeight"  allowtransparency="true"  @load="load"  frameborder="0" ></iframe>
    </div>
 </Modal>
</template>
<script>
import size from '@/components/base/size';
export default {
    name:'billbox',
    mixins: [size],
    data () {
        return {
            myConfig:{
                url:'',
                title:'',
                width:0.8,
                height:0.8,
                adjustHeight:0,
                onLoad:'',
                onDestroy:''
            },
            modalflag:false
        };
    },
    methods: {
        setConfig(config) {
            this.myConfig = Object.assign({},this.myConfig,config);
            this.setSizeConfig(this.myConfig);
        },
        show() {
            this.modalflag = true;
        },
        load() {
            if (this.myConfig.onLoad) {
                let iframe = this.$refs.bill.$el;
                this.myConfig.onLoad(iframe);
            }
        },
        ondestroy(value) {
            if (!value) {
                if (this.myConfig.onDestroy) {
                    this.myConfig.onDestroy(this.myConfig);
                }
            }
        },
        logout() {
            this.$store.dispatch('LogOut').then(() => {
                location.reload();  // 为了重新实例化vue-router对象 避免bug
            });
        },
        getUrl() {
            if (this.base.OmdUrl.memberid) {
                this.$el.setAttribute('src',this.base.OmdUrl.modulecode_99011502 + '&memberid='+this.base.OmdUrl.memberid);
            } else {
                this.logout();
            }
        }
    },
    mounted(){
        //this._setCustomHeight(this.clientHeight);
        //this._setCustomWidth(this.clientWidth);
    }
};

</script>