<!--
  @description:采购立项-供应商-可参与项目-邀请函
  @Modifier:gmy
  @routerPath:/procurement/invitation
  @date:2020/6/30-11:27
-->
<template>
  <div>
    <div class="page-title title_border clearfix" style="padding: 0 8px">
      <!-- 返回 -->
      <div class="title-back pointer fl" @click="back">
        <i class="iconfont icon-fanhui mr10 " />{{ titleMessage }}
      </div>
      <div v-if="typeTage !== '01'" class="fr">
        <el-button type="primary" size="small" @click="acceptnvitation">
          接受邀请
        </el-button>
      </div>
    </div>
    <procurementProjectLetterComp v-if="askData.packId" :tender-type="askData.tenderType" :pack-id="askData.packId" />
  </div>
</template>
<script>
/* 接口*/
import { refuseInvitationAsk } from '@/api/procurement/procurementInvitation'//  供应商报名可参与列表
/* 公共字典*/
import { procurementProjectMixins } from '../mixins/procurementProjectMixins'
import procurementProjectLetterComp from '@views/procurement/procurementProject/procurementProjectLetter/procurementProjectLetterComp.vue'

/* pdf组件*/
export default {
  name: 'ProjectManagerTenderList',
  components: {
    procurementProjectLetterComp
  },
  mixins: [procurementProjectMixins],
  data() {
    return {
      // 拒绝邀请函公告数据
      askData: {
        id: this.$route.query.bizId, // 邀请函主键id
        packId: this.$route.query.packId, // 项目标段id
        tenderType: this.$route.query.tenderType,
        invitationStateType: this.$route.query.invitationStateType // 邀请函状态 00拒绝 01接受 02待接受
      },
      titleMessage: '邀请函', // 采购标题
      text: '', //  html文件
      typeTage: this.$route.query.typeTage // 判断是否是已完成项目跳转过来的 01 是
    }
  },
  created() {
  },
  methods: {
    // 拒绝邀请函
    refuseInvitation() {
      this.$confirm('拒绝之后将不能再次参与本项目，确认拒绝吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.refuseInvitationData(this.askData)
      }).catch(() => {
      })
    },
    // 接受邀请函
    acceptnvitation() {
      // 获取项目的采购方式 14||15 前往竞价页面
      const tenderMethod = this.$route.query.tenderMethod
      // 获取项目标段Id
      const packIds = this.$route.query.packId
      // 项目采购方式参数
      this.$router.push({
        path: '/procurement/procurementContactsApply',
        query: {
          packId: packIds, // 标段Id
          tenderMethod: tenderMethod,
          check: '01' // 01 表示可参与项目
        }
      })
    },
    // 拒绝邀请函请求
    async refuseInvitationData(data) {
      const res = await refuseInvitationAsk(data)
      if (res.header.msg === '操作成功') {
        this.$confirm('操作成功', '提示', {
          showConfirmButton: false,
          showCancelButton: false,
          type: 'warning'
        }).then(() => {}).catch(() => { this.$router.push({ path: '/procurement/procurementSupplier' }) })
      }
    },
    // 返回
    back() {
      // 获取采购方式
      const tenderMethod = this.$route.query.tenderMethod
      // typeTage 01 表示是已完成列表跳转的查看
      if (this.typeTage === '01') {
        this.$router.push(this.driveCompletedList[tenderMethod])
        return
      }
      // 返回对应的页面
      this.$router.push(this.driveSupplierList[tenderMethod])
    }
  }
}
</script>
<style lang="less" scoped>
</style>
