<template>
  <div id="other">
    <el-row>
      <el-col :span="24">
        <el-tabs v-model="activeName" :before-leave="handleClick">
          <el-tab-pane v-for="(item, index) in otherList" :key="index" :label="item.title" :name="`${index}`">
            <el-col
              :span="24"
              class="listinfo"
              v-for="(child, index) in item.children"
              :key="index"
              @click.native="$router.push({ path: `/master/detail/news/${child.id}` })"
            >
              <el-col :span="20">
                <span class="qiu"></span>
                <el-link :underline="false">
                  <p class="title">{{ child.title }}</p>
                </el-link>
              </el-col>
              <el-col :span="4" class="date">
                {{ child.publish_time }}
              </el-col>
            </el-col>
          </el-tab-pane>
        </el-tabs>
        <el-link :underline="false" class="add" @click="turnTo()"><i class="el-icon-plus"></i></el-link>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'other',
  props: {
    otherList: null,
  },
  components: {},
  data: () => ({
    activeName: '0',
  }),
  created() {},
  computed: {},
  methods: {
    turnTo() {
      let to = this.otherList[`${this.activeName}`];
      if (!to) return false;
      let title = to.title;
      let path;
      if (to.type === 'bugList') path = `/master/notice/${to.content_id}?title=${title}&news_type=0`;
      if (to.type === 'column') path = `/master/notice/${to.id}?title=${title}&news_type=1`;
      this.$router.push({ path: path });
    },
    handleClick(active, old) {
      //略过加载时处理,只有点击后才会走判断逻辑
      if (!old) return true;
      let to = this.recruitList[`${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: `/master/detail/news/${to.content_id}` });
    },
  },
};
</script>

<style lang="less" scoped>
p {
  margin: 0;
  padding: 0;
}
.add {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 20px;
  height: 20px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  color: #000;
  background: #fff;
  font-weight: bold;
}
/deep/.el-tabs__header {
  margin: 0;
  background: #415285;
}
/deep/.el-tabs__item {
  color: #bfc4d3;
  font-size: 18px;
  height: 50px;
  line-height: 50px;
}
/deep/.el-tabs__item.is-active {
  color: #fff;
}
/deep/.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
  padding-left: 20px;
}
/deep/.el-tabs__active-bar {
  background-color: transparent;
}
/deep/.el-tabs__nav-wrap::after {
  background-color: transparent;
}
.qiu {
  display: inline-block;
  width: 4px;
  height: 5px;
  background: #999;
  margin: 0 15px;
}
.listinfo {
  padding: 20px 0;
}
.listinfo .el-link {
  font-size: 16px;
  color: #000;
}
.listinfo:hover .el-link {
  color: #415285;
}
.listinfo .date {
  font-size: 18px;
  color: #999;
}
</style>
