wangzhibo
4 天以前 656e2507b9aa388afa4c3346927b1b94ab70a0b2
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
<template>
    <div class="screen-page">
            <el-row :gutter="10" class="kpi-row">
                <el-col v-for="item in kpis" :key="item.label" :lg="4" :sm="12" :xs="24">
                    <kpi-card v-bind="item" />
                </el-col>
            </el-row>
 
            <el-row :gutter="10" class="mid-row">
                <el-col :lg="10" :xs="24">
                    <panel-card title="可回收物品类占比" sub="同一时间范围,看结构">
                        <v-chart :option="pieOption" autoresize class="chart" />
                    </panel-card>
                </el-col>
                <el-col :lg="14" :xs="24">
                    <panel-card title="各类回收量" sub="横向柱状图更适合长品类名">
                        <v-chart :option="weightOption" autoresize class="chart" />
                    </panel-card>
                </el-col>
            </el-row>
 
            <el-row :gutter="10">
                <el-col :span="24">
                    <panel-card title="回收价值分析" sub="学校最关心:什么垃圾最值钱">
                        <v-chart :option="valueOption" autoresize class="chart chart--value" />
                    </panel-card>
                </el-col>
            </el-row>
        </div>
</template>
 
<script lang="ts" setup>
defineOptions({
    name: 'report-screen-resource'
});
 
import { computed } from 'vue';
import KpiCard from '../../components/kpi-card.vue';
import PanelCard from '../../components/panel-card.vue';
import { useChartTheme, useScreenData } from '../../hooks/use-screen';
 
const { data } = useScreenData();
const { textColor, mutedColor, splitColor, primary, tooltip } = useChartTheme();
 
const kpis = computed(() => [
    { label: '回收总量', value: data.value.kpis.periodWeightTon, suffix: '吨', fixed: 2, hint: '全部分类重量合计' },
    { label: '可回收物', value: data.value.kpis.recyclableTon, suffix: '吨', fixed: 2, hint: 'SW62' },
    { label: '大件垃圾', value: data.value.kpis.bulkTon, suffix: '吨', fixed: 2, hint: 'SW63' },
    { label: '电子产品', value: data.value.kpis.elecTon, suffix: '吨', fixed: 2, hint: '可回收子类' },
    { label: '废旧织物', value: data.value.kpis.fabricTon, suffix: '吨', fixed: 2, hint: '可回收子类' }
]);
 
const pieOption = computed(() => ({
    tooltip: { trigger: 'item', formatter: '{b}<br/>{c} kg ({d}%)', ...tooltip() },
    legend: { bottom: 0, textStyle: { color: mutedColor.value } },
    series: [
        {
            type: 'pie',
            radius: ['36%', '60%'],
            center: ['50%', '46%'],
            padAngle: 3,
            itemStyle: { borderRadius: 6 },
            label: { color: textColor.value, formatter: '{b} {d}%' },
            data: data.value.recycleItems.map(e => ({
                name: e.name,
                value: e.weight,
                itemStyle: { color: e.color }
            }))
        }
    ]
}));
 
const weightOption = computed(() => ({
    grid: { containLabel: true, left: 8, right: 28, top: 12, bottom: 8 },
    tooltip: { trigger: 'axis', ...tooltip() },
    xAxis: {
        type: 'value',
        name: 'kg',
        splitLine: { lineStyle: { color: splitColor.value, type: 'dashed' } },
        axisLabel: { color: mutedColor.value },
        axisLine: { show: false },
        axisTick: { show: false }
    },
    yAxis: {
        type: 'category',
        data: data.value.recycleItems.map(e => e.name).reverse(),
        axisLabel: { color: textColor.value },
        axisLine: { show: false },
        axisTick: { show: false }
    },
    series: [
        {
            type: 'bar',
            barWidth: 16,
            data: data.value.recycleItems
                .map(e => ({ value: e.weight, itemStyle: { color: e.color, borderRadius: [0, 8, 8, 0] } }))
                .reverse()
        }
    ]
}));
 
const valueOption = computed(() => ({
    grid: { containLabel: true, left: 16, right: 16, top: 28, bottom: 8 },
    tooltip: { trigger: 'axis', ...tooltip() },
    xAxis: {
        type: 'category',
        data: data.value.recycleItems.map(e => e.name),
        axisLabel: { color: mutedColor.value },
        axisLine: { show: false },
        axisTick: { show: false }
    },
    yAxis: {
        type: 'value',
        name: '元',
        nameTextStyle: { color: mutedColor.value },
        splitLine: { lineStyle: { color: splitColor.value, type: 'dashed' } },
        axisLabel: { color: mutedColor.value },
        axisLine: { show: false },
        axisTick: { show: false }
    },
    series: [
        {
            type: 'bar',
            barWidth: 28,
            data: data.value.recycleItems.map(e => e.value),
            itemStyle: { color: primary.value, borderRadius: [6, 6, 0, 0] }
        }
    ]
}));
</script>
 
<style lang="scss" scoped>
.screen-page {
    .kpi-row,
    .mid-row {
        margin-bottom: 10px;
    }
 
    .kpi-row {
        :deep(.el-col) {
            margin-bottom: 10px;
        }
    }
 
    .mid-row {
        :deep(.panel-card) {
            min-height: 360px;
        }
    }
 
    .chart {
        height: 300px;
        width: 100%;
 
        &--value {
            height: 280px;
        }
    }
}
</style>