linzhijie
2023-04-25 b79e4f19491338a53f31aa358081d19d4b6d23e8
src/views/exam/paper/finish.vue
@@ -6,20 +6,57 @@
      <el-main class="align-center">
        <H1 v-if="content!==null && content.trim()!==''">{{content}}</H1>
        <H1 v-else>{{$t('finishMsg')}}</H1>
        <!-- 新增下载报告提示语 -->
        <H1 v-if ="downDisable">{{$t('finishPersonalityDownInfo')}}</H1>
        <el-button type="danger" v-if ="downDisable" @click="downReport" round>{{$t('down')}}</el-button>
        <!-- 新增预览提示语 -->
        <H1 v-if ="viewDisable">{{$t('finishViewReportInfo')}}</H1>
        <el-button type="danger" v-if ="viewDisable" @click="viewReport" round>{{$t('view')}}</el-button>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import examPaperApi from '@/api/examPaper'
export default {
  data () {
    return {
      name: this.$route.query.name,
      content: this.$route.query.content
      content: this.$route.query.content,
      tokenId: this.$route.query.tokenId,
      type: this.$route.query.type,
      downDisable: false,
      viewDisable: false,
      downUrl: '',
      viewUrl: ''
    }
  },
  created () {
    let _this = this
    // 查询报告文件名
    examPaperApi.selectTesterReport(_this.tokenId).then(re => {
      if (re.code === 0) {
        _this.downDisable = true
        // 设置下载路径
        _this.downUrl = '/api/exam/paper/download?fileName=' + re.msg + '&delete=false'
        console.log(re)
      } else {
        console.log(re)
      }
    })
    // 查询报告文件名
    examPaperApi.selectTesterReportUrl(_this.tokenId).then(re => {
      if (re.code === 0) {
        _this.viewDisable = true
        // 设置预览路径
        _this.viewUrl = re.msg
        console.log(re)
      } else {
        console.log(re)
      }
    })
  },
  mounted () {
@@ -27,6 +64,16 @@
  beforeDestroy () {
  },
  methods: {
    // 下载报告
    downReport: function () {
      let _this = this
      window.open(_this.downUrl)
    },
    // 预览报告
    viewReport: function () {
      let _this = this
      _this.$router.push({ path: '/pdf/view', query: { fileUrl: _this.viewUrl } })
    }
  },
  computed: {
  }