<!--
  @description: 异议申请函详情-公共组件
  @Modifier: haoFx
  @routerPath:
  @date: 2020/3/3-13:33
-->
<template>
  <div>
    <table class="tableData">
      <tr>
        <td>项目名称</td>
        <td>{{ formData.tenderName }}</td>
        <td>项目编号</td>
        <td>{{ formData.tenderNo }}</td>
      </tr>
      <tr>
        <td>标段（包）名称</td>
        <td>
          <span v-for="(item,index) in formData.packInfoList" :key="index">
            {{ item.packName }}
          </span>
        </td>
        <td>标段（包）编号</td>
        <td>
          <span v-for="(item,index) in formData.packInfoList" :key="index">
            {{ item.packNo }}
          </span>
        </td>
      </tr>
      <tr>
        <td>问题类型</td>
        <!--问题类型00异议 01投诉-->
        <td>{{ formData.objectionMode==='00'?'异议':'投诉' }}</td>
        <td>异议类型</td>
        <td>
          {{ filterDictText(objectionTypeList,formData.objectionType) }}
        </td>
      </tr>
      <tr>
        <!--投诉/异议接收单位公司代码-->
        <td>{{ bukName }}</td>
        <td>{{ formData.buk }}</td>
        <!--投诉/异议申请单据号-->
        <td>{{ objectionNoName }}</td>
        <td>{{ formData.objectionNo }}</td>
      </tr>
      <tr>
        <td>异议人</td>
        <td>{{ formData.supplierName }}</td>
        <td>地址</td>
        <td>{{ formData.address }}</td>
      </tr>
      <tr>
        <td>法定代表人</td>
        <td>{{ formData.legalPerson }}</td>
        <td>法定代表人电话</td>
        <td>{{ formData.legalPersonPhone }}</td>
      </tr>
      <tr>
        <td>法定代表人邮箱</td>
        <td>{{ formData.legalPersonEmail }}</td>
        <td>授权委托人</td>
        <td>{{ formData.grantauthPerson }}</td>
      </tr>
      <tr>
        <td>授权委托人电话</td>
        <td>{{ formData.grantauthPersonPhone }}</td>
        <td>授权委托人邮箱</td>
        <td>{{ formData.grantauthPersonEmail }}</td>
      </tr>
      <tr>
        <td>投诉方式</td>
        <td>
          {{ filterDictText(clarificationObjectionTypeList,formData.complaintType) }}
        </td>
        <td />
        <td />
      </tr>
      <tr>
        <td>提出异议事项的基本事实</td>
        <td colspan="3">
          {{ formData.objectionbasicfactsContent }}
        </td>
      </tr>
      <tr>
        <td>相关证明材料</td>
        <td colspan="3">
          <downloadFile :data="upLoadData" />
          <downloadFile :data="upLoadContent" />
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
/* api*/
import { getRaiseObjectionInfoByObjectionId, getObjectionId } from '@api/bidding/tenderObjection'
import downloadFile from '@comp/common/updownload/downloadFile' // 获取附件信息 下载组件
import { filterDictText } from '@assets/js/utils'// 常用方法
export default {
  name: 'ClarificationApplicationDetail',
  components: {
    downloadFile// 文件下载
  },
  data() {
    return {
      /* 字典信息-start */
      objectionTypeList: [], // 异议类型
      clarificationObjectionTypeList: [], // 投诉方式
      /* 字典信息-end */
      flowStatus: this.$route.query.flowStatus, // 是否工作流进入
      // 异议投诉附件文件
      upLoadData: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_objection_attachment'// 文件类型
      },
      // 异议投诉内容文件
      upLoadContent: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_objection_content'// 文件类型
      },
      // 异议申请函详情
      formData: {},
      bukName: '',
      objectionNoName: ''
    }
  },
  watch: {
    // 00异议 01投诉
    'formData.objectionMode'(val) {
      if (val === '01') {
        this.bukName = '投诉接收单位公司代码'
        this.objectionNoName = '投诉申请单据号'
      } else {
        this.bukName = '异议接收单位公司代码'
        this.objectionNoName = '异议申请单据号'
      }
    }
  },
  created() {
    // 工作流进入和其它页面进入异议id objectionId取值方式不同
    // flowStatus true 工作流进入
    let bizId = ''
    if (this.flowStatus) {
      bizId = this.$route.query.bizId
      this.flowGetObjectionId(bizId) // 工作流进入使用bizId获取objectionId
    } else {
      bizId = this.$route.params.objectionId
      this.getRaiseObjectionInfo(bizId)
    }
  },
  mounted() {
    this.initGroup() // 获取字典方法
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取字典方法
    initGroup() {
      const data = [
        'objectionType', // 异议类型
        'clarificationObjectionType'// 异议投诉方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 根据异议投诉id获取投标人提出异议基本信息
    getRaiseObjectionInfo(objectionId) {
      this.upLoadData.bizId = objectionId // 异议投诉附件文件-业务主键Id
      this.upLoadContent.bizId = objectionId // 获取异议投诉内容文件-业务主键Id
      const params = {
        objectionId
      }
      getRaiseObjectionInfoByObjectionId(params).then(res => {
        this.formData = res.data
        this.$emit('objectionDetail', this.formData) // 详情信息传给父组件
      }).catch(() => {
      })
    },
    // 根据异议回复主键id获取异议主键id--工作流进入调用
    flowGetObjectionId(bizId) {
      let objectionId = '' // 异议id
      const processDefinitionKey = this.$route.query.processDefinitionKey // 风险控制部的流程图key
      // 工作流进入并且不是风险控制部则需要重新获取objectionId
      if (processDefinitionKey !== 'raiseObjectionWeb_audit') {
        getObjectionId(bizId).then(res => {
          objectionId = res.data
          this.getRaiseObjectionInfo(objectionId)
          this.upLoadData.bizId = objectionId // 异议投诉附件文件-业务主键Id
          this.upLoadContent.bizId = objectionId // 获取异议投诉内容文件-业务主键Id
        }).catch(() => {
        })
      } else {
        this.getRaiseObjectionInfo(bizId)
        this.upLoadData.bizId = bizId // 异议投诉附件文件-业务主键Id
        this.upLoadContent.bizId = bizId // 获取异议投诉内容文件-业务主键Id
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
