<template>
  <div id="cause">
    <el-row>
      <el-col :span="24" v-if="enterList && enterList.length > 0">
        <el-tabs v-model="activeName" type="border-card" :before-leave="handleClick">
          <el-tab-pane v-for="(item, index) in enterList" :key="index">
            <span slot="label">{{ item.title }}</span>
            <el-col :span="24" v-for="(tag, index) in item.children" :key="index" class="enterList">
              <el-col :span="20" class="title textOver">
                <el-link :underline="false" @click="$turnTo(tag)" :title="tag.title">{{ tag.title }} </el-link>
              </el-col>
              <el-col :span="4" class="time">
                {{ tag.publish_time }}
              </el-col>
            </el-col>
          </el-tab-pane>
        </el-tabs>
        <el-link :inderline="false" class="moreLink" :style="`color:${Color}`" @click="moreClick()">MORE<i class="el-icon-video-play"></i> </el-link>
      </el-col>
      <el-col :span="24" v-else>
        <no-data></no-data>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import noData from '@publics/src/layout/noData.vue';
export default {
  name: 'cause',
  props: {
    enterList: null,
  },
  components: {
    noData,
  },
  data: () => ({
    activeName: '',
    Color: '#850000',
  }),
  created() {},
  computed: {},
  methods: {
    moreClick() {
      let to = this.enterList[`${this.activeName}`];
      if (!to) return false;
      if (to.type === 'bugList') this.$router.push({ path: `/info/list/${to.content_id}?news_type=0` });
      if (to.type === 'column') this.$router.push({ path: `/info/list/${to.id}` });
    },
    handleClick(active, old) {
      //略过加载时处理,只有点击后才会走判断逻辑
      if (!old) return true;
      let to = this.enterList[`${active}`];
      if (!to) return false;
      if (to.type === 'bugList' || to.type === 'column') return true;
      if (to.type === 'url') window.open(to.url);
      if (to.type === 'content') this.$router.push({ path: `/info/detail?id=${to.content_id}` });
    },
    detailBtn(tag) {
      console.log(tag);
    },
  },
};
</script>

<style lang="less" scoped>
.moreLink {
  position: absolute;
  top: 10px;
  right: 10px;
  color: #850000;
}
/deep/.el-tabs__header {
  margin: 0;
}
/deep/.el-tabs--border-card > .el-tabs__content {
  padding: 0;
}
.talksList {
  padding: 12px 10px;
  border-bottom: 1px dashed #ccc;
}
.talksList .title .el-link {
  font-size: 18px;
}
.textOver {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.enterList {
  padding: 10px;
  border-bottom: 1px dashed #ccc;
}
.enterList .title .el-link {
  font-size: 18px;
}
.enterList .time {
  font-size: 18px;
  text-align: right;
}
.teacherList {
  padding: 10px;
  border-bottom: 1px dashed #ccc;
}
.teacherList .title .el-link {
  font-size: 18px;
}
.teacherList .time {
  font-size: 18px;
  text-align: right;
}
</style>
