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
197
198
199
200
| <template>
| <div class="machineNest">
| <div class="nestTop">
| <div class="card-title">
| <img :src="jc1" alt="" />
| <div class="cardtotal">
| <p>机巢事件数量排名</p>
| <!-- <div class="total-number">111</div>
| <span>个</span> -->
| </div>
| </div>
| <!-- <div class="status-grid">
| <div v-for="(item, index) in jcOrder" :key="index" class="status-item">
| <img :src="jc2" alt="" />
| <div>
| <div class="status-label">{{ item.name }}</div>
| <div :style="{ color: '#387FC8' }" class="status-value">
| {{ item.value }}
| </div>
| </div>
| </div>
| </div> -->
| </div>
| <div class="nestCenter">
| <div class="chart" ref="echartsRef"></div>
| </div>
| </div>
| </template>
|
| <script setup>
| import * as echarts from 'echarts';
| import useEchartsResize from '@/hooks/useEchartsResize';
| import jc1 from '@/assets/images/workbench/jc1.png';
| import jc2 from '@/assets/images/workbench/jc2.png';
| import { industryJobNumPieChart } from '@/api/home/index';
| const echartsRef = ref(null);
| let { chart: jcchart } = useEchartsResize(echartsRef);
| const jcOrder = ref([]);
| // 获取机巢事件数据
| const getIndustryJobNumPieChart = value => {
| industryJobNumPieChart(value).then(res => {
| console.log('ppp', res);
|
| const resList = res?.data?.data || [];
| jcOrder.value = resList;
| pieInit(resList);
| });
| };
| const pieInit = resList => {
| // 处理数据,过滤掉没有name的项
| const validData = resList.filter(item => item.name);
|
| // 准备图表数据
| const optionData = {
| yAxisData: validData.map(item => item.name),
| seriesData: validData.map(item => item.value),
| };
|
| const option = {
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'shadow',
| },
| formatter: '{b}: {c}',
| },
| grid: {
| left: '3%',
| right: '4%',
| bottom: '3%',
| containLabel: true,
| },
| xAxis: {
| type: 'value',
| splitLine: {
| lineStyle: {
| color: '#E5E5E5',
| },
| },
| axisLabel: {
| color: '#35455aa6',
| },
| boundaryGap: [0, 0.01],
| },
| yAxis: {
| type: 'category',
| data: optionData.yAxisData, // 使用处理后的分类数据
| axisLabel: {
| color: '#35455aa6',
| },
| axisLine: {
| lineStyle: {
| color: '#D1D1D1',
| },
| },
| axisTick: {
| show: false,
| },
| },
| series: [
| {
| type: 'bar',
| data: optionData.seriesData, // 使用处理后的数值数据
| itemStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
| { offset: 0, color: '#93BAFF' },
| { offset: 1, color: '#C5DEFF' },
| ]),
| },
| barWidth: '30%',
| label: {
| show: true,
| position: 'right',
| formatter: '{c}',
| },
| },
| ],
| };
|
| jcchart.value.setOption(option);
| };
| onMounted(() => {
| getIndustryJobNumPieChart({ date_enum: 'CURRENT_WEEK' });
| });
| </script>
|
| <style scoped lang="scss">
| .machineNest {
| .nestTop {
| .card-title {
| display: flex;
| margin-left: 57px;
| margin-bottom: 15px;
| align-items: center;
| img {
| width: 36px;
| height: 40px;
| }
| }
| .cardtotal {
| display: flex;
| align-items: center;
| margin-left: 9px;
| p {
| font-weight: bold;
| font-size: 14px;
| color: #363636;
| }
| span {
| font-weight: 400;
| font-size: 14px;
| color: #7c8091;
| }
| .total-number {
| font-family: 'YouSheBiaoTiHei';
| font-weight: bold;
| font-size: 32px;
| color: #2a54ff;
| }
| }
| .status-grid {
| margin-left: 30px;
| display: grid;
| grid-template-columns: repeat(2, 1fr);
| row-gap: 17px;
| .status-item {
| display: flex;
| text-align: center;
| align-items: center;
| justify-content: center;
| background: #f6f8fe;
| margin-right: 10px;
| padding: 10px;
| img {
| width: 40px;
| height: 40px;
| margin-right: 13px;
| }
| .status-label {
| font-size: 14px;
| color: #383838;
| }
| .status-value {
| font-family: 'YouSheBiaoTiHei';
| font-weight: bold;
| font-size: 20px;
| }
| }
| }
| }
| .nestCenter {
| width: 100%;
| height: 600px;
| .chart {
| width: 100%;
| height: 100%;
| }
| }
| }
| </style>
|
|