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
| <template>
| <div class="box">
| <div class="title">设备设施统计</div>
| <div ref="main" style="width: 100%; height: 400px"></div>
| </div>
| </template>
| <script lang="ts">
| import { defineComponent, onMounted, ref } from 'vue';
| import * as echarts from 'echarts';
| import { ElMessage } from 'element-plus';
| import { facilityManagementApi } from '/@/api/facilityManagement';
| export default defineComponent({
| setup() {
| const listApi = () => {
| facilityManagementApi()
| .getequipmentInfoStatistics()
| .then((res) => {
| if (res.data.code == 200) {
| let arr=[]
| arr=res.data.data
| let date=[]
| for (let i = 0; i < arr.length; i++) {
| date.push(arr[i].count)
| }
| init(date);
| } else {
| ElMessage({
| showClose: true,
| message: res.data.msg,
| type: 'error',
| });
| }
| });
| };
| onMounted(() => {
| listApi();
| });
| const main = ref();
| const init = (data:any) => {
| var myChart = echarts.init(main.value);
| var option = {
| tooltip: {},
| grid: {
| left: '3%',
| right: '4%',
| bottom: '5%',
| containLabel: true,
| },
| xAxis: {
| type: 'category',
| data: ['在用数', '报废数', '维修数', '停用数'],
| },
| yAxis: {
| type: 'value',
| name: '数量',
| nameTextStyle: {
| color: '#aaa',
| nameLocation: 'start',
| },
| },
| color: ['#6394f9'],
| series: [
| {
| data: data,
| type: 'bar',
| },
| ],
| };
|
| myChart.setOption(option);
| };
| return {
| init,
| onMounted,
| main,
| listApi,
| };
| },
| });
| </script>
| <style scoped>
| .box {
| background-color: #fff;
| box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
| }
| .title {
| font-size: 16px;
| border-bottom: 1px solid #eee;
| padding: 20px;
| }
| </style>
|
|