<!--
  @description: 申报材料-查看基本信息
  @Modifier: 肖文龙
  @routerPath:
  @date: 2020-2-20 16:32:31
-->
<template>
  <div class="projectInfoDetail">
    <table class="tableData">
      <el-button v-if="ChangeDetailBtn" class="mb10" type="primary" @click="handleChangeDetail">
        查看变更内容
      </el-button>
      <tr v-if="reviewSource" class="singleRow mb10">
        <td>资审来源</td>
        <td colspan="3">
          申报入库
        </td>
      </tr>
      <tr>
        <td
          colspan="4"
          style="text-align: left;
          font-weight: bold;
          background: #fff;border:none"
        >
          <span>1.基本信息</span>
          <!-- <el-button class="left10" :loading="btnLoding" type="primary" @click="downloadFile()">
            下载基本信息
          </el-button> -->
        </td>
      </tr>
      <tr>
        <td>单位注册地</td>
        <td>
          <span v-for="(item,indexs) in incorporationGroup" v-if="formData.incorporation === item.typecode" :key="indexs">{{ item.typename }}</span>
          ,
          <span v-for="(item) in incorporationGroups" v-if="formData.area === item.typecode" :key="item.typecode">{{ item.typename }}</span>
        </td>
        <td>机构类型</td>
        <td><span v-for="(item,indexs) in documentMethodList" v-if="formData.unittype === item.typecode" :key="indexs">{{ item.typename }}</span></td>
      </tr>
      <tr class="singleRow">
        <td>供应商名称</td>
        <td colspan="3">
          {{ formData.departName }}
        </td>
      </tr>
      <tr>
        <td>{{ businesslicenceTitle }}</td>
        <td>{{ formData.businesslicence }}</td>
        <td>供应商分类</td>
        <td> {{ filterDictText(supplierTypeCodeGroup,formData.supplierType) }}</td>
      </tr>
      <tr>
        <td>企业性质</td>
        <td><span v-for="(item,indexs) in supplierEntPrptGroup" v-if="formData.entPrpt === item.typecode" :key="indexs">{{ item.typename }}</span></td>
        <td>单位成立日期</td>
        <td>{{ formData.foundingTime }}</td>
      </tr>
      <tr>
        <td>法人/负责人</td>
        <td>{{ formData.corporation }}</td>
        <td>法人/负责人身份证号或护照号</td>
        <td>{{ formData.corporateid }}</td>
      </tr>
      <tr>
        <td>单位地址</td>
        <td colspan="3">
          {{ formData.areaValue }}{{ formData.address }}
        </td>
      </tr>
      <tr>
        <td>供货范围</td>
        <td colspan="3">
          {{ formData.supplyScope }}
        </td>
      </tr>
      <tr>
        <td>公司简介</td>
        <td colspan="3">
          {{ formData.descr }}
        </td>
      </tr>
      <tr>
        <td>营业执照扫描件</td>
        <td><downloadFile v-if="businessLicenseData.bizId" :data="businessLicenseData" /></td>
        <td>营业执照有效期</td>
        <td>{{ formData.effectiveEndDate }}</td>
      </tr>
      <tr>
        <td>法人/负责人身份证或护照扫描件</td>
        <td colspan="3">
          <downloadFile v-if="principalData.bizId" :data="principalData" />
        </td>
      </tr>
      <tr>
        <td
          colspan="4"
          style="text-align: left;
          font-weight: bold;
          background: #fff;border:none"
        >
          2.基本户信息
        </td>
      </tr>
      <tr>
        <td>开户银行</td>
        <td>{{ formData.finance.bankname }}</td>
        <td>账号</td>
        <td>{{ formData.finance.bankaccount }}</td>
      </tr>
      <tr>
        <td>开户行行号</td>
        <td>{{ formData.finance.accountNum }}</td>
        <td>联行号</td>
        <td>{{ formData.finance.correspondentNum }}</td>
      </tr>
      <tr>
        <td>开户行地址</td>
        <td>{{ formData.finance.accountCity }}</td>
        <td>电话</td>
        <td>{{ formData.finance.accountPhone }}</td>
      </tr>
      <tr>
        <td>注册资本(万元)</td>
        <td>
          {{
            formData.finance.regcapital
              ? moneyFormat(Number(formData.finance.regcapital))
              : formData.finance.regcapital
          }}
        </td>
        <td>币种</td>
        <td>
          <span v-for="(item,indexs) in currencies" v-if="formData.finance.currencies === item.typecode" :key="indexs">{{ item.typename }}</span>
        </td>
      </tr>
      <tr>
        <td>实缴资本(万元)</td>
        <td>{{ formData.finance.actualCapital }}</td>
        <td>开户许可证</td>
        <td>
          <downloadFile
            v-if="businessLicenseData.bizId"
            ref="downloadFile"
            :data="accountLicenceData"
          />
        </td>
      </tr>
      <template v-if="$route.path === '/supperManagement/editorDeclarationOurCompanyAudit-detail'">
        <tr>
          <td colspan="4" style="text-align: left; font-weight: bold; background: #fff;border:none">
            3.供应商申报附件
          </td>
        </tr>
        <tr>
          <td>供应商申报附件</td>
          <td colspan="3">
            <downloadFile :data="downloadFileReport" />
          </td>
        </tr>
      </template>
    </table>

    <!--审核信息-->
    <inforaMtionAuditDetail v-if="!judgePageData.detailType" />
    <!--查看变更内容-弹窗-->
    <essentialInformationDifferenceDialog :dialog-data="essentialInformationDifferenceDialog" />
  </div>
