<!--
  @description: 发布候选人公示页面
  @Modifier: haoFx
  @routerPath: /bidding/sendCandidatePublicityPublish
  @date: 2020/1/9-19:28
-->
<template>
  <div>
    <div class="title p0-16 clearfix">
      <div class="title-back pointer" @click="back">
        <i class="iconfont icon-fanhui mr10" />候选人公示发布列表
      </div>
    </div>
    <!--公示内容预览-->
    <candidateBulletinDetail />
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button :loading="confirmLoading" type="primary" @click="publishBulletin">
          发布候选人公示
        </el-button>
        <el-button :loading="confirmLoading" @click="back">
          返 回
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { uploadCandidateBulletinCms } from '@/api/bidding/bidCalibration'
import candidateBulletinDetail from '../candidateBulletin/candidateBulletin-detail'
export default {
  name: 'SendCandidatePublicityPublish',
  components: {
    candidateBulletinDetail
  },
  data() {
    return {
      confirmLoading: false,
      candidateBulletinId: this.$route.query.candidateBulletinId // 候选人公示id
    }
  },
  methods: {
    // 返回
    back() {
      this.$router.push('/bidding/candidateBulletinPublish')
    },
    // 发布公告
    publishBulletin() {
      this.$confirm('确认发布?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        uploadCandidateBulletinCms(this.candidateBulletinId).then(response => {
          this.$message({
            message: '发布成功',
            type: 'success'
          })
          this.$router.push({
            path: '/bidding/candidateBulletinPublish'
          })
          this.confirmLoading = false
        }).catch(() => {
          this.confirmLoading = false
        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
