<template>
    <div>
        <TableHeader area datePicker></TableHeader>
        <div style="display: flex" v-loading="tableStore.table.loading" :style="{ height: height }">
            <MyEchart :options="options1" />
            <MyEchart :options="options2" />
        </div>
    </div>
</template>
<script setup lang="ts">
import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { mainHeight } from '@/utils/layout'
import { ref, provide, onMounted } from 'vue'
const options1 = ref()
const options2 = ref()
const tableStore = new TableStore({
    url: '/process-boot/process/pmsTerminalDetection/getCycleStatistics',
    method: 'POST',
    column: [],
    beforeSearchFun: () => {
        tableStore.table.params.id = tableStore.table.params.deptIndex
    },
    loadCallback: () => {
        options1.value = {
            legend: {
                data: ['已展开', '未展开']
            },
            xAxis: {
                data: tableStore.table.data.dateStatistics.map(item => item.orgName)
            },
            yAxis: {
                name: '台'
            },
            series: [
                {
                    name: '已展开',
                    type: 'bar',

                    data: tableStore.table.data.dateStatistics.map(item => item.expanded)
                },
                {
                    name: '未展开',
                    type: 'bar',

                    data: tableStore.table.data.dateStatistics.map(item => item.notExpanded)
                }
            ]
        }
        options2.value = {
            legend: {
                data: ['检测终端数量']
            },
            xAxis: {
                data: tableStore.table.data.orgStatistics.map(item => item.orgName)
            },
            yAxis: {
                name: '台'
            },
            series: [
                {
                    name: '检测终端数量',
                    type: 'bar',

                    data: tableStore.table.data.orgStatistics.map(item => item.count)
                }
            ]
        }
    }
})
provide('tableStore', tableStore)

const height = mainHeight(160).height
onMounted(() => {
    tableStore.index()
})
</script>
<style lang="scss" scoped></style>
