<template>
  <div class="supplementary-info">
    <supplementary-info-content ref="supplementaryInfo" :details-info="detailsInfo"></supplementary-info-content>
    <div class="submit-btn">
      <el-button @click="() => { $router.go(-1) }">取消</el-button>
      <el-button type="primary" @click="onSubmit">提交</el-button>
    </div>
  </div>
</template>

<script>
import { getSuppleDetails, suppleInfoSubmit } from '@/api/exemptionFollow'
export default {
  name: 'ExemptionSupplementaryInfo',
  components: {
    SupplementaryInfoContent: () => import('./components/SupplementaryInfoContent.vue')
  },
  data() {
    return {
      detailsInfo: {}
    }
  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.params
      getSuppleDetails({ exemptionMattersId: id }).then(({ data }) => {
        this.detailsInfo = data
      })
    },
    onSubmit() {
      const data = this.$refs.supplementaryInfo.getParams()
      if (!data) return
      const { taskId } = this.$route.query
      const { id } = this.$route.params
      const params = {
        Loading: true,
        ...data,
        taskId,
        id,
        paymentInfoId: this.detailsInfo.paymentApply.paymentInfoId
      }
      suppleInfoSubmit(params).then(() => {
        this.$message.success('提交成功')
        this.$router.go(-1)
      })
    }

  }
}
</script>

<style lang="scss" scoped>

</style>
