<template>
  <div class="financial-review">
    <cy-up-down-drag>
      <div slot="top">
        <invoices-management-view></invoices-management-view>
      </div>
      <div slot="bar">
        <div>
          财务审核
        </div>
      </div>
      <div slot="bottom">
        <div class="tempalte-content" style="min-height: auto; padding: 0px 20px ">
          <financial-review-content ref="financialReviewContent" :deatails-info="deatailsInfo" />
          <div class="submit-btn">
            <el-button style="width: 150px;" type="primary" @click="onSubmit">确定</el-button>
            <el-button style="width: 150px;" @click="() => { $router.go(-1) }">取消</el-button>
          </div>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script>
import { saleInvoiceApprovalQuery, saleInvoiceApproval } from '@/api/invoicesManagement/invoicesManagement'
import FinancialReviewContent from './components/FinancialReviewContent.vue'
import InvoicesManagementView from './components/InvoicesManagementView.vue'
export default {
  name: 'BiddingManagementTemplateReview',
  components: {
    FinancialReviewContent,
    InvoicesManagementView
  },
  data() {
    return {
      deatailsInfo: {}
    }
  },
  created() {
    const { businessKey } = this.$route.query
    if (businessKey) {
      this.saleInvoiceApprovalQuery()
    }
  },
  methods: {
    saleInvoiceApprovalQuery() {
      const { taskId, businessKey } = this.$route.query
      saleInvoiceApprovalQuery({ taskId, businessKey }).then(data => {
        this.deatailsInfo = data.data
      })
    },
    onSubmit() {
      this.$refs.financialReviewContent.getSubmit().then(data => {
        const params = {
          Loading: true,
          ...data
        }
        saleInvoiceApproval(params).then(() => {
          this.$message.success('财务审核成功')
          this.$router.push({ name: 'InvoicesManagement' })
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  /* .template-examine .submit-btn {
    position: absolute;
    bottom: 40px;
    right: 40px;
  } */
</style>

