<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">
            <HcCardItem class="hc-card-item-box info-card">
                <div class="content">
                    <div class="item">
                        <span>户主：xxxxx</span>
                        <span class="ml-20">宗地编号：xxxxx</span>
                    </div>
                    <div class="item">征地面积：xxxxx</div>
                    <div class="item">征拆状态：xxxxx</div>
                    <div class="item">结算金额：xxxxx</div>
                </div>
                <div class="btn">
                    <el-button type="primary">查看协议书</el-button>
                    <el-button type="primary">查看结算协议书</el-button>
                </div>
            </HcCardItem>
            <div class="hc-count-map">
                地图
            </div>
        </div>
    </HcCard>
</template>

<script setup>
import {ref, onUnmounted, onMounted} from "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)
    }
}

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

<style lang="scss" scoped>
.hc-count-card .hc-count-body .hc-card-item-box.info-card {
    height: 130px;
    margin-bottom: 24px;
    .content {
        flex: 1;
        position: relative;
        .item + .item {
            margin-top: 10px;
        }
    }
    .btn {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
}
.hc-count-map {
    position: relative;
    height: calc(100% - 155px);
}
</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;
            }
            &.info-card .hc-card-item-body {
                display: flex;
            }
        }
    }
}
</style>
