DigitalMarketingLeft.vue
4.97 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
<template>
<div class="marketing-left">
<PullDownSelect ref="leftDownSelect" :selectList="selectList" @selectVal="selectVal"></PullDownSelect>
<inner-tab class="inner-tab" v-if="tabShow" :list="tabList" :width="6.4" :itemPadding="0.5" @changeTab="changeTab"></inner-tab>
<BarChart v-if="chartShow" ref="trendChartRef" domId="trendChart" :label="'statMonth'" height="22vh" :colorList="colorList" :valueName="valueName"></BarChart>
<LineChart v-if="!chartShow" ref="monthIncomeLineChartRef" domId="monthIncomeLineChart" :height="'18vh'" :valName="valName"></LineChart>
</div>
</template>
<script>
import BarChart from './BarChart.vue'
import LineChart from './LineCharts.vue'
import PullDownSelect from './PullDownSelect.vue'
import { digitalMarketingLeftSelectList } from './constant'
export default {
name: 'DigitalMarketingLeft',
components: {
PullDownSelect,
BarChart,
LineChart
},
data() {
return {
tabList: ['订单量', '收入'],
selectList: digitalMarketingLeftSelectList[0],
colorList: ['#2AD191', '#00A89E', '#061422'],
valueName: 'registerNum',
tabShow: false,
marketingTrendList: [],
marketingCrowdFundingTrendList: [],
chartShow: true,
valName: 'orderNum',
tabActive: 0
}
},
created() {
this.getMarketingTrend()
this.getMarketingCrowdFundingTrend()
},
mounted() {
// this.$refs.trendChartRef.drawBar()
this.$bus.$on('digitalMarketingTabChange', data => {
// console.log(data)
this.$refs.leftDownSelect.selectType = ''
this.tabActive - data
this.tabShow = false
this.chartShow = true
this.selectList = digitalMarketingLeftSelectList[data]
switch (data) {
case 0:
this.valueName = 'registerNum'
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingTrendList)
})
break
case 1:
this.valueName = 'activityNum'
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingCrowdFundingTrendList)
})
break
}
})
},
methods: {
selectVal(val) {
const actions = {
registerNum: () => {
this.chartShow = true
this.tabShow = false
this.valueName = 'registerNum'
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingTrendList)
})
},
activeNum: () => {
this.chartShow = true
this.valueName = 'activeNum'
this.tabShow = false
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingTrendList)
})
},
output: () => {
this.valName = 'orderNum'
this.chartShow = false
this.tabShow = true
this.$nextTick(() => {
this.$refs.monthIncomeLineChartRef.drawLine(this.marketingTrendList)
})
},
activityNum: () => {
this.chartShow = true
this.valueName = 'activityNum'
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingCrowdFundingTrendList)
})
},
orderNum: () => {
this.chartShow = true
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingCrowdFundingTrendList)
})
},
avgPrice: () => {
this.chartShow = true
this.valueName = 'avgPrice'
this.$nextTick(() => {
this.$refs.trendChartRef.drawBar(this.marketingCrowdFundingTrendList)
})
}
}
const action = actions[val.val]
if (action) {
action()
}
},
changeTab(val) {
console.log(val)
switch (val) {
case 0:
if (this.tabActive === 0) {
this.valName = 'orderNum'
console.log(111)
this.$nextTick(() => {
this.$refs.monthIncomeLineChartRef.drawLine(this.marketingTrendList)
})
}
break
case 1:
if (this.tabActive === 0) {
this.valName = 'output'
this.$nextTick(() => {
this.$refs.monthIncomeLineChartRef.drawLine(this.marketingTrendList)
})
}
break
}
},
async getMarketingTrend() {
const _data = await this.api.internal.getMarketingTrend()
const _dataList = _data.data.dataList
this.marketingTrendList = _dataList
this.$refs.trendChartRef.drawBar(_dataList)
},
async getMarketingCrowdFundingTrend() {
const _data = await this.api.internal.getMarketingCrowdFundingTrend()
const _dataList = _data.data.dataList
this.marketingCrowdFundingTrendList = _dataList
}
}
}
</script>
<style lang="scss" scoped>
.marketing-left {
width: 22.78vw;
height: 25vh;
display: flex;
flex-direction: column;
justify-content: space-between;
.inner-tab {
/deep/.tab-item-box {
margin: 0;
}
}
}
</style>