<!--
  @description:代理机构-邀请函列表-查看邀请函信息
  @Modifier: haoFx
  @routerPath: /bidding/tenderInvitationDetail
  /work/invitation/tenderInvitationDetail
  @date: 2020/1/20-16:33
  flowStatus: true 从工作流进入
-->

<template>
  <div>
    <div v-if="invitationDetailType==='00'" class="title p0-16 clearfix">
      <div class="title-back pointer" @click="back">
        <i class="iconfont icon-fanhui mr10" />邀请函列表
      </div>
    </div>
    <div :class="invitationDetailType==='00'?'view':'main'">
      <!--项目信息-->
      <dl class="projectInfoDetail">
        <dt>
          <p class="projectInfoDetail_icon">
            <i class="iconfont icon-xiangmujibenxinxi" />
          </p>
          项目信息
        </dt>
        <dd>
          <table class="tableData">
            <tr>
              <td>邀请函标题</td>
              <td colspan="3">
                {{ formData.invitationTitle }}
              </td>
            </tr>
            <tr>
              <td>标段（包）编号</td>
              <td>{{ formData.packNo }}</td>
              <td>标段（包）名称</td>
              <td>{{ formData.packName }}</td>
            </tr>
            <tr>
              <td>招标方式</td>
              <td>
                <span
                  v-for="(item,index) in bidTypeList"
                  v-if="formData.tenderMethod === item.typecode"
                  :key="index"
                >
                  {{ item.typename }}
                </span>
              </td>
              <td>资格审查方式</td>
              <td>
                <span v-if="formData.qualificationMethod === '00'">资格预审</span>
                <span v-else-if="formData.qualificationMethod === '01'">资格后审</span>
              </td>
            </tr>
            <tr>
              <td>招标文件购买开始时间</td>
              <td>
                {{ formData.getTendeStageTimeRulVo.tenderDocumentReceiveStartTime && $Moment(formData.getTendeStageTimeRulVo.tenderDocumentReceiveStartTime).format(momentDateTime) }}
              </td>
              <td>招标文件购买截止时间</td>
              <td>
                {{ formData.getTendeStageTimeRulVo.tenderDocumentReceiveEndTime && $Moment(formData.getTendeStageTimeRulVo.tenderDocumentReceiveEndTime).format(momentDateTime) }}
              </td>
            </tr>
            <tr>
              <!--isTwoBidOpening 是否两步开标 00:否 01:是  一步开标展示投标文件截止时间及开标时间-->
              <template v-if="formData.getTendeStageTimeRulVo.isTwoBidOpening==='00'">
                <td>投标文件截止时间及开标时间</td>
                <td>
                  {{ formData.getTendeStageTimeRulVo.openBidStartTime && $Moment(formData.getTendeStageTimeRulVo.openBidStartTime).format(momentDateTime) }}
                </td>
              </template>
              <!--isTwoBidOpening 是否两步开标 00:否 01:是  两步开标展示 商务技术开标时间-->
              <template v-if="formData.getTendeStageTimeRulVo.isTwoBidOpening==='01'">
                <td>商务技术开标时间</td>
                <td>
                  {{ formData.getTendeStageTimeRulVo.technicalOpeningTime && $Moment(formData.getTendeStageTimeRulVo.technicalOpeningTime).format(momentDateTime) }}
                </td>
              </template>
              <td>澄清答疑截止时间</td>
              <td>
                {{ formData.getTendeStageTimeRulVo.acceptAnsweringQuestionsEndTime && $Moment(formData.getTendeStageTimeRulVo.acceptAnsweringQuestionsEndTime).format(momentDateTime) }}
              </td>
            </tr>
            <tr>
              <td>项目所在地</td>
              <td colspan="3">
                {{ formData.buildAddress }}
              </td>
            </tr>
          </table>
        </dd>
      </dl>
      <!--邀请-->
      <dl class="projectInfoDetail">
        <dt>
          <p class="projectInfoDetail_icon">
            <i class="iconfont icon-xiangmujibenxinxi" />
          </p>
          邀请
        </dt>
        <dd>
          <!--不分包详情 isPack 00 不分包 01 分包-->
          <noPackageSupplierInvitationDetail v-if="isPack === '00'" />
          <!--分包详情-->
          <packageSupplierInvitationDetail v-if="isPack === '01'" />
        </dd>
      </dl>
      <!--邀请函信息-->
      <dl class="projectInfoDetail">
        <dt>
          <p class="projectInfoDetail_icon">
            <i class="iconfont icon-xiangmujibenxinxi" />
          </p>
          邀请函信息
        </dt>
        <dd>
          <table class="tableData">
            <tr class="singleRow">
              <td>邀请函内容</td>
              <td colspan="3">
                <downloadFile :data="bulletinContentData" />
              </td>
            </tr>
            <tr class="singleRow">
              <td>附件</td>
              <td colspan="3">
                <downloadFile :data="upLoadData" />
              </td>
            </tr>
          </table>
        </dd>
      </dl>
    </div>
    <!--邀请接受情况明细-->
    <scceptInvitationDetailDialog ref="scceptInvitation" />
    <!--邀请拒绝情况明细-->
    <rejectInvitationDetailDialog ref="rejectInvitation" />
    <!--当前页面从哪进来的  01 驱动内列表页 并且不是工作流-->
    <div v-if="invitationDetailType==='01' && !flowStatus" class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button @click="back()">
          返 回
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
/* api*/
import { getTenderInvitationDetailed } from '@/api/bidding/bidInvitation'
/* api*/
import { queryTenderProjectIsPack } from '@/api/bidding/biddingProject'
/* 组件*/
import scceptInvitationDetailDialog from './scceptInvitationDetail-dialog'
import rejectInvitationDetailDialog from './rejectInvitationDetail-dialog'
import noPackageSupplierInvitationDetail from '../tenderInvitationSupplier/noPackageSupplierInvitation-detail'
import packageSupplierInvitationDetail from '../tenderInvitationSupplier/packageSupplierInvitation-detail'
import downloadFile from '@comp/common/updownload/downloadFile' // 获取附件信息 下载组件
/* 混入*/
import { tenderInvtationMixin } from './../mixins/tenderInvtationMixin'
export default {
  name: 'TenderInvitationDetail',
  components: {
    downloadFile, // 文件下载
    scceptInvitationDetailDialog, // 接受查看
    rejectInvitationDetailDialog, // 拒绝查看
    noPackageSupplierInvitationDetail, // 不分包查看详情
    packageSupplierInvitationDetail // 分包查看详情
  },
  mixins: [tenderInvtationMixin],
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      phaseTypeList: [], // 资格审查方式
      /* 字典信息-end */
      flowStatus: this.$route.query.flowStatus, // true 工作流进入驳回编辑
      invitationDetailType: this.$route.meta.invitationDetailType, // 判断类型驱动内直接展示详情页01 菜单下查看00
      invitationId: '',
      tenderId: this.$route.query.id,
      isPack: this.isPack, // 00 不分包 01 分包
      formData: {
        invitationId: '', // 邀请函id
        invitationTitle: '', // 邀请函标题
        contentText: '', // 邀请函内容
        packNo: '', // 包编号
        packName: '', // 包名称
        tenderMethod: '', // 招标方式
        stageId: '', // 阶段id
        buildAddress: '',
        qualificationMethod: '', // 资格审查方式 00资格预审,01 资格后审
        // 时间规则
        getTendeStageTimeRulVo: {
          tenderDocumentReceiveStartTime: '', // 标书获取开始时间
          tenderDocumentReceiveEndTime: '', // 标书获取截止时间
          submitEndTime: '', // 投标截止时间
          openBidStartTime: '', // 开标时间
          technicalOpeningTime: '', // 商务技术开标时间
          acceptAnsweringQuestionsEndTime: '' // 接受答疑截止时间
        }
      }
    }
  },
  created() {
    // flowStatus为true 工作流进入 否则是驱动进入
    this.invitationId = this.flowStatus ? this.$route.query.bizId : this.$route.query.invitationId

    this.initGroup() // 获取字典方法
    this.getPack()
    this.getTenderInvitationDetail()
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType', // 招标方式
        'phaseType'// 资格审查方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取分标段不分标段状态
    getPack() {
      queryTenderProjectIsPack(this.tenderId).then(res => {
        // isPack 00 不分包 01 分包
        // 分包不分包邀请名单展示不同的组件
        this.isPack = res.data.isPack
      })
    },
    getTenderInvitationDetail() {
      getTenderInvitationDetailed(this.invitationId).then(res => {
        this.formData = res.data
      }).catch(() => {
      })
    },
    // 查看邀请明细
    examineInvitation(row) {
      if (row.status === '00') {
        //  接受邀请函明细
        this.$refs.scceptInvitation.openBounced()
      } else {
        //  拒绝邀请函明细
        this.$refs.rejectInvitation.openBounced()
      }
    },
    // 返回
    back() {
      if (this.invitationDetailType === '01') { // 驱动内列表页
        const query = { ...this.$route.query }
        this.$router.push({
          path: '/bidding/projectDrive/invitation/invitationList',
          query: {
            id: query.id, // 项目id
            tenderName: query.tenderName, // 项目名称
            stageIds: query.stageIds, // 阶段Id
            packId: query.packId// 标段Id
          }
        })
      } else { // 菜单下查看
        this.$router.push({
          path: '/bidding/tenderInvitation'
        })
      }
    }
  }
}
</script>

<style scoped lang="less">
</style>
