<template>
    <div class="container">
        <!-- 顶部信息 -->
        <div class="containertop">
            <div class="topleft">
                <img src="../../../assets/images/detailsicon/1.png" alt="">
                <span>项目画像</span>
            </div>
            <div class="topright" style="visibility: hidden;"> 
                <el-button type="primary" size="medium" plain>
                    编辑
                </el-button>
            </div>
        </div>
        <!-- 内容区 -->
        <div class="content">
            <div class="picturediv">
                <div ref="chart" style="width: 30rem; height: 28rem; margin-left: 2rem;"></div>
            </div>
            <div class="descriptionsdiv">
                <div class="tablehead">
                    <img src="@/assets/images/icon-pjdj@2x.png" alt="">
                    <span>评价等级：</span>
                    <span style="margin-top: .3rem;">12/60</span>

                </div>
                <div class="tablebody">
                    <div class="table-container">
                        <div class="table-column">
                            <div class="table-header">评价要素</div>
                            <div v-for="(evaluation, index) in evaluations" :key="index" class="table-row">
                                {{ evaluation.element }}
                            </div>
                        </div>
                        <div class="table-column">
                            <div class="table-header">评价排名</div>
                            <div v-for="(evaluation, index) in evaluations" :key="index" class="table-row">
                                {{ evaluation.ranking }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import * as echarts from 'echarts';

export default {
    props: {
        size: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            evaluations: [
                { element: '总投资额', ranking: '100' },
                { element: '层数', ranking: '20' },
                { element: '首层层高', ranking: '5' },
                { element: '二层及以上层高', ranking: '6' },
                { element: '首层地面荷载', ranking: '7' },
                { element: '二层及以上露面荷载', ranking: '8' }
            ]
        };
    },
    mounted() {
        this.initChart();
    },
    methods: {
        initChart() {
            const chartDom = this.$refs.chart;
            const myChart = echarts.init(chartDom);

            const option = {
                legend: {
                    data: ['本项目', '中位数'],
                    top: '0%',
                },
                radar: {
                    center: ['50%', '55%'],
                    indicator: [
                        { name: '总投资额', max: 6500 },
                        { name: '首层层高', max: 16000 },
                        { name: '二层及以上楼面荷载', max: 30000 },
                        { name: '首层地面荷载', max: 38000 },
                        { name: '二层及以上楼面荷载', max: 52000 },
                        { name: '层数', max: 25000 }
                    ]
                },
                series: [
                    {
                        name: 'Budget vs spending',
                        type: 'radar',
                        data: [
                            {
                                value: [4200, 3000, 20000, 35000, 50000, 18000],
                                name: '本项目',
                                itemStyle: {
                                    color: '#2B62F1' // 自定义线条颜色
                                },
                                areaStyle: {
                                    color: {
                                        type: 'linear',
                                        x: 0,
                                        y: 0,
                                        x2: 0,
                                        y2: 1,
                                        colorStops: [{
                                            offset: 0, color: 'rgba(43, 98, 241, 0.3)' // 阴影起始颜色
                                        }, {
                                            offset: 1, color: 'rgba(43, 98, 241, 0)' // 阴影结束颜色
                                        }]
                                    }
                                }
                            },
                            {
                                value: [5000, 14000, 28000, 26000, 42000, 21000],
                                name: '中位数',
                                itemStyle: {
                                    color: '#FF9900' // 自定义线条颜色
                                },
                                areaStyle: {
                                    color: {
                                        type: 'linear',
                                        x: 0,
                                        y: 0,
                                        x2: 0,
                                        y2: 1,
                                        colorStops: [{
                                            offset: 0, color: 'rgba(255, 153, 0, 0.3)' // 阴影起始颜色
                                        }, {
                                            offset: 1, color: 'rgba(255, 153, 0, 0)' // 阴影结束颜色
                                        }]
                                    }
                                }
                            }
                        ]
                    }
                ]
            };

            myChart.setOption(option);
        }
    }
};
</script>

<style scoped>
.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: #FFFFFF;
    box-shadow: 0rem 0.13rem 0.63rem 0rem rgba(177, 177, 177, 0.1);
    border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
}

.content {
    padding: 1rem;
    display: flex;
}

.containertop {
    height: auto;
    display: flex;
    justify-content: space-between;
    padding: .7rem 0;
    padding: .5rem;
    border-bottom: 1px solid #E5E5E5;
}

.topleft {
    width: 8rem;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.topleft img {
    width: 0.81rem;
    height: 0.81rem;
}

.topleft span {
    width: auto;
    height: 0.88rem;
    font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
    font-weight: 500;
    font-size: 0.88rem;
    color: #3D424C;
    line-height: 0.88rem;
    text-align: right;
    font-style: normal;
    text-transform: none;
}

.picturediv {
    width: auto;
    height: auto;
}

.descriptionsdiv {
    width: 52rem;
    margin-left: 10rem;
    height: 25.31rem;
}

.two-row-item {
    height: 20rem;
}

.tablebody {
    margin-top: 2rem;
}

.table-container {
    display: flex;
    width: 100%;
}

.table-column {
    flex: 1;
}

.table-header {
    font-weight: bold;
    text-align: center;
    background-color: #F2F4F7;
    font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
    font-weight: 600;
    font-size: 0.88rem;
    color: #3D3D3D;
    line-height: 2.19rem;
    text-align: center;
    font-style: normal;
    text-transform: none;
    padding: .3rem 0;
}

.table-row {
    font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
    font-weight: 400;
    font-size: 0.88rem;
    color: #3D424C;
    line-height: 2.56rem;
    text-align: center;
    font-style: normal;
    text-transform: none;
    padding: .3rem 0;
}

.tablehead {
    width: auto;
    height: 2.38rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.tablehead img {
    width: 1.13rem;
    height: 1.13rem;
}
</style>