<!--
  @description: 发布招标公告/发布资审公告
  @Modifier: haoFx
  @routerPath: /bidding/publishTenderingBulletin
               /bidding/publishTenderInformationBulletin
  @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" />{{ bulletinTitle }}发布列表
      </div>
    </div>
    <!--公告内容预览-->
    <bulletinPdfDetail />
    <div class="view mb16" style="text-align: center">
      <el-checkbox-group v-model="formData.mediaPartners">
        <el-checkbox
          v-for="(item) in mediaPartnersList"
          :key="item.typecode"
          :disabled="item.typecode === '00'"
          :label="item.typecode"
        >
          {{ item.typename }}
        </el-checkbox>
      </el-checkbox-group>
    </div>
    <!--保存按钮-->
    <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 { tenderBulletinInitGroupMixin } from './../mixins/tenderBulletinInitGroupMixin'// 字典信息
import { uploadCms } from '@/api/bidding/bidBulletin'
import bulletinPdfDetail from '../tenderBulletin/bulletinPdf-detail'
export default {
  name: 'PublishTenderingBulletin',
  components: {
    bulletinPdfDetail
  },
  mixins: [tenderBulletinInitGroupMixin],
  data() {
    return {
      confirmLoading: false,
      bulletinId: this.$route.query.bulletinId, // 公告Id
      formData: {
        mediaPartners: ['00'] // 指定媒体 00 门户网站
      }
    }
  },
  watch: {
    $route() {
      this.initBulletinType()// 字典信息区分-招标公告/资审公告方法
    }
  },
  created() {
    this.initBulletinType()// 字典信息区分-招标公告/资审公告方法
    this.getTenderBailPriceInitInfo()// 字典信息
  },
  methods: {
    // 返回发布列表
    back() {
      this.$router.push('/bidding/tenderBulletinPublish')
    },
    // 发布公告
    publishBulletin() {
      this.$confirm('确认发布?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        uploadCms(this.bulletinId).then(response => {
          this.$message({
            message: '发布成功',
            type: 'success'
          })
          // 同一个页面不同路由
          let path = ''
          if (this.bulletinType === '01') { // 招标公告
            path = '/bidding/tenderBulletinPublish'
          } else if (this.bulletinType === '21') {
            path = '/bidding/tenderInformationBulletinPublish'// 资审公告
          }
          this.$router.push({
            path: path
          })
          this.confirmLoading = false
        }).catch(() => {
          this.confirmLoading = false
        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
