DigitalLink.vue
3.08 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
<template>
<div class="link-box">
<box-title title="数字化链接"></box-title>
<div class="link-box-content">
<StatisticsBox :list="digitalLinkList"></StatisticsBox>
<div class="down-content">
<PullDownSelect :selectList="selectList" @selectVal="selectVal"></PullDownSelect>
<BarChart ref="linkChartRef" height="22vh" domId="linkChart" :label="'statDate'" :colorList="colorList" :valueName="'num'"></BarChart>
</div>
</div>
</div>
</template>
<script>
import PullDownSelect from './PullDownSelect.vue'
import BarChart from './BarChart.vue'
export default {
name: 'DigitalLink',
components: {
PullDownSelect,
BarChart
},
data() {
return {
digitalLinkList: [],
selectList: [
{
name: '成品设备激活趋势',
val: 'finished'
},
{
name: '半成品发货趋势',
val: 'semifinished'
}
],
dataList: [
{
statMonth: '2021',
actiNum: 400
},
{
statMonth: '2022',
actiNum: 400
},
{
statMonth: '2023',
actiNum: 400
}
],
colorList: ['#22D8FF', '#223FA9', '#061422'],
start: '',
end: ''
}
},
created() {
this.end = this.formatDate()
const start = new Date()
start.setTime(start.setMonth(start.getMonth() - 12))
this.start = this.formatDate(start)
this.getLinkFinishedProductTrend()
},
mounted() {
this.$bus.$on('innerGetAllOverview', data => {
this.digitalLinkList = data.filter(item => item.tag === 'digitalLink')
})
},
methods: {
selectVal(val) {
switch (val.val) {
case 'finished':
this.getLinkFinishedProductTrend('finished')
break
case 'semifinished':
this.getLinkFinishedProductTrend('semifinished')
break
}
},
async getLinkFinishedProductTrend(queryItem) {
const params = {
queryItem: queryItem || 'finished', // finished--成品,semifinished--半成品
queryType: 0,
startDate: this.start,
endDate: this.end
}
const _data = await this.api.internal.getLinkFinishedProductTrend(params)
const _dataList = _data.data.dataList
this.$refs.linkChartRef.drawBar(_dataList)
},
// 日期转化
formatDate(val) {
const date = val || new Date()
const year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
if (month < 10) {
month = '0' + month
}
if (day < 10) {
day = '0' + day
}
const currentdate = year + '-' + month + '-' + day
return currentdate
}
}
}
</script>
<style lang="scss" scoped>
.link-box {
width: 23.33vw;
height: 40vh;
box-shadow: inset 0 0 20px 0 #3d57ff69;
&-content {
padding: 1.56vh 0.83vw;
/deep/ .statistics {
height: 8vh;
}
.down-content {
margin-top: 1.78vh;
height: 21.5vh;
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
}
</style>