<template>
  <i-frame :src="url"/>
</template>

<script>
import { getToken } from '@/utils/auth'
import { getReportViewUrl } from '@/api/tool/jimu'
import iFrame from "@/components/iFrame/index.vue"

export default {
  name: "ReportView",
  components: {
    iFrame
  },
  data() {
    return {
      url: `http://${window.location.hostname}:8099/jmreport/view?token=Bearer `+ getToken()
    }
  },
  created() {
    // this.init()
  },
  methods: {
    init() {
      getReportViewUrl().then(res => {
        // 使用 this.$route 替代 proxy.$route
        const path = this.$route.path
        const reportId = path.substring(path.lastIndexOf("/") + 1)
        this.url = res + "/" + reportId + "?token=Bearer " + getToken()
      }).catch(error => {
        console.error("获取报表URL失败:", error)
      })
    }
  }
}
</script>
