<template>
    <div class="distribution-charts">
        <div class="chart-box">
            <div class="chart-title">支付方式占比</div>
            <div class="chart-content">
                <base-chart :option="paymentOption" />
            </div>
        </div>
        <div class="chart-box">
            <div class="chart-title">订单状态占比</div>
            <div class="chart-content">
                <base-chart :option="statusOption" />
            </div>
        </div>
    </div>
</template>

<script setup>
    import { computed } from 'vue';
    import BaseChart from '@/components/Chart/BaseChart.vue';

    const props = defineProps({
        paymentData: {
            type: Array,
            default: () => []
        },
        statusData: {
            type: Array,
            default: () => []
        }
    });

    const paymentOption = computed(() => ({
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: '5%',
            left: 'center'
        },
        series: [
            {
                name: '支付方式',
                type: 'pie',
                radius: '50%',
                data: props.paymentData,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    }));

    const statusOption = computed(() => ({
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: '5%',
            left: 'center'
        },
        series: [
            {
                name: '订单状态',
                type: 'pie',
                radius: '50%',
                data: props.statusData,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    }));
</script>

<style scoped lang="scss">
    .distribution-charts {
        display: flex;
        gap: 20px;
        margin-bottom: 20px;

        .chart-box {
            flex: 1;
            background: #fff; // Or transparent if card handles bg

            .chart-title {
                font-size: 16px;
                font-weight: bold;
                margin-bottom: 15px;
                color: #333;
            }

            .chart-content {
                height: 300px;
            }
        }
    }
</style>
