zhangxiao
2024-08-23 3a28df1eccec424a37649cca968bce59739e0b35
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
<template>
    <div class="the-chart-card">
        <div class="top">
            <div class="left">
                {{ props.title }}
            </div>
            <div class="right">
                <a-space>
                    <a-radio-group v-model="dateType" type="button">
                        <a-radio value="hour">按小时</a-radio>
                        <a-radio value="day">按天</a-radio>
                        <a-radio value="month">按月</a-radio>
                    </a-radio-group>
                    <a-date-picker v-if="dateType === 'hour'"></a-date-picker>
                    <a-month-picker v-if="dateType === 'day'"></a-month-picker>
                    <a-year-picker v-if="dateType === 'month'"></a-year-picker>
                </a-space>
            </div>
        </div>
        <div class="chart-body">
            <template v-if="props.chartConfig">
                <the-chart v-bind="props.chartConfig" ref="theChart" class="chart-detail" @init="initChart"></the-chart>
            </template>
        </div>
    </div>
</template>
<script lang="ts" setup name="TheChartCard">
import TheChart from "../the-chart/index.vue";
type ChartType = InstanceType<typeof TheChart>["$props"];
const props = withDefaults(
    defineProps<{
        chartConfig?: ChartType;
        title?: string;
    }>(),
    {
        chartConfig: undefined,
        title: ""
    }
);
const dateType = ref("hour");
 
const theChart = ref<InstanceType<typeof TheChart> | null>(null);
 
const emits = defineEmits<{
    (e: "init", value: echarts.ECharts): void;
}>();
 
function initChart(v: any) {
    emits("init", v);
}
</script>
<style lang="scss" scoped>
.the-chart-card {
    background-color: $bg2;
    width: 100%;
    padding: 24px;
    margin-top: 20px;
    .top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 20px;
        .left {
            font-size: 18px;
            font-weight: 700;
            position: relative;
            padding-left: 18px;
            &::before {
                position: absolute;
                top: 50%;
                left: 0;
                width: 8px;
                height: 8px;
                background-color: #315efb;
                border: 1px solid #b4c0da;
                transform: translateY(-50%);
                content: " ";
            }
        }
    }
}
</style>