<template>
  <div class="app-content layoutEmbedded" style="height: 76vh;overflow: auto;">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <div class="page-content">
        <a-tabs type="card" hideAdd size="small" @change="callback">
          <a-tab-pane :key="item.key" :tab="item.title" v-for="(item) in tabsData">
          </a-tab-pane>
        </a-tabs>
      </div>
      <div class="page-footer">
        <a-button type="primary" @click="onTalentExport">导出</a-button>
        <talent-info v-model="formData" :tabsData.sync="tabsData" />
      </div>
    </a-spin>
  </div>
</template>

<script>
import talentInfo from '@/views/report/talent/components/talentInfo'

export default {
  name: "talentView",
  components: {
    talentInfo
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null
      }
    },
  },
  data() {
    return {
      tabsData: [
        { title: '全部', key: '0', isShow: true },
        { title: '申报人基本情况', key: '1', isShow: true },
        { title: '申报人简历', key: '2', isShow: true },
        { title: '申报人科研成绩', key: '3', isShow: true },
        { title: '科学研究规划及团队人员名单', key: '4', isShow: true },
        { title: '经费预算及培养计划和目标', key: '5', isShow: true },
        { title: '附件', key: '6', isShow: true },
        { title: '项目审核记录', key: '7', isShow: true },
      ],
      formData: {
        id: null, 
        talentCategory: null,
        reportYear: null,
        certId: null,
        personId: null,
        personName: null,
        nation: null,
        sex: null,
        birthday: null,
        degree: null,
        degreeTime: null,
        degreeUnit: null,
        spec: null,
        graduateTeacher: null,
        title: null,
        politicalParty: null,
        duty: null,
        talentType: null,
        honoraryTitle: null,
        holdPost1: null,
        holdPost2: null,
        holdPost3: null,
        mobile: null,
        fax: null,
        technicalSkill: null,
        qualityTarget: null,
        researchCondition: null,
        researchProgress: null,
        email: null,
        applyFund: null,
        otherFund: null,
        totalFund: null,
        planTarget: null,
        unitAdvice: null,
        talentState: null,
        resumeList: [],
        membersList: [],
        budgetList: [],
        scientificList: [],
        fileList: [],
        auditList: [],
      },
      loading: false,
    };
  },
  created() {
    this.getTalentApplyById()
  },
  methods: {
    getTalentApplyById() {
      if (this.value != null) {
        this.$api.talent.getTalentApplyById({ id: this.value }).then(({ data = {} }) => {
          if (data) {
            // 处理字符串转数组
            if (typeof data.talentType === 'string' && data.talentType) {
              data.talentType = data.talentType.split(',')
            }
            if (typeof data.graduateTeacher === 'string' && data.graduateTeacher) {
              data.graduateTeacher = data.graduateTeacher.split(',')
            }
            this.formData = data
            this.loading = false
          } else
            this.$emit('close', 'error')
        }).catch(() => { this.$emit('close', 'error') })
      }
    },
    callback (key) {
      var index = parseInt(key)
      this.tabsData.forEach(e => {
        if (key == '0')
          e.isShow = true
        else
          e.isShow = false
      })
      this.tabsData[0].isShow = true;
      this.tabsData[index].isShow = true;
    },
    onTalentExport () {
      
    },
  }
};
</script>

<style scoped lang="less">
::v-deep .ant-spin-container {
  width: 100%;
  height: 100%;
}
::-webkit-scrollbar {
  width: 8px;
  height: 6px;
}
.page-content {
  width: 100%;
  height: 50px;
}
.page-footer {
  width: 100%;
  height: calc(100% - 50px);
  overflow: auto;
}
</style>