<template>
  <div class="study-syxx">
    <div class="syxx-top" v-show="!showDetail" style="margin-bottom: 10px;">
      <div class="syxx-operate">
        <div class="operate-img"></div>
        <div class="operate-left">{{ $t('page.business.study.studyFormPlan.syxx') }}</div>
      </div>
      <el-form ref="form" label-width="90px">
        <el-row>
          <el-col :span="6">
            <el-form-item :label="$t('page.business.study.studyFormPlan.symc')">
              {{ studyInfo.name }}
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('page.business.study.studyFormPlan.sybh')">
              {{ studyInfo.sn }}
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('page.business.study.studyFormPlan.syfzr')">
              {{ studyInfo.leaderName }}
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('page.business.study.studyFormPlan.cjsj')">
              {{ studyInfo.createTime }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="syxx-content">
      <div class="search-box" v-show="!showDetail">
        <div class="search-item" :class="active === item.key ? 'active' : ''" v-for="(item, index) in tabList"
          :key="index" @click="changeTab(item)">
          {{ item.name }}
        </div>
      </div>
       <div class="content-box">
        <sjList v-if="active === 'sjlb'" :study="studyInfo" @showDetail="showDetailCallback" />
        <gspList v-if="active === 'gsplb'" :study="studyInfo" @showDetail="showDetailCallback" />
        <gyzjList v-if="active === 'gyzjlb'" :study="studyInfo" @showDetail="showDetailCallback" />
        <mjyList v-if="active === 'mjylb'" :study="studyInfo" @showDetail="showDetailCallback"/>
        <cellList v-if="active === 'xblb'" :study="studyInfo" @showDetail="showDetailCallback"/>
        <bacteriaList v-if="active === 'xjlb'" :study="studyInfo" @showDetail="showDetailCallback"/>
      </div>
    </div>

  </div>
</template>

<script>
import { checkPermi, checkRole } from "@/utils/permission";
import { study_info } from "@/api/business/study/study"
import gyzjList from './wzlb/gyzjList.vue'
import sjList from './wzlb/sjList.vue'
import gspList from './wzlb/gspList.vue'
import cellList from './wzlb/cellList.vue'
import bacteriaList from './wzlb/bacteriaList.vue'
export default {
  name: 'StudyWzlb',
  props: {
    study: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  watch: {
    study: {
      immediate: true,
      handler(v) {
        this.studyId = v.id
        this.getStudyInfo()
      }
    },
  },
  components: {gyzjList, sjList, gspList, cellList, bacteriaList},
  data() {
    return {
      showDetail: false,
      studyId: '',
      studyInfo: {},
      tabList: [
        { key: 'sjlb', name: this.$t('page.business.study.studyEnter.sjlb') },
        { key: 'gsplb', name: this.$t('page.business.study.studyEnter.gsplb') },
        { key: 'gyzjlb', name: this.$t('page.business.study.studyEnter.gyzjlb') },
        { key: 'xblb', name: this.$t('page.business.study.studyEnter.xblb') },
        { key: 'xjlb', name: this.$t('page.business.study.studyEnter.xjlb') }
      ],
      active: 'sjlb',
    }
  },
  created() {
  },
  methods: {
    checkPermi,
    checkRole,
    getStudyInfo() {
      this.$modal.loading()
      study_info({ id: this.studyId }).then(response => {
        this.studyInfo = response.data
        this.$modal.closeLoading()
      }).finally(() => {
        this.$modal.closeLoading()
      })
    },
    showDetailCallback(val) {
      this.showDetail = val
      this.$emit('showDetail', val)
    },
    changeTab(item) {
      if (this.active !== item.key) {
        this.active = item.key
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.study-syxx {
 .search-box {
    background: #fff;
    padding: 0;
    border-radius: 3px;
    margin-bottom: 10px;

    display: flex;
    flex-direction: row;
    align-items: center;

    .search-item {
      padding: 10px 20px;
      font-size: 14px;
      cursor: pointer;

      &.active {
        background: #1890ff;
        color: #fff;
      }

      &:hover {
        background: #46a6ff;
        color: #fff;
      }

      &:first-child {
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
      }

      &:last-child {
        border-top-right-radius: 3px;
        border-bottom-right-radius: 3px;
      }
    }
  }
  .syxx-top {
    background: #fff;
    padding: 20px;
    width: 100%;

    .syxx-operate {
      margin: 0px 0 10px 0;
      display: flex;
      flex-direction: row;
      align-items: center;
      color: #409eff;

      .operate-img {
        flex-shrink: 0;
        height: 15px;
        background: #409eff;
        width: 3px;
      }

      .operate-left {
        flex-shrink: 0;
        font-weight: bold;
        padding-left: 10px;
      }

      .operate-right {
        flex-grow: 1;
        text-align: right;

        .operate-icon {
          cursor: pointer;
        }
      }
    }
  }

  .syxx-content {}
}
</style>
