<template>
  <div class='flex flex-justify-start'>
    <div class="full-height">
      <pro-left :data="data" :code='code' @success='listSucc'/>
    </div>
    <div style='margin-left: 300px' class='full-width'>
      <basic-container>
        <basic-tab :tabs='tabs' @change='change'></basic-tab>
      </basic-container>
      <basic-container style='margin-top: 0'>
        <div v-if='currentTab.value === 1'>
          <div v-for='(item,index) in resultList' :key='item.id'>
            <a :href='`#header`+(index+1)'>
              <div class='full-width' :id="`header`+(index+1)">
                <params1 v-if='item.dictKey === "1" ' :info='item'/>
              </div>
            </a>
          </div>
        </div>
        <div v-else-if='currentTab.value === 2'>
          <div v-for='(item,index) in resultList' :key='item.id'>
            <a :href='`#header`+(index+1)'>
              <div class='full-width' :id="`header`+(index+1)">
                <inspect1 v-if='item.dictKey === "1" ' :info='item'/>
              </div>
            </a>
          </div>
        </div>
        <div v-else-if='currentTab.value === 3'>
          tab3
        </div>
      </basic-container>
    </div>
  </div>
</template>
<route>
{
name: '项目详情',
meta: { keepAlive: true }
}
</route>

<script>
import proLeft from '@/views/home/component/pro_left.vue'
import BasicContainer from '@/components/basic-container/main.vue'
import BasicTab from '@/components/basic-tab/index.vue'
import params1 from '@/views/home/component/params/params1.vue'
import inspect1 from '@/views/home/component/inspect/Inspect1.vue'

export default {
  name: 'pro_detail',
  components: { BasicContainer, proLeft, BasicTab, params1, inspect1 },
  data () {
    return {
      id: '',
      data: {},
      tabs: [
        { name: '项目信息管理', value: 1, code: 'params_type' },
        { name: '项目督查情况', value: 2, code: 'inspect_type' },
        { name: '项目数据明细管理', value: 3 }
      ],
      currentTab: null,
      resultList: [],
      code: 'params_type'
    }
  },
  created () {
    this.id = this.$route.query.id
    this.currentTab = this.tabs[0]
    this.proInfo()
  },
  methods: {
    change (res, index) {
      this.currentTab = res
      this.code = this.currentTab.code
    },
    /**
     * 项目信息
     */
    proInfo () {
      this.$api.project.projectInfo(this.id).then(res => {
        if (res.code === 200) {
          this.data = res.data
        }
      })
    },
    listSucc (list) {
      this.resultList = list
    }
  }
}
</script>

<style scoped>

</style>