</template>

<script>
/* 接口*/
import { getUpdateDepartInfo, downBaseInfoSupplierDocx } from '@/api/supplier/supplierBaseInfo'// 获取编辑申报材料查询
import { queryDeclarationInfo } from '@/api/supplier/declaraTionrecord'// 供应商入库查询
/* 公用方法 */
import { moneyFormat, filterDictText } from '@assets/js/utils'
/* 混合开发*/
import { declareHegSupperGroupMixin } from '@/views/supplier/editorDeclaration/mixins/declareHegSupperGroupMixin'// 供应商-字典
import { declareHegSupperMixins } from '@/views/supplier/editorDeclaration/mixins/declareHegSupperMixins'// 供应商-公用方法参数
import { supplierGroupMixin } from '@/views/supplier/mixins/supplierGroupMixin'

/* 组件 */
import downloadFile from '@comp/common/updownload/downloadFile'// 附件
import essentialInformationDifferenceDialog from '@/views/supplier/editorDeclaration/essentialInformation/essentialInformationDifference-dialog' // 查看变更内容-弹窗
import inforaMtionAuditDetail from '@/views/supplier/editorDeclaration/inforaMtionAudit/inforaMtionAudit-detail'// 审报材料-审核信息
import { download } from '@/assets/js/utils'// 常用方法

