<template>
    <div class="default-main">
        <TableHeader datePicker area showExport>
            <template #select>
                <el-form-item label="统计类型:">
                    <el-select
                        v-model="tableStore.table.params.statisticalType"
                        placeholder="请选择统计类型"
                        value-key="id"
                    >
                        <el-option
                            v-for="item in classificationData"
                            :key="item.id"
                            :label="item.name"
                            :value="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="电压等级:">
                    <el-select
                        v-model="tableStore.table.params.scale"
                        filterable
                        multiple
                        collapse-tags
                        clearable
                        placeholder="请选择电压等级"
                        value-key="id"
                    >
                        <el-option
                            v-for="item in voltageleveloption"
                            :key="item.id"
                            :label="item.name"
                            :value="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="终端厂家:">
                    <el-select
                        v-model="tableStore.table.params.manufacturer"
                        filterable
                        multiple
                        collapse-tags
                        clearable
                        placeholder="请选择终端厂家"
                        value-key="id"
                    >
                        <el-option
                            v-for="item in terminaloption"
                            :key="item.id"
                            :label="item.name"
                            :value="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="干扰源类型:">
                    <el-select
                        v-model="tableStore.table.params.loadType"
                        filterable
                        multiple
                        collapse-tags
                        clearable
                        placeholder="请选择干扰源类型"
                        value-key="id"
                    >
                        <el-option
                            v-for="item in interfereoption"
                            :key="item.id"
                            :label="item.name"
                            :value="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
            </template>
        </TableHeader>
        <Table ref="tableRef" isGroup :key="num" />
    </div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import { useDictData } from '@/stores/dictData'
import TableHeader from '@/components/table/header/index.vue'
const dictData = useDictData()
defineOptions({
    name: 'harmonic-boot/detailedAnalysis/contrast'
})
const view = ref(true)
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
const voltageleveloption = dictData.getBasicData('Dev_Voltage_Stand')
const terminaloption = dictData.getBasicData('Dev_Manufacturers')
const interfereoption = dictData.getBasicData('Interference_Source')

const num = ref(0)

const tableStore = new TableStore({
    url: '/harmonic-boot/detailAnalysis/overAreaStatistics',
    method: 'POST',
    isWebPaging: true,
    column: [
        {
            field: 'index',
            title: '序号',
            width: '80',
            formatter: (row: any) => {
                return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
            }
        },
        { field: 'name', title: '电网拓扑', minWidth: '150' },
        {
            field: 'onlineMonitorNumber',
            title: '在运监测点数(个)',
            minWidth: '100px',
            formatter: (row: any) => {
                return row.cellValue == -1 ? '/' : row.cellValue
            }
        },
        {
            field: 'overLimitMonitorNumber',
            title: '超标监测点数量(个)',
            minWidth: '100px',
            formatter: (row: any) => {
                return row.cellValue == -1 ? '/' : row.cellValue
            }
        },
        {
            field: 'overBiLi',
            title: '超标监测点占比(%)',
            minWidth: '100px',
            formatter: (row: any) => {
                return row.cellValue == -1 ? '/' : row.cellValue
            }
        },
        {
            title: '频率偏差超标情况',
            children: [
                {
                    field: 'frequencyMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'frequencyBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'frequencyOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '电压偏差超标情况',
            children: [
                {
                    field: 'voltageMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'voltageBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'voltageOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '谐波电压超标情况',
            children: [
                {
                    field: 'harmonicVoltageMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'harmonicVoltageBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'harmonicVoltageOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '谐波电流超标情况',
            children: [
                {
                    field: 'harmonicCurrentMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'harmonicCurrentBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'harmonicCurrentOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '三相电压不平衡度超标情况',
            children: [
                {
                    field: 'threePhaseVoltageMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'threePhaseVoltageBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'threePhaseVoltageOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '闪变超标情况',
            children: [
                {
                    field: 'flickerMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'flickerBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'flickerOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '负序电流超标情况',
            children: [
                {
                    field: 'negativeMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'negativeBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'negativeOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        },
        {
            title: '间谐波电压超标情况',
            children: [
                {
                    field: 'interHarmonicMonitorNumber',
                    title: '超标点数(天/点)',
                    minWidth: '140px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'interHarmonicBiLi',
                    title: '超标占比(%)',
                    minWidth: '100px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                },
                {
                    field: 'interHarmonicOverDayBiLi',
                    title: '平均超标天数(天/点)',
                    minWidth: '150px',
                    formatter: (row: any) => {
                        return row.cellValue == -1 ? '/' : row.cellValue
                    }
                }
            ]
        }
    ],
    beforeSearchFun: () => {
        tableStore.options.column[1].title = tableStore.table.params.statisticalType.name
        num.value += 1
    }
})
tableStore.table.params.statisticalType = classificationData[0]
tableStore.table.params.serverName = 'harmonic-boot'
tableStore.table.params.powerFlag = 2
tableStore.table.params.monitorFlag = 2
tableStore.table.params.scale = []
tableStore.table.params.manufacturer = []
tableStore.table.params.loadType = []
const wp = ref({})

provide('tableStore', tableStore)
onMounted(() => {
    tableStore.index()
})
</script>
