<style scoped lang="scss">
    .sg-block{
        width: 190px;
        margin: 10px;
    }
    .sg-dis{
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .sg-table{
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        tr{
            td{
                padding: 7px;
                border: 1px solid royalblue;
            }
        }
    }
    .sin9{
        background-color: #ffffff;
        padding: 10px;
    }
    .title{
        padding: 10px;
        font-size: 16px;
        font-weight: bold;
    }
</style>

<template>
    <div class="system-menu-container layout-pd">
        <el-row :gutter="20">
            <el-col :xs="24"
                    :sm="21"
                    :md="20"
                    :lg="18"
                    :xl="10">
                <div class="sg-dis sin9">
                    <div class="sg-block" v-for="a in 9">
                        <el-card shadow="hover" style="background-color: #fff1f1;">
                            <div style="font-size: 18px;font-weight: bold;color: #ff4400">
                                100000元
                            </div>
                            <div style="margin-top: 7px">
                                预售资金监管余额
                            </div>
                        </el-card>
                    </div>
                </div>
            </el-col>
            <el-col :span="14">
                <div class="" style="width: 100%;height: 100%;background-color: #f2feff">
                    <div class="title">月度统计总收入总支出（柱状图）</div>
                    <div style="height: 300px;" ref="homeLineRef"></div>
                </div>
            </el-col>
        </el-row>

        <el-row :gutter="20">
            <el-col :span="12">
                <div style="background-color: #ffffff;height: 400px;margin-top: 20px">
                    <div class="title">资金收入支出余额对比</div>
                    <div style="height: 340px;" ref="homeLineRef2"></div>
                </div>
            </el-col>
            <el-col :span="12">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;">

                    <div style="padding: 10px">
                        <el-tabs
                                v-model="activeName"
                                type="border-card"
                                @tab-click="handleClick"
                        >
                            <el-tab-pane label="在建监管项目总收入排行" name="first">
                                <div>
                                    <el-table :data="tableData" border style="width: 100%">
                                        <el-table-column prop="date" label="排名" width="180" />
                                        <el-table-column prop="name" label="公司名称" width="180" />
                                        <el-table-column prop="address" label="金额" />
                                    </el-table>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="在建监管项目总支出排行" name="second">
                                <div>
                                    <el-table :data="tableData" border style="width: 100%">
                                        <el-table-column prop="date" label="Date" width="180" />
                                        <el-table-column prop="name" label="Name" width="180" />
                                        <el-table-column prop="address" label="Address" />
                                    </el-table>
                                </div>
                            </el-tab-pane>
                        </el-tabs>
                    </div>
                </div>
            </el-col>

        </el-row>
        <el-row :gutter="20">
            <el-col :span="8">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">在建监管项目资金余额排行</div>
            </el-col>
            <el-col :span="8">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">监管银行输入资金占比（饼状图，导出excel）</div>
            </el-col>
            <el-col :span="8">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">监管账户按照银行分组（柱状图、折线图）</div>
            </el-col>
        </el-row>
        <el-row :gutter="20">
            <el-col :span="24">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">进度节点分布统计（柱状图统计，按楼幢）</div>
            </el-col>
        </el-row>
        <el-row :gutter="20">
            <el-col :span="8">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">在建楼幢层高分析（低层、多层、小高层、高层饼状图占比）（柱状图统计，按楼幢）</div>
            </el-col>
            <el-col :span="8">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">楼幢托管周期（天）分析（低层、多层、小高层、高层柱状图分析）</div>
            </el-col>
            <el-col :span="8">
                <div style="margin-top: 20px;background-color: #ffffff;height: 400px;padding: 20px">企业监管资金余额排行</div>
            </el-col>
        </el-row>
    </div>
</template>

<script setup lang="ts">
    import { reactive, onMounted, ref, watch, nextTick, onActivated, markRaw } from "vue";
    import * as echarts from "echarts";
    import type { TabsPaneContext } from 'element-plus'


    const homeLineRef = ref();
    const homeLineRef2 = ref();
    const state = reactive({
        global: {
            homeChartOne: null,
            homeChartOne2: null,
        },
        myCharts: [] as any,
    })
    const activeName = ref('first')




    const handleClick = (tab: TabsPaneContext, event: Event) => {

    }
    const tableData = [
        {
            date: '2016-05-03',
            name: 'Tom',
            address: 'No. 189, Grove St, Los Angeles',
        },
        {
            date: '2016-05-02',
            name: 'Tom',
            address: 'No. 189, Grove St, Los Angeles',
        },
        {
            date: '2016-05-04',
            name: 'Tom',
            address: 'No. 189, Grove St, Los Angeles',
        },
        {
            date: '2016-05-01',
            name: 'Tom',
            address: 'No. 189, Grove St, Los Angeles',
        },
    ]

    const initLineChart = () =>{
        state.global.homeChartOne = markRaw(
            echarts.init(homeLineRef.value)
        );
        const option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            legend: {
                data: ['收入', '支出']
            },
            xAxis: [
                {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Sun'],
                    axisPointer: {
                        type: 'shadow'
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value} 套'
                    }
                },
                {
                    type: 'value',
                    splitLine:{
                        show:false
                    },
                    axisLabel: {
                        formatter: '{value} ㎡'
                    }
                }
            ],
            series: [
                {
                    name: '收入',
                    type: 'bar',
                    tooltip: {
                        valueFormatter: function (value) {
                            return value + ' 套';
                        }
                    },
                    data: [
                        20, 49, 70, 232, 256, 767, 1356, 1356
                    ]
                },
                {
                    name: '支出',
                    type: 'bar',
                    yAxisIndex: 1,
                    tooltip: {
                        valueFormatter: function (value) {
                            return value + '㎡';
                        }
                    },
                    data: [
                        2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 1.6, 1.6
                    ]
                }
            ]
        };
        state.global.homeChartOne.setOption(option);
        state.myCharts.push(state.global.homeChartOne);
    };
    const initLineChart2 = () =>{
        state.global.homeChartOne2 = markRaw(
            echarts.init(homeLineRef2.value)
        );
        const option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            legend: {
                data: ['收入', '支出']
            },
            xAxis: [
                {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Sun'],
                    axisPointer: {
                        type: 'shadow'
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value} 套'
                    }
                },
                {
                    type: 'value',
                    splitLine:{
                        show:false
                    },
                    axisLabel: {
                        formatter: '{value} ㎡'
                    }
                }
            ],
            series: [
                {
                    name: '收入',
                    type: 'bar',
                    tooltip: {
                        valueFormatter: function (value) {
                            return value + ' 套';
                        }
                    },
                    data: [
                        20, 49, 70, 232, 256, 767, 1356, 1356
                    ]
                },
                {
                    name: '支出',
                    type: 'line',
                    yAxisIndex: 1,
                    tooltip: {
                        valueFormatter: function (value) {
                            return value + '㎡';
                        }
                    },
                    data: [
                        2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 1.6, 1.6
                    ]
                }
            ]
        };
        state.global.homeChartOne2.setOption(option);
        state.myCharts.push(state.global.homeChartOne2);
    };
    nextTick(() => {
        setTimeout(() => {
            initLineChart();
        }, 500);
        setTimeout(() => {
            initLineChart2()
        }, 700);
        setTimeout(() => {
            // initBarChart();
        }, 1000);
    });
</script>