export default {
  name: 'PreviewProjectInfoDetail',
  components: {
    downloadFile, // 附件
    essentialInformationDifferenceDialog, // 查看变更内容-弹窗
    inforaMtionAuditDetail
  },
  mixins: [declareHegSupperGroupMixin, declareHegSupperMixins, supplierGroupMixin],
  props: {
    judgePageData: {
      type: Object,
      default: function() {
        return {
          departId: '', // 供应商id
          declarationId: '', // 申报审核携带参数
          isViewPage: '', // 判斷是否是供应商本人登录 空代表是
          departInfoId: '' // 变更提交携带参数
        }
      }
    }
  },
  data() {
    return {
      btnLoding: false, // loading
      pageType: this.$route.meta.type,
      bizType: this.$route.params.bizType || '',
      declarationId: this.$route.params.declarationId || this.judgePageData.declarationId || '', // 申报记录id
      isViewPage: this.judgePageData.isViewPage || '', // 是否是供应商本人登录
      departId: this.$route.params.departId || this.judgePageData.departId || '', // 供应商id
      moneyFormat: moneyFormat, // 千分位转换
      ChangeDetailBtn: true, // 查看变更内容
      reviewSource: false,
      // 添加证书/编辑证书弹框
      certificateData: {
        dialog: false, // 弹框展示状态
        id: '', // 证书id-编辑时才会有证书id
        oldId: '' // 修改时用的Id
      },
      // 变更查看
      essentialInformationDifferenceDialog: {
        dialog: false,
        id: ''
      },
      downloadFileReport: {
        bizId: this.$route.params.fileBizId,
        fileType: 'supplier_declaration_file'
      }
    }
  },
  watch: {
    judgePageData: {
      handler(val) {
        this.isViewPage = val.isViewPage
        this.pageInit()
      },
      deep: true,
      immediate: true
    }
  },
  created() {},
  methods: {
    filterDictText, // 字典值替换文本通用方法
    pageInit() {
      this.initKey() // 获取供应字典
      this.bizType = this.$route.params.bizType || ''
      // 判断是否是变更审
      this.ChangeDetailBtn = this.bizType === '02' ? [] : false
      if (this.$route.meta.type === 'audit') {
        // 判断是否是申报审核
        this.reviewSource = this.bizType === '01' ? [] : false
        // 判断是否是变更审核页面
        this.isViewPage = this.bizType === '02' ? '' : '01'
        // 判断是否是申报审核页面
        this.declarationId = this.bizType === '01' ? this.$route.params.bizId : ''
      }
      if (this.$route.meta.type === 'declarationFirst' || this.$route.meta.type === 'declarationChange' || this.$route.meta.type === 'audit' || this.judgePageData.detailType === 'dialog') {
        // declarationFirst 编辑申报材料查看 declarationChange 申报材料变更时 audit 初审审核时
        this.getUpdateDepartInfo()// 获取编辑申报材料/初审基本信息
      } else { // 入库审核
        this.queryDeclarationInfo()// 查询审核申报材入库审核基本信息
      }
    },
    // 下载
    downloadFile() {
      const departId = this.departId // 供应商id
      downBaseInfoSupplierDocx(departId).then((res) => {
        download(res, '供应商基本信息.docx')
      })
    },
    // 获取编辑申报材料/初审基本信息
    getUpdateDepartInfo() {
      const params = {
        departId: this.departId,
        declarationId: this.declarationId, // 申报id
        isViewPage: this.isViewPage // 判断是否为变更数据
      }
      getUpdateDepartInfo(params).then((response) => {
        this.assemblyData(response)// 组装数据
      })
    },
    // 查询审核申报材入库审核基本信息
    queryDeclarationInfo() {
      queryDeclarationInfo(this.departId).then((response) => {
        this.assemblyData(response)// 组装数据
      })
    },
    // 组装数据
    assemblyData(response) {
      const { info, finance, showStatus, declarationAuditStatus } = response.data
      this.$emit('showStatuschage', showStatus, declarationAuditStatus) // 传给父集组件参数-审核状态-审核图片展示
      if (info) {
        this.formData = { ...info, finance: finance || this.formData.finance }// 基本信息部分
      }
      this.showStatus = showStatus// 展示状态 00查看 01可编辑 02可编辑
      if (this.formData.foundingTime) this.formData.foundingTime = this.$Moment(this.formData.foundingTime).format(this.momentDate)// 单位成立日期
      if (this.formData.longTerm === '01') { // 有效期至为长期
        this.formData.effectiveEndDate = '长期'
      } else { // 有效期至非长期
        if (this.formData.effectiveEndDate) this.formData.effectiveEndDate = this.$Moment(this.formData.effectiveEndDate).format(this.momentDate)// 有效期至
      }
      // 附件主键Id
      this.businessLicenseData.bizId = this.formData.id // 营业执照扫描件
      this.principalData.bizId = this.formData.id // 法人/负责人身份证号或护照号
      this.accountLicenceData.bizId = this.formData.id // 开户许可证
      this.essentialInformationDifferenceDialog.id = response.data.info.id // 机构id
    },
    // 查看变更内容弹框
    handleChangeDetail() {
      this.essentialInformationDifferenceDialog.dialog = true
    }
  }
}
</script>

<style lang="less" scoped>
  .left10 {
    margin-left: 10px;
  }
</style>
