PlmPicModal.vue 3.15 KB
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
    <iframe v-for="(item, index) in picUrl" style="width: 400px;height: 600px;display: none" :src="item"></iframe>

    <!--    <vue-qr v-for="(url, index) in qrCodeList" :text="url" :size="120" :margin="0" style="position: relative;-->
    <!--    top: -52vh;"></vue-qr>-->
    <!--    -->
    <!--    -->
    <!--    <iframe v-for="(url, index) in picUrl2" :src="url" :key="url" :ref="'myIframe'+index"-->
    <!--            style="width: 450px;height: 600px;margin-left: 10px"></iframe>-->
    <div class="ant-modal-body">
      <div v-for="(item, index) in picAll" style="display: flex">
        <div>
          <p style="text-align: center;font-weight: 600;color: black;font-size: 20px">{{ item.name }}</p>
          <vue-qr :text="item.qrCode" :size="120" style="margin-top: -15px;
    margin-right: -22px;
    /* left: -3px; */
    width: 177px;
    height: 196px;
    display: inline-block;"></vue-qr>
        </div>


        <iframe :src="item.url" :key="item.url" :ref="'myIframe'+index"
                style="width: 450px;height: 600px;margin-left: 10px"></iframe>
      </div>
    </div>


  </j-modal>
</template>

<script>
import QRCode from 'qrcodejs2' // 引入qrcode
// import QrcodeVue from 'qrcode.vue'
import VueQr from 'vue-qr'

export default {
  name: 'PlmPicModal',
  components: {
    QRCode,
    VueQr
  },
  data() {
    return {
      title: '',
      width: 1800,
      picUrl: [],
      picUrl2: [],
      picAll: [],
      visible: false,
      disableSubmit: false
    }
  },
  mounted() {
    // 获取指定的iframe元素
    // 判断iframe是否成功加载页面了
    this.picUrl = [];
    this.picUrl2 = [];
    this.picAll = [];
  },
  methods: {
    edit(picUrl, picUrl2, picAll) {
      this.$message.loading("图纸加载中....")
      this.picUrl = [];
      this.picUrl = picUrl;
      this.picUrl2 = [];
      this.picUrl2 = picUrl2;
      this.picAll = [];
      this.picAll = picAll;
      this.visible = true;
      let timeSearch = setTimeout(() => {
        for (let i = 0; i <= this.picUrl2.length; i++) {
          console.log('aaaaaaaaaaaa:')
          const iframeRefName = 'myIframe' + i;
          const myIframe = this.$refs[iframeRefName][0];
          console.log(myIframe)
          if (myIframe != undefined) {
            myIframe.contentWindow.location.reload(true);
          }
          // if (i = this.picUrl2.length - 1) {
          //   clearInterval(timeSearch);
          // }
        }
        //clearInterval(timeSearch);

      }, 1000)

    },
    close() {
      this.$emit('close');
      this.visible = false;
    },
    handleOk() {
      this.$refs.realForm.submitForm();
    },
    submitCallback() {
      this.$emit('ok');
      this.visible = false;
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>
<style lang="less" scoped>
.ant-modal-body {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-content: space-around;
}
</style>