PurchaseTrends.vue
3.7 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
<!--
* @Description: 近一年采购额趋势图
* @Author: huyue
* @Date: 2023-07-06 16:19:15
* @LastEditors: huyue
* @LastEditTime: 2023-07-20 15:24:42
-->
<template>
<div class="purchase-box">
<box-title title="采购额趋势"></box-title>
<div v-if="!isEmpty">
<BarLineChart ref="purchaseRef" height="30.23vh" domId="purchase" :dataList.sync="dataList" :tooltipFormatterObj="tooltipFormatterObj"></BarLineChart>
<div class="legend">
<div class="legend-item shop">
<span class="legend-even">双</span>
<span class="legend-odd">单</span>
<span>商城</span>
</div>
<div class="legend-item self">
<span class="legend-even">双</span>
<span class="legend-odd">单</span>
自采
</div>
<div class="legend-item">
<img class="icon-line" src="@/assets/images/icon-line.png" alt="" />
商城采购占比
</div>
</div>
</div>
<div v-else class="empty">
<Empty></Empty>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import BarLineChart from './BarLineChart.vue'
import { changeMixin } from '@/mixins'
export default {
name: 'PurchaseTrends',
components: {
BarLineChart
},
mixins: [changeMixin],
data() {
return {
tooltipFormatterObj: [
{
label: '商城',
attrName: 'data1'
},
{
label: '自采',
attrName: 'data2'
},
{
label: '占比',
attrName: 'data3',
addSymbol: '%'
}
],
dataList: [],
isEmpty: false
}
},
mounted() {
},
methods: {
init() {
this.getDataList()
},
async getDataList() {
this.dataList = []
const _data = await this.api.solar.getAllPurchaseTrend({ year: this.$store.state.app.solarYear })
const _dataList = _data.data.dataList
if (!_dataList.length) {
this.isEmpty = true
return
}
_dataList.forEach(item => {
this.dataList.push({
month: item.statDate,
data1: item.shopamount,
data2: item.selfamount,
data3: item.shopratio
})
})
this.$refs.purchaseRef.drawBarLine()
}
}
}
</script>
<style scoped lang="scss">
.purchase-box {
position: relative;
margin: 1.78vh 0;
background-color: #061422;
box-shadow: inset 0 0 20px 0 #3d57ff69;
.legend {
font-size: 14px;
display: flex;
position: absolute;
right: 1.39vw;
top: 2.22vh;
&-item {
display: flex;
align-items: center;
color: #fff;
margin-right: 1.67vw;
&:last-child {
margin-right: 0;
}
img {
width: 1.32vw;
height: 1vh;
margin-right: 0.28vw;
}
.icon-line {
width: 0.98vw;
height: 0.56vh;
}
.legend-even,
.legend-odd {
display: inline-block;
width: 0.83vw;
height: 1.33vh;
line-height: 1.33vh;
margin-right: 0.28vw;
font-size: 8px;
text-align: center;
}
}
}
.empty {
height: 30.23vh;
display: flex;
align-items: center;
}
}
.shop {
.legend-even {
background-image: linear-gradient(180deg, #2ad190 1%, #00b7df 100%);
}
.legend-odd {
background-image: linear-gradient(180deg, #22d8ff 0%, #5c56ff 100%);
}
}
.self {
.legend-even {
background-image: linear-gradient(180deg, #145f4e 1%, #035972 100%);
}
.legend-odd {
background-image: linear-gradient(180deg, #11627a 0%, #282f7a 100%);
}
}
</style>