<template>
  <baseVFormRender v-if="reportCode" :reportCode="reportCode"></baseVFormRender>
</template>

<script>
import {setReportGlobalParam} from '@base/components/xform/utils/util.js'

export default {
  name: 'out_render',
  data() {
    return {
      reportCode: null,
    };
  },
  created() {
    this.initData();
  },
  methods: {
    initGlobalReqData() {
      let param = this.$route.query.param;
      setReportGlobalParam(param);
    },
    initData() {
      let dw = this.$route.query.dw;
      let reportCode = this.$route.query.reportCode;
      if (dw && reportCode) {
        this.$http({
          aes: true,
          url: USER_PREFIX + '/dw_auth/login',
          method: `post`,
          data: {
            dw: dw
          },
          // isLoading: true,
          success: res => {
            let token = res.objx;
            this.$store
              .dispatch('user/addToken', {
                token
              })
              .then(() => {
                this.initGlobalReqData();
                this.$nextTick(() => {
                  this.reportCode = reportCode;
                });
              });
          }
        });
      }
    }
  }
};
</script>

<style></style>
