<!--
  @description: 公告内容预览-提交公告
  @Modifier: haoFx
  @routerPath:
  @date: 2020/1/7-16:18
-->
<template>
  <div>
    <!--公告内容预览-->
    <makeTenderingBulletinPdfDetail 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 { submitTenderBulletin } from '@/api/bidding/bidBulletin'
import makeTenderingBulletinPdfDetail from './bulletinPdf-detail'
export default {
  name: 'BidBulletinContentPreview',
  components: {
    makeTenderingBulletinPdfDetail
  },
  data() {
    return {
      confirmLoading: false, // 控制按钮重复点击Loding
      bulletinId: this.$route.query.bulletinId // 公告Id
    }
  },
  methods: {
    getBulletinPdf() {
      this.$refs.bulletinPdf.getBulletinContentPdf() // 调用子组件获取pdf方法
    },
    // 编辑
    editBulletin() {
      this.$router.push({
        path: '/bidding/projectDrive/bulletin/tabs/tenderBulletIinInfo-add',
        query: {
          ...this.$route.query
        }
      })
    },
    // 提交公告
    submitBulletin() {
      this.$confirm('确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        submitTenderBulletin({
          bulletinId: this.bulletinId
        }).then(response => {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.$router.push({
            path: '/bidding/projectDrive/bulletin/',
            query: {
              ...this.$route.query
            }
          })
          this.confirmLoading = false
        }).catch(() => {
          this.confirmLoading = false
        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped>

</style>
