<template>
  <div class="white_bg burt-container">
    <!--详细信息-->
    <companyInfo :detailObj="detailObj" />
    <!--折扣信息-->
    <Discount v-if="detailObj.id" :detailObj="detailObj" @getDetail="getDetail" />
  </div>
</template>

<script>
import companyInfo from "./components/companyInfo";
import Discount from "./components/companyDiscount";
export default {
  data(){
    return {
      id: '', //公司id
      detailObj: { //公司详情
        discountList: [], //折扣列表
        claimApplicationTemplate: [],
        authApplicationTemplate: []
      }
    }
  },
  components: {
    companyInfo,
    Discount
  },
  created(){
    this.id = this.$route.query.id;
    if(this.id){
      this.getDetail();
    }
  },
  methods: {
    //获取详细信息
    getDetail() {
      this.$apis.PAYORDETAIL({
        id: this.id,
      })
      .then((res) => {
        if (res.returnCode == "0000") {
          let data = res.content || {};
          if(data.claimApplicationTemplate){
            data.claimApplicationTemplate = [
              {
                uid: Math.random()*10000,
                name: data.claimApplicationTemplate.slice(data.claimApplicationTemplate.lastIndexOf('/')+1),
                status: 'done',
                url: data.claimApplicationTemplate,
              }
            ]
          }else{
            data.claimApplicationTemplate = [];
          }
          if(data.authApplicationTemplate){
            data.authApplicationTemplate = [
              {
                uid: Math.random()*10000,
                name: data.authApplicationTemplate.slice(data.authApplicationTemplate.lastIndexOf('/')+1),
                status: 'done',
                url: data.authApplicationTemplate,
              }
            ]
          }else{
            data.authApplicationTemplate = [];
          }
          this.detailObj = data;
        } else {
          this.$message.error(res.returnMsg);
        }
      });
    },
  }
}
</script>

<style lang="less" scoped>

</style>