<!--
  @description: 候选人公示内容预览-提交候选人公示
  @Modifier: haoFx
  @routerPath: /bidding/projectDrive/calibration/submitCandidateBulletin
  @date: 2020/1/7-16:18
-->
<template>
  <div>
    <!--候选人公示内容预览-->
    <candidateBulletinDetail ref="bulletinPdf" />
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button @click="editBulletin">
          编辑
        </el-button>
        <el-button :loading="confirmLoading" type="primary" @click="submitBulletin">
          提交公示
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
/* api*/
import { submitCandidateBulletin } from '@/api/bidding/bidCalibration'
import candidateBulletinDetail from './candidateBulletin-detail'
import { candidateBulletinCommon } from '../mixins/candidateBulletinCommon'

export default {
  name: 'BidBulletinContentPreview',
  components: {
    candidateBulletinDetail
  },
  mixins: [candidateBulletinCommon],
  data() {
    return {
      confirmLoading: false // 控制按钮重复点击Loding
    }
  },
  methods: {
    // 编辑
    editBulletin() {
      this.$router.push({
        path: '/bidding/projectDrive/calibration/makeCandidateBulletin-add',
        query: {
          ...this.$route.query
        }
      })
    },
    // 提交公告
    submitBulletin() {
      this.$confirm('确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        const params = {
          candidateBulletinId: this.candidateBulletinId
        }
        submitCandidateBulletin(params).then(response => {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.$router.push({
            path: '/bidding/projectDrive/calibration/candidatePublicity-add',
            query: {
              ...this.$route.query
            }
          })
          this.confirmLoading = false
        }).catch(() => {
          this.confirmLoading = false
        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped>

</style>
