<template>
  <div id="fenlei">
    <el-col class="swfl">
      <el-image style="width:22px;height:22px;margin:0 5px -5px 0;" :src="src"></el-image>
      <span>中心科研</span>
    </el-col>
    <el-col>
      <el-menu default-active="1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" text-color="#000" active-text-color="#000">
        <el-menu-item index="1" v-for="(item, index) in liebiaoList" :key="index"
          ><span slot="title" @click="clickUrl(item.title, index)" :style="`color:${menuIndex == index ? color : ''}`">{{ item.title }}</span></el-menu-item
        >
      </el-menu>
    </el-col>
  </div>
</template>

<script>
export default {
  name: 'fenlei',
  props: {},
  components: {},
  data: () => ({
    menuIndex: '0',
    color: '#054982',
    src: require('@/assets/achieveCenter.png'),
    liebiaoList: [{ title: '平台建设' }, { title: '项目成果' }, { title: '知识产权' }, { title: '科技合作' }],
  }),
  created() {
    this.search();
  },
  computed: {
    col_name() {
      return this.$route.query.col_name;
    },
  },
  methods: {
    async search() {
      let title = this.col_name;
      if (title == '科技合作') {
        let index = 3;
        this.clickUrl(title, index);
      }
    },
    clickUrl(title, index) {
      if (title == '平台建设') {
        this.menuIndex = index;
      } else if (title == '项目成果') {
        this.menuIndex = index;
      } else if (title == '知识产权') {
        this.menuIndex = index;
      } else if (title == '科技合作') {
        this.menuIndex = index;
      }
      this.$emit('leftdaohang', title);
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style lang="less" scoped>
.swfl {
  height: 60px;
  width: 250px;
  line-height: 60px;
  background-color: #22529a;
  text-align: center;
}
.swfl span {
  font-size: 22px;
  color: #ffffff;
}
/deep/.el-menu-item {
  height: 60px;
  text-align: center;
  line-height: 60px;
  border-bottom: 1px dashed;
  font-size: 22px;
  font-weight: bold;
}
/deep/.el-menu-item:last-child {
  border-bottom: none;
}
</style>
