LineBar.vue
4.33 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
<template>
<view class="line-bar-box">
<view class="tabs">
<page-tabs
:list="tabList"
@changeTab="changeTab"
size="small"
/>
</view>
<view class="canvas">
<qiun-data-charts
type="bar"
:opts="opts"
:chartData="chartData"
:tooltipShow="false"
/>
</view>
</view>
</template>
<script type="text/ecmascript-6">
import PageTabs from '@/components/PageTabs.vue'
const rateList = {
excellentStoreAvgDealRate: '优秀门店均值',
thisStoreDealRate: '本门店',
personalDealRate: '个人'
},
priceList = {
excellentStoreAvgDeal: '优秀门店均值',
thisStoreKdj: '本门店',
personalKdj: '个人'
}
export default {
components: {
PageTabs
},
props: {
pageData: {
type: Object,
default: () => { }
},
dataShow: {
type: Boolean,
default: true
},
sceneType: Number,
isHarmony: Boolean, // 是否为鸿蒙
bussinessType: Number
},
watch: {
dataShow: {
immediate: true,
handler (newval) {
this.getServerData()
}
}
},
name: '',
data () {
return {
tabIndex: 0,
tabList: ['本月交付成交率', '本月交付客单价'],
chartData: {},
//您可以通过修改 config-ucharts.js 文件中下标为 ['bar'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
opts: Object.freeze({
fontColor: '#333',
fontSize: 12,
color: ["#2C66F7"],
padding: [20, 80, 0, 0],
enableScroll: false,
legend: {
show: false
},
xAxis: {
disabled: true,
gridColor: '#fff',
},
yAxis: {
axisLineColor: '#cfd4e3'
},
extra: {
bar: {
type: "group",
width: 6,
barColorList: [
['#389FFF', '#2C66F7'],
['#708DFF', '#6858F5'],
['#94CBFF', '#3283FB']
],
linearType: 'custom',
barBorderCircle: true,
}
}
})
}
},
mounted () {
},
methods: {
getServerData () {
let { dataShow, tabIndex, pageData, sceneType, isHarmony, bussinessType } = this
/**
* 2.1场景 鸿蒙---问界/鸿蒙 [本月交付客单价] 改成 [整车延保成交数]
* 2.1场景 非鸿蒙---选延保 [本月交付客单价] 改成 [整车延保成交数] (bussinessType 1:延保 3:权益)
* 2.1场景 非鸿蒙---权益 [本月交付成交率] 改为 [广联权益渗透率]; [本月交付客单价] 改成 [广联权益成交数]
*/
if (sceneType == 0) {
if (isHarmony) {
this.tabList[1] = '整车延保成交数'
} else {
if (bussinessType == 1) this.tabList[1] = '整车延保成交数'
else this.tabList = ['广联权益渗透率', '广联权益成交数']
}
}
let list = [],
categories = [],
data = [],
defaultList = []
if (tabIndex == 0) Object.keys(rateList).map(key => {
list.push({
text: rateList[key],
value: pageData[key]
})
})
else Object.keys(priceList).map(key => {
list.push({
text: priceList[key],
value: pageData[key]
})
})
list.sort((a, b) => b.value - a.value)
list.map(e => {
categories.push(e.text)
data.push(e.value || 0)
defaultList.push(e.value == null)
})
let series = [{
defaultList,
hideData: !dataShow,
textSize: 14,
textColor: '#333',
data
}]
if (tabIndex == 0) series[0].afterUnit = '%'
if (sceneType == 1 && tabIndex == 1) series[0].beforeUnit = '¥' //轻改
this.chartData = {
categories,
series,
}
},
changeTab (index) {
this.tabIndex = index
this.getServerData()
}
}
}
</script>
<style scoped lang="scss">
.line-bar-box {
height: toRpx(388);
box-sizing: border-box;
padding: toRpx(24);
.tabs {
width: toRpx(544);
height: toRpx(64);
}
.canvas {
height: toRpx(260);
}
}
</style>