123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- <template>
- <div class="category">
- <div type="primary" class="title">
- <div class="flex lg">
- <i class="el-icon-s-fold"></i>
- <div class="m-l-8">人才图谱分类</div>
- </div>
- </div>
- <div class="category-con bg-white" v-show="category.length && showCate">
- <ul class="category-one">
- <li v-for="(item, index) in cateList" :key="index" :class="{ active: index === selectIndex }"
- @click="changeActive(index)">
- <div class="flex row-between">
- <span class="line-1">{{ item.title }}</span>
- <i v-if="item.children.length"
- :class="index === selectIndex ? 'el-icon-arrow-down' : 'el-icon-arrow-right'"></i>
- </div>
- <ul class="category-two" v-show="index === selectIndex">
- <li v-for="(itemTwo, indexTwo) in cateTwoList" :key="indexTwo"
- @click.stop="changeTwoActive(indexTwo)" :class="{ active: indexTwo === selectTowIndex }">
- <div class="flex row-center">
- <span class="line-1">{{ itemTwo.title }}</span>
- </div>
- </li>
- </ul>
- </li>
- <div class="category-float bg-white" v-show="showCateFloat && cateTwoList.length">
- <div class="float-con">
- <div class="m-t-16" v-for="(item, index) in cateTwoList" :key="index">
- <div class="category-two weight-500 m-b-15">
- <nuxt-link :to="`/category?id=${item.id}`">{{
- item.title
- }}</nuxt-link>
- </div>
- <div class="category-three flex flex-wrap">
- <div class="item" v-for="(titem, idx) in item.children" :key="idx">
- <nuxt-link :to="`/category?id=${titem.id}`" class="flex">
- <!-- <el-image-->
- <!-- style="width: 48px; height: 48px"-->
- <!-- :src="titem.image"-->
- <!-- fit="contain"-->
- <!-- ></el-image>-->
- <span class="m-l-8">{{
- titem.title
- }}</span>
- </nuxt-link>
- </div>
- </div>
- </div>
- </div>
- </div>
- </ul>
- </div>
- </div>
- </template>
- <script>
- import {
- mapState
- } from 'vuex'
- export default {
- data() {
- return {
- cateList: [],
- selectIndex: 0, //一级分类索引
- selectTowIndex: 0, //二级分类索引
- cateTwoList: [], //二级分类列表
- cateThreeList: [], //三级分类列表
- cateTwoId: 0,
- showCate: true,
- showCateFloat: false,
- //产业链配置
- currentTab: 0,
- }
- },
- created() {},
- mounted() {},
- updated() {},
- methods: {
- changeActive(index) {
- this.selectIndex = index
- this.selectTowIndex = 0 //二级分类索引重置0
- this.cateTwoList = this.cateList[this.selectIndex].children
- this.cateThreeSet()
- },
- changeTwoActive(index) {
- this.selectTowIndex = index
- this.cateThreeSet()
- console.log(this.selectTowIndex)
- this.$forceUpdate()
- },
- //产业链
- cateThreeSet() {
- this.cateTwoId = this.cateTwoList[this.selectTowIndex].id
- let children = this.cateTwoList[this.selectTowIndex].children.slice()
- if (children[0].title != '全部') {
- children.unshift({
- type: 1,
- pid: this.cateTwoId,
- title: '全部'
- })
- }
- this.currentTab = 0;
- this.cateThreeList = children.filter((item, index) => item.type == 1)
- if (this.cateThreeList.length > 0) {
- this.$emit('chain', this.cateThreeList)
- } else {
- // this.cateTwoId = 0;
- }
- },
- },
- watch: {
- $route: {
- immediate: true,
- handler: function(val) {
- this.showCate = val.path == '/' ? true : false
- },
- },
- category: {
- handler: function(val) {
- this.cateList = val.slice()
- if (this.cateList.length > 0) {
- this.cateTwoList = this.cateList[this.selectIndex].children
- this.cateThreeSet()
- }
- },
- immediate: true,
- deep: false,
- }
- },
- computed: {
- ...mapState(['category']),
- },
- }
- </script>
- <style lang="scss" scoped>
- .category {
- position: relative;
- .title {
- padding: 12px 20px;
- flex: none;
- width: 160px;
- box-sizing: border-box;
- border-radius: 0;
- background: $--color-primary;
- color: white;
- }
- .category-con {
- position: absolute;
- width: 100%;
- z-index: 999;
- height: 440px;
- padding: 10px 0;
- box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
- cursor: pointer;
- .category-one {
- height: 100%;
- overflow-y: auto;
- &::-webkit-scrollbar {
- display: none;
- /*隐藏滚动条*/
- }
- &>li {
- border-bottom: $--border-base;
- &>a {
- height: 42px;
- padding: 0 20px;
- }
- &>div {
- height: 42px;
- padding: 0 20px;
- }
- &.active {
- // background-color: #ffeeef;
- &>div {
- color: $--color-primary;
- font-weight: bold;
- }
- }
- }
- .category-float {
- box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
- position: absolute;
- left: 160px;
- top: 0;
- width: 880px;
- height: 440px;
- padding: 0 24px;
- overflow-y: auto;
- &::-webkit-scrollbar {
- display: none;
- /*隐藏滚动条*/
- }
- a:hover {
- color: #ff2c3c;
- }
- .float-con {
- .category-three {
- border-bottom: 1px dashed $--border-color-base;
- .item {
- width: 20%;
- margin-bottom: 20px;
- padding-right: 10px;
- }
- }
- }
- }
- }
- .category-two {
- height: 100%;
- overflow-y: auto;
- &::-webkit-scrollbar {
- display: none;
- /*隐藏滚动条*/
- }
- &>li {
- &>a {
- height: 42px;
- padding: 0 20px;
- }
- &>div {
- height: 42px;
- padding: 0 20px;
- }
- &.active {
- // background-color: #ffeeef;
- div {
- color: $--color-primary;
- font-weight: bold;
- }
- }
- }
- .category-float {
- box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
- position: absolute;
- left: 160px;
- top: 0;
- width: 880px;
- height: 440px;
- padding: 0 24px;
- overflow-y: auto;
- &::-webkit-scrollbar {
- display: none;
- /*隐藏滚动条*/
- }
- a:hover {
- color: #ff2c3c;
- }
- .float-con {
- .category-three {
- border-bottom: 1px dashed $--border-color-base;
- .item {
- width: 20%;
- margin-bottom: 20px;
- padding-right: 10px;
- }
- }
- }
- }
- }
- }
- }
- </style>
|