<template>
  <div class="study-tbbd">
    <div class="tbbd-left" v-show="!showDetail">
      <sbject :study="study" @change="changeSubject" />
    </div>
    <div class="tbbd-right" v-if="studyInfo.studySubjectId!='' && studyInfo.studySubjectId!=undefined">
      <tbbdList :study="studyInfo" :selectedDeptId="selectedDeptId" @showDetail="showDetailCallback" @changeTab="changeTab"/>
    </div>
  </div>
</template>

<script>
import sbject from './suject.vue'
import tbbdList from './tbbdList.vue'
export default {
  name: 'StudyTbbd',
  props: {
    study:{
      type:Object,
      default:()=>{
        return {}
      }
    }
  },
  watch:{
    study: {
      immediate: true,
      deep:true,
      handler(v) {
        this.studyInfo = _.merge({studySubjectId:''},v)
      },
    },
  },
  components: {sbject,tbbdList},
  computed: {},
  filters: {},
  data() {
    return {
      showDetail:false,
      studyInfo:{
        studySubjectId:''
      },
      selectedDeptId:''
    }
  },
  created() {},
  methods: {
    changeSubject(val,deptId){
      this.studyInfo.studySubjectId = val
      this.selectedDeptId = deptId || ''
    },
    showDetailCallback(val){
      this.showDetail=val
      this.$emit('showDetail',val)
    },
    changeTab(val){
      this.$emit('changeTab',val)
    }
  }
}
</script>
<style lang="scss" scoped>
.study-tbbd {
  display: flex;
  flex-direction: row;
  .tbbd-left {
    background: #fff;
    padding: 20px;
    margin-right: 10px;
    flex-shrink: 0;
    width: 350px;
  }
  .tbbd-right{
    flex-grow: 1;
    overflow: hidden;
  }
}
</style>
