MainTab.vue
3.18 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
<div class="tab-box flex">
<div class="flex">
<div v-for="(item, index) in tabList" :key="index" class="tab-item" :class="tabActive == index ? 'tab-item-active' : ''" @click="changeTab(index)">{{ item }}</div>
</div>
<div class="flex" v-show="showMonth">
<span class="month-text">统计月份:</span>
<div class="month-plugin">
<div class="month" @click.stop="switchMonth">
{{ month || '全部' }}
<img class="arrow-down" src="@/assets/images/arrow-down.png" alt="" />
</div>
<SelectBox
:isShow="isShow"
isObject
:defaultValue.sync="defaultMonth"
@clickOutside="clickOutside"
:dataList.sync="dataList"
:boxWidth="'8.61vw'"
@selectVal="selectVal"
:valueName="'statMonth'"
></SelectBox>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'MainTab',
props: {
tabList: {
type: Array,
default: () => []
}
},
data() {
return {
tabActive: 0,
isShow: false,
showMonth: true,
defaultMonth: {
label: new Date().format('yyyy-MM'),
statMonth: new Date().format('yyyy-MM')
},
dataList: [],
month: ''
}
},
created() {
this.getMonth()
},
mounted() {},
methods: {
async getMonth() {
const _result = await this.api.crowdFunding.getMonth()
const _dataList = _result.data.dataList
_dataList.forEach(item => {
this.dataList.push({
label: item.statMonth,
statMonth: item.statMonth
})
})
this.defaultMonth = this.month = this.dataList[0].statMonth
this.$bus.$emit('crowdFundingMonth', this.dataList[0].statMonth)
},
// tab切换
changeTab(index) {
this.tabActive = index
this.showMonth = index === 0
this.$emit('tabChange', index)
},
switchMonth() {
this.isShow = !this.isShow
},
selectVal(val) {
this.defaultMonth = this.month = val.statMonth
this.$bus.$emit('crowdFundingMonth', val.statMonth)
this.switchMonth()
},
clickOutside() {
this.isShow = false
}
}
}
</script>
<style lang="scss" scoped>
.tab-box {
height: 6.22vh;
justify-content: space-between;
padding: 1.11vh 0.83vw;
box-sizing: border-box;
background: #091c40;
.tab-item {
height: 4vh;
line-height: 4vh;
font-weight: 400;
font-size: 14px;
color: #c9c9c9;
padding: 0 1.39vw;
cursor: pointer;
}
.tab-item-active {
font-weight: 500;
font-size: 16px;
color: #ffffff;
background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%);
}
.month-text {
font-weight: 400;
font-size: 14px;
color: #c9c9c9;
}
.month-plugin {
position: relative;
}
.month {
display: flex;
align-items: center;
justify-content: space-between;
width: 8.61vw;
height: 4vh;
padding: 0 0.56vw;
box-sizing: border-box;
background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%);
margin-right: 0.56vw;
color: #ffffff;
.arrow-down {
width: 0.69vw;
height: 0.67vh;
}
}
}
.flex {
display: flex;
}
</style>