<template>
    <HcCard ui="hc-count-card-ui" bodyUi="hc-count-card">
        <div class="hc-count-tree" id="hc-count-tree">
            <el-scrollbar>
                <HcTreeData :isMenu="false" @nodeTap="treeNodeTap"/>
            </el-scrollbar>
        </div>
        <div class="hc-count-body" id="hc-count-body">
            <el-scrollbar>
                <div class="hc-count-echarts-1">
                    <el-row :gutter="14">
                        <el-col :span="10">
                            <HcCardItem title="面积进度柱状图统计" style="height: 440px">
                                <BarLabelEcharts :lables="planLables" :color="planColors" :datas="planDatas"/>
                            </HcCardItem>
                        </el-col>
                        <el-col :span="14">
                            <HcCardItem title="面积进度" style="height: 160px">
                                <el-row :gutter="20" class="h-full">
                                    <el-col :span="6">
                                        <div class="hc-count-area-progress">
                                            <div class="num">23123123.12</div>
                                            <div class="text">已签协议面积(亩)</div>
                                        </div>
                                    </el-col>
                                    <el-col :span="6">
                                        <div class="hc-count-area-progress">
                                            <div class="num">26.12%</div>
                                            <div class="text">已签协议比例</div>
                                        </div>
                                    </el-col>
                                    <el-col :span="6">
                                        <div class="hc-count-area-progress">
                                            <div class="num">23123.12</div>
                                            <div class="text">已结算面积(亩)</div>
                                        </div>
                                    </el-col>
                                    <el-col :span="6">
                                        <div class="hc-count-area-progress">
                                            <div class="num">26.36%</div>
                                            <div class="text">已结算比例</div>
                                        </div>
                                    </el-col>
                                </el-row>
                            </HcCardItem>
                            <HcCardItem title="金额进度" style="height: 266px; margin-top: 14px">
                                <BarLabelEcharts :lables="planLables1" :color="planColors1" :datas="planDatas1"/>
                            </HcCardItem>
                        </el-col>
                    </el-row>
                </div>
                <HcCardItem title="结算统计图（单位：元）" style="height: 440px; margin-top: 14px">
                    <stackEcharts/>
                </HcCardItem>
            </el-scrollbar>
        </div>
    </HcCard>
</template>

<script setup>
import {ref, onUnmounted, onMounted} from "vue";
import BarLabelEcharts from "~com/echarts/BarLabel.vue";
import stackEcharts from "~com/echarts/stackEcharts.vue";
import split from "split.js";

//树节点被点击
const treeNodeTap = ({node, data}) => {

}

//渲染完成
onMounted(() => {
    setSplitDom()
})

// 初始化设置拖动分割线
const splitvar = ref(null);
const setSplitDom = () => {
    try {
        //配置参考： https://split.js.org/#/?direction=vertical&snapOffset=0
        splitvar.value = split([
            '#hc-count-tree',
            '#hc-count-body'
        ], {
            sizes: [20, 80],
            minSize: [200, 900],
        });
    } catch (e) {
        setTimeout(() => {
            setSplitDom()
        }, 500)
    }
}

//面积进度柱状图统计
const planColors = ['#D97558', '#E4C476']
const planLables = ref(['农用地', '建设用地', '未利用地'])
const planDatas = ref([
    {
        name: '已签面积',
        value: [1200, 132, 501]
    },
    {
        name: '设计面积',
        value: [120, 432, 1001]
    }
])

//金额进度
const planColors1 = ['#7F83F6', '#81B336', '#E99D43']
const planLables1 = ref(['征地补偿', '专项设施', '青苗', '坟地补偿', '地上附着物'])
const planDatas1 = ref([
    {
        name: '实际补助总金额',
        value: [1200, 132, 501, 323, 654]
    },
    {
        name: '设计补助总金额',
        value: [120, 432, 1001, 111, 987]
    },
    {
        name: '已结算总金额',
        value: [120, 432, 1001, 323, 654]
    }
])

//销毁
onUnmounted(() => {
    if (splitvar.value) {
        splitvar.value.destroy()
    }
})
</script>

<style lang="scss" scoped>
.hc-count-body .hc-count-echarts-1 {
    position: relative;
    overflow: hidden;
}
</style>

<style lang="scss">
.hc-count-card-ui {
    background: white;
    .el-card__body {
        padding: 10px;
    }
}
.hc-count-card {
    display: flex;
    .hc-count-tree {
        position: relative;
        margin-right: 5px;
        height: 100%;
    }
    .hc-count-body {
        position: relative;
        margin-left: 5px;
        height: 100%;
        .hc-card-item-box {
            background: #f5f5f5;
            .hc-card-item-header {
                color: #101010;
            }
        }
    }
    .hc-count-area-progress {
        position: relative;
        height: 100%;
        background: #ffffff;
        border-radius: 5px;
        display: flex;
        align-items: center;
        justify-content: center;
        .num {
            margin-bottom: 18px;
            font-size: 20px;
        }
        .text {
            position: absolute;
            bottom: 10px;
            font-size: 14px;
        }
    }
}
</style>
