<template>
  <div id="dataInfo">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="top">
          <el-button type="primary" size="mini" @click="back">返回</el-button>
        </el-col>
        <el-col :span="24" class="down">
          <el-tabs v-model="active" type="card">
            <el-tab-pane label="（一）基本信息" name="first">
              <basic :info="form.basic"></basic>
            </el-tab-pane>
            <el-tab-pane label="（二）内容简介" name="second">
              <brief :info="form.brief"></brief>
            </el-tab-pane>
            <el-tab-pane label="（三）主研人员名单" name="third">
              <research :list="form.research"></research>
            </el-tab-pane>
            <el-tab-pane label="（四）评价委托方提供资料清单" name="fourth">
              <detailed :linkInfo="form.datalist"></detailed>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import basic from './parts/basic.vue';
import brief from './parts/brief.vue';
import research from './parts/research.vue';
import detailed from './parts/detailed.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: achieveApply } = createNamespacedHelpers('achieveApply');
const { mapActions: verifyRecord } = createNamespacedHelpers('verifyRecord');
export default {
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  name: 'dataInfo',
  props: {},
  components: {
    basic,
    brief,
    research,
    detailed,
  },
  data: function() {
    return {
      // 标签
      active: 'first',
      form: {
        basic: {},
        brief: {},
        research: [],
        datalist: {},
      },
    };
  },
  created() {
    if (this.id) this.search();
  },
  methods: {
    ...achieveApply(['fetch']),
    async search() {
      const res = await this.fetch(this.id);
      if (this.$checkRes(res)) {
        console.log(res.data);
        this.$set(this, 'form', res.data);
      }
    },
    // 返回
    back() {
      window.history.back();
    },
  },
  computed: {
    ...mapState(['user']),
    id() {
      return this.$route.query.id;
    },
  },
  watch: {},
};
</script>

<style lang="less" scoped>
.main {
  .top {
    margin: 0 0 10px 0;
    text-align: right;
  }
  .down {
    .fiveth {
      padding: 0 20%;
      .btn {
        text-align: center;
      }
    }
  }
}
</style>
