<!--采集详情-->
<template>
  <div v-loading="loading" class="app-container">
    <!--显示上传状态-->
    <upload-state v-if="flgUpload" :res-upload="resUpload" :flg-upload="flgUpload"/>
    <!--识别成功显示详情-->
    <base-info v-if="baseInfo" :info="baseInfo" :show-other="true"/>
    <!--显示采集详情-->
    <collect-info-read v-if="collectInfo" :info="collectInfo"/>
    <!--生物特征详情-->
    <biosignature v-if="irisPhotos" :iris-photos="irisPhotos" :person-photo="personPhoto"/>
    <!--识别失败显示比对信息-->
    <compare-info v-if="flgUpload=='2'" :list="compareList"/>

  </div>
</template>

<script>
import BaseInfo from '@/views/irisCollect/components/baseInfoRead'
import CollectInfoRead from '@/views/irisCollect/components/collectInfoRead'
import Biosignature from '@/views/irisCollect/components/biosignature'
import UploadState from './components/uploadState'
import CompareInfo from '@/views/irisCollect/components/compareInfo'
import { getRecordsDetail } from '@/api/system/dataupload'
import { getPersonDetail } from '@/api/system/collect'
let fromPath = ''
export default {
  name: 'UploadPersonDetail',
  components: { CompareInfo, UploadState, Biosignature, CollectInfoRead, BaseInfo },
  data() {
    return {
      id: '', // 记录id
      sId: '', // 人员id
      baseInfo: null, // 基本信息
      collectInfo: null, // 采集信息
      irisPhotos: [], // 生物信息
      personPhoto: '', // 人像照片
      recognitionList: [], // 识别记录列表
      flgUpload: '', // 人证核验结果code
      flgUploadName: '', // 人证核验结果
      resUpload: '', // 核验失败原因
      recogDetail: null, // 本次识别详情，失败有效
      compareList: [], // 比对详情
      loading: true
    }
  },
  beforeRouteEnter(to, from, next) {
    fromPath = from.path
    next()
  },
  created() {
    this.id = this.$route.query.id
    this.sId = this.$route.query.sId
    this.fetchCollectDetail()
    if (fromPath === '/uploadRecords') {
      this.fetchUploadDetail()
    }
  },
  methods: {
    // 获取人员详情
    fetchCollectDetail() {
      this.loading = true
      const params = {
        sId: this.sId
      }
      getPersonDetail(params).then(response => {
        if (response.code === 200) {
          this.loading = false
          const data = response.data
          this.baseInfo = {
            name: data.name,
            photo: data.photo,
            sex: data.sex,
            sexName: data.sexName,
            nationality: data.nationality,
            nationalityName: data.nationalityName,
            nation: data.nation,
            nationName: data.nationName,
            cardType: data.cardType,
            cardTypeName: data.cardTypeName,
            idCardNo: data.idCardNo,
            birthday: data.birthday,
            age: data.age,
            authority: data.authority,
            valiDuration: data.valiDuration,
            tel1: data.tel1,
            tel2: data.tel2,
            residenceAddr: data.residenceAddr,
            liveAddr: data.liveAddr,
            hasCardFlag: data.hasCardFlag,
            hasCardFlagName: data.hasCardFlagName
          }
          this.collectInfo = {
            collReason: data.collReason,
            collReasonName: data.collReasonName,
            reasonCollDesc: data.reasonCollDesc,
            collectState: data.collectState,
            collectStateName: data.collectStateName,
            stationName: data.stationName,
            collId: data.collId,
            collName: data.collName,
            collTime: data.collTime,
            stX: data.stX,
            stY: data.stY,
            devCode: data.devCode,
            devType: data.devType,
            devTypeName: data.devTypeName,
            devProducer: data.devProducer,
            flgWo: data.flgWo,
            flgFocus: data.flgFocus,
            personTags: data.personTags,
            personSpecial: data.personSpecial,
            personTagsName: data.personTagsName,
            personSpecialName: data.personSpecialName,
            collType: data.collType,
            collTypeName: data.collTypeName,
            irisCode: data.irisCode,
            defReason: data.defReason,
            collWay: data.collWay,
            collWayName: data.collWayName,
            collSpend: data.collSpend
          }
          // 虹膜照片
          this.irisPhotos = [
            {
              irisName: '右眼虹膜',
              irisPath: data.imageR1,
              irisQuality: data.qR
            },
            {
              irisName: '左眼虹膜',
              irisPath: data.imageL1,
              irisQuality: data.qL
            }
          ]
          this.personPhoto = data.pathImage // 人像照片
        }
      })
    },
    // 获取上传成功/失败情况
    fetchUploadDetail() {
      const params = {
        id: this.id
      }
      getRecordsDetail(params).then(response => {
        if (response.code === 200) {
          const data = response.data
          this.flgUpload = data.flgUpload
          this.resUpload = data.resUpload
        }
      })
    }
  }

}
</script>

<style scoped>

</style>
