<template>
  <el-dialog class="common-dialog" :title="title" :modal="false" top="2vh" :visible.sync="diaShow" @close="coloseDia"
    :width="width">
    <div slot="title">
      <span class="el-dialog__title">{{title}}</span>
      <slot name="searchtype"></slot>
    </div>

    <div class="dialogConcent" :style="{height:wheight+'px'}">
      <iframe id="iframeWin" :src="baseUrl+url" frameborder="0" scrolling="auto" align="center" class="iframeWeb">
      </iframe>
    </div>

    <div slot="footer" class="dialog-footer">
      <el-button @click="coloseDia">关 闭</el-button>
      <slot name="footerbtn"></slot>
    </div>
  </el-dialog>

</template>

<script>
  export default {
    props: {
      title: {
        type: String,
        default: "文件预览"
      },
      width: {
        type: String,
        default: "60%"
      },
      isShow: {
        type: Boolean,
        default: () => {
          return false
        }
      },
      type: {
        type: String,
        default: "showinfo"
      },
      url: {
        type: String,
        default: ""
      }
    },
    data() {
      return {
        diaShow: this.isShow,
        baseUrl: "http://192.168.60.24:8012/onlinePreview?url=",
        wheight: ""
      }
    },
    watch: {
      url() {

        this.wheight = document.documentElement.clientHeight * .7;
      },
      isShow(val) {
        this.diaShow = this.isShow;
      }
    },
    methods: {
      coloseDia() {
        this.url = ""
        this.$emit('update:isShow', false)
        this.$emit('resetform');

      }
    }
  }
</script>

<style>
  .dialogConcent {
    overflow-y: hidden;
  }

  .iframeWeb {
    text-align: center;
    border: none;
    display: block;
    height: 100vh;
    width: 100%;
  }
</style>
