<!--
  @description: 邀请函内容预览-提交邀请函
  @Modifier: haoFx
  @routerPath:
  @date: 2020/1/7-16:18
-->
<template>
  <div>
    <!--邀请函内容预览-->
    <makeTenderingInvitationPdfDetail ref="bulletinPdf" />
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button :loading="confirmLoading" @click="editBulletin">
          编辑
        </el-button>
        <el-button :loading="confirmLoading" type="primary" @click="submitBulletin">
          提交邀请函
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
/* api*/
import { submitTenderInvitation } from '@/api/bidding/bidInvitation'
import makeTenderingInvitationPdfDetail from './makeTenderingInvitationPdf-detail'
export default {
  name: 'BidInvitationContentPreview',
  components: {
    makeTenderingInvitationPdfDetail
  },
  data() {
    return {
      confirmLoading: false, // 控制按钮重复点击Loding
      invitationId: this.$route.query.invitationId // 邀请函Id
    }
  },
  methods: {
    getBulletinPdf() {
      this.$refs.bulletinPdf.getBulletinContentPdf() // 调用子组件获取pdf方法
    },
    // 编辑
    editBulletin() {
      this.$router.push({
        path: '/bidding/projectDrive/invitation/tabs/tenderInvitationInfo-add',
        query: {
          ...this.$route.query
        }
      })
    },
    // 提交邀请函
    submitBulletin() {
      this.$confirm('确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        submitTenderInvitation({ invitationId: this.invitationId }).then(response => {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.$router.push({
            path: '/bidding/projectDrive/invitation',
            query: {
              ...this.$route.query
            }
          })
          this.confirmLoading = false
        }).catch(() => {
          this.confirmLoading = false
        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped>

</style>
