<template>
  <div id="" class="page-body">
    <div class="page-header">
      <h1 class="page-title">数据样品信息汇交</h1>
      <el-breadcrumb>
        <el-breadcrumb-item :to="{path: '/'}">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{name: 'VoyageReg'}">数据汇交</el-breadcrumb-item>
        <el-breadcrumb-item>样品数据集管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="filter-container">
      <div class="checkBtn">
        <el-button
          v-for="item in btnList"
          :key="item.value"
          :type="item.value === currentValue ? 'primary' : ''"
          size="medium"
          @click="handleBtn(item)"
        >{{ item.label }}</el-button>
      </div>
    </div>
    <!--新增数据集-->
    <add-data v-if="currentValue === 'add'" />
    <!--编辑数据集-->
    <add-data v-if="currentValue === 'edit'" />
    <!--数据集列表-->
    <data-list v-if="currentValue === 'list'" @edit="handleEdit" />
    <!--测线数据样品汇交-->
    <line-list v-if="currentValue === 'line'" @edit="handleEdit" />
    <!--站位数据样品汇交-->
    <station-list v-if="currentValue === 'station'" @edit="handleEdit" />
  </div>
</template>

<script>
import AddData from '@/views/dataTransfer/sampleViews/AddData'
import DataList from '@/views/dataTransfer/sampleViews/DataList'
import LineList from '@/views/dataTransfer/sampleViews/LineList'
import StationList from '@/views/dataTransfer/sampleViews/StationList'
export default {
  name: 'SampleDataset',
  components: { AddData, DataList, LineList, StationList },
  data() {
    return {
      btnList: [
        {
          label: '新增数据集',
          value: 'add'
        },
        {
          label: '数据集列表',
          value: 'list'
        },
        {
          label: '测线数据样品汇交',
          value: 'line'
        },
        {
          label: '站位数据样品汇交',
          value: 'station'
        },
        {
          label: '批量导入样品',
          value: 'sample'
        },
        {
          label: '批量导入下潜轨迹',
          value: 'track'
        }
      ],
      currentValue: 'add',
      row: {},
      id: null
    }
  },
  created() {

  },
  methods: {
    handleBtn(item) {
      if (item.value === 'sample') {

      } else {
        this.currentValue = item.value
        if (item.value === 'edit') {
          return false
        } else if (item.value === 'add') {
          this.$store.commit('SET_ROW', {})
          this.$store.commit('SET_ID', null)
        } else {
          this.btnList[0] = {
            label: '新增数据集',
            value: 'add'
          }
        }
      }
    },
    handleEdit(row) {
      this.currentValue = 'edit'
      this.btnList[0] = {
        label: '数据集详细信息',
        value: 'edit'
      }
      this.$store.commit('SET_ROW', row)
      this.$store.commit('SET_ID', row.tsy_id)
    }
  }
}
</script>

