<template>
    <div class="default-main">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="区域">
                <Area v-model="formInline.deptIndex" />
            </el-form-item>
            <el-form-item label="时间">
                <el-date-picker v-model="formInline.searchBeginTime" type="date" placeholder="请选择时间" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
            </el-form-item>
        </el-form>
        <el-tabs v-model="activeName" type="border-card" v-loading="loading">
            <el-tab-pane label="图形" name="1">
                <Echart :list="list" ref="echarts" />
            </el-tab-pane>
            <el-tab-pane label="表格" name="2"><Tableabove ref="table" /></el-tab-pane>
        </el-tabs>
    </div>
</template>

<script setup lang="ts">
import Area from '@/components/form/area/index.vue'
import { useDictData } from '@/stores/dictData'
import Echart from '@/views/dashboard/components/echart.vue'
import Tableabove from '@/views/dashboard/components/Tableabove.vue'
import { onMounted, reactive, ref, onBeforeMount } from 'vue'

defineOptions({
    name: 'Region/overview'
})
const activeName = ref('1')
import { getAreaCalculation } from '@/api/test'
const list = ref([])
const echarts = ref()
const table = ref()
const dictData = useDictData()
const loading = ref(true)
const formInline = reactive({
    deptInd: '',
    deptIndex: dictData.state.area[0].id,
    monitorFlag: 2,
    powerFlag: 2,
    serverName: 'event-boot',
    searchBeginTime: '2023-12-01',
    searchEndTime: '2023-12-26',
    statisticalType: {
        name: '电网拓扑',
        id: 'cc28974d259ad22642f6a1bff708f967',
        code: 'Power_Network',
        value: 'cc28974d259ad22642f6a1bff708f967',
        gvalue: null,
        label: '电网拓扑',
        sort: 0
    },
    timeFlag: 1
})
// const locale=zhCn
const onSubmit = async () => {
    loading.value = true
    await getAreaCalculation(formInline).then(res => {
        list.value = res.data
        echarts.value.Processing(res.data.areaStatistics)
        echarts.value.Grade(res.data.voltageStatistics)
        echarts.value.Relation(res.data.monthlyStatistics)
        table.value.info(res.data)
        loading.value = false
    })
}

onMounted(() => {
    onSubmit()
})
</script>

<style lang="scss" scoped>
.bars_w {
    width: 100%;
    height: 500px;
}
::v-deep(.el-tabs__content) {
    height: calc(100vh - 161px);
    overflow-y: auto;
}
</style>
