<template>
  <div>
    <ele-modal
      :visible.sync="showEditFlag"
      :close-on-click-modal="false"
      custom-class="ele-dialog-form"
      append-to-body
      :fullscreen="true"
    >
      <browse :url="fileUrl"></browse
    ></ele-modal>
    <el-link type="primary" @click="open">{{ text }}</el-link>
  </div>
</template>

<script>
  import { getToken } from '@/utils/token-util';
  import { getJmPrintViewUrl } from './api.js';
  import browse from './browse.vue';

  export default {
    components: {
      browse
    },
    props: {
      text: {
        default: '打印预览'
      },
      businessId: {
        default: ''
      },
      businessCode: {
        default: ''
      }
    },
    data() {
      return {
        fileUrl: '',
        showEditFlag: false
      };
    },

    methods: {
      async open() {
        this.showEditFlag = true;
        let url = await getJmPrintViewUrl(this.businessCode);
        this.fileUrl = `${url}?token=${getToken()}&id=${this.businessId}`;
      }
    }
  };
</script>
<style scoped lang="scss"></style>
