ann0707
2018-08-16 c9bc8ec61cff4076132f6396d99d383a2cdf5a03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
    <div>
        <div class="filter-tab">
            <span v-for="(item, index) in filterTab"
                  :key="index"
                  :class="{selected: activeIndex === index || (item.isPullDown && item.pullDownActive)}"
                  @click="handleFilterTab(index)">
            {{ item.content }}
            <i class="iconfont icon-triangledown-fill"
               :class="{'icon-triangleup-fill': item.activeTriangle }"
               v-if="item.isPullDown"></i>
            </span>
        </div>
        <div class="vux-1px-b"></div>
    </div>
</template>
 
<script>
    /**
     * Created by c.y on 2018/3/16.
     * 组件的命名 项目名(F---filean) + 组件的描述(区别与框架的组件)
     * 贷款的筛选tab
     * 如果要使用这个组件,需要传递如下数组值
     *  * filterTab: [
     {
         isPullDown: true, // 是否有下拉选项(即三角形)
         content: '筛选条件1',
         pullDownActive: false, // 这个筛选条件是可以携带的,及点击一次就选中,后面一直选中,
         activeTriangle: false // 下拉筛选三角形显示问题,列表展开三角形向上,收起三角形向下
     },
     {
         isPullDown: false,
         content: '筛选条件2',
         pullDownActive: false
     },
     {
         isPullDown: false,
         content: '筛选条件3',
         pullDownActive: false
     }
     ]
     *
     */
    export default {
        name: 'filter-tab',
        data () {
            return {
                activeIndex: -1, // 初始化时候,都没选中
            }
        },
        methods: {
            // 点击筛选tab
            handleFilterTab (index) {
                this.activeIndex = index;
                // 把当前点击的元素,传递给父组件
                this.$emit('on-click-tab', this.filterTab[index], index);
            }
        },
        props: {
            filterTab: {
                type: Array,
                required: true
            }
        },
        deactivated(){
            this.activeIndex = -1;
        }
    }
</script>
 
<style lang="less">
    @import "../../style/mixin";
 
    .filter-tab {
        position: relative;
        width: 100%;
        height: 32px;
        font-size: @font-size-small;
        line-height: 32px;
        color: @color-text-primary;
        .flexLayout();
        background: @color-white;
        span {
            flex: 1;
            text-align: center;
        }
        .selected {
            color: @color-primary;
        }
        .iconfont {
            font-size: @font-size-tiny;
        }
    }
</style>