CanvasTab.vue
4.96 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<template>
<div class="tab" v-if="data.length > 0">
<!-- 样式占位符-->
<div class="canvas-tab flex">
<template v-for="(i, index) in data">
<div @click="click(index)" :class="['item', `${tabType.index == index ? 'active-' + i.location : 'unactive'}`]" :key="index"></div>
</template>
</div>
<div class="canvas-place-tab flex placeholder">
<template v-for="(i, index) in data">
<div @click="click(index)" :class="['item', 'text-center', `${tabType.index == index ? 'active' : ''}`]" :key="index + 'i'">{{ i.title }}</div>
</template>
</div>
<slot></slot>
</div>
</template>
<script type='text/ecmascript-6'>
import { mapState, mapMutations } from 'vuex'
export default {
name: 'CanvasTab',
watch: {
tabIndex: {
handler() {
this.initTextData()
},
immediate: true
},
outputData: {
handler() {
this.initTextData()
},
deep: true,
immediate: true
}
},
computed: {
...mapState({
reportData: state => state.report.reportData,
tabIndex: state => state.report.tabIndex,
reportType: state => state.report.reportType,
tabType: state => state.report.tabType,
userInfo: state => state.report.userInfo,
outputData: state => state.report.outputData
})
},
data() {
return {
data: [],
text: ''
}
},
mounted() {},
methods: {
...mapMutations({
SET_TABTYPE_INDEX: 'report/SET_TABTYPE_INDEX'
}),
initTextData() {
let { reportType, outputData } = this
if (reportType == 0) {
this.text = '本周'
} else {
let time = outputData.reportTimeStart.split('-')
if (parseInt(time[1]) > 9) {
this.text = time[1] + '月'
} else {
this.text = time[1] && time[1].split('')[1] + '月'
}
}
this.initData()
},
initData() {
let {
userInfo: { accountLevel },
reportType,
text,
tabIndex
} = this
if (accountLevel !== 4 && tabIndex == 0) {
//集团客户周月报
if (reportType == 0) {
this.data = [
{ title: '企微客户占比', location: 'left' },
{ title: '新增企微客户数 ', location: 'right' }
]
} else {
this.data = [
{ title: '企微客户占比', location: 'left' },
{ title: '新增企微客户数 ', location: 'center' },
{ title: '新增客户趋势', location: 'right' }
]
}
} else if (accountLevel == 4 && tabIndex == 0) {
//门店客户周月报
if (reportType == 1) {
this.data = [
{ title: '新增客户趋势', location: 'left' },
{ title: '新增客户分布', location: 'right' }
]
} else {
this.data = []
}
} else if (accountLevel !== 4 && tabIndex == 1) {
//集团产值周月报
if (reportType == 0) {
this.data = [
{ title: `${text}门店产值排行`, location: 'left' },
{ title: '新增产值分布', location: 'right' }
]
} else {
this.data = [
{ title: `${text}门店产值`, location: 'left' },
{ title: '新增产值分布', location: 'center' },
{ title: '新增产值趋势', location: 'right' }
]
}
} else {
//门店产值月报
if (reportType == 1) {
this.data = [
{ title: '新增产值趋势', location: 'left' },
{ title: '新增产值分布', location: 'right' }
]
} else {
this.data = []
}
}
},
click(index) {
this.$emit('change', index)
}
}
}
</script>
<style scoped lang='scss'>
.tab {
margin: 30px 0 80px 0;
height: auto;
box-shadow: 0px 3px 10px 0px rgba(223, 228, 234, 0.81);
border-radius: 4px;
position: relative;
background-color: #fff;
.canvas-tab {
width: 100%;
height: 50px;
box-sizing: border-box;
background-color: #dfe7f1;
.item {
width: 50%;
// transition: all 0.5s;
font-size: 14px;
}
.active-left {
height: 0;
border-bottom: 50px solid #ffffff;
border-right: 10px solid transparent;
}
.active-right {
height: 0;
border-bottom: 50px solid #ffffff;
border-left: 10px solid transparent;
}
.active-center {
height: 0;
border-bottom: 50px solid #ffffff;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
}
}
.canvas-place-tab {
width: 100%;
height: 50px;
box-sizing: border-box;
font-size: 12px;
color: #333333;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 9;
.item {
color: #333333;
flex: 1;
// transition: all 0.5s;
font-size: 14px;
}
.active {
color: #3975c6;
height: 50px;
}
}
}
</style>