<template>
    <div class="default-main">
        <TableHeader date-picker area showCustomColumn>
            <template v-slot:select>
                <el-form-item label="干扰源类型">
                    <el-select
                        multiple
                        clearable
                        collapse-tags
                        v-model="interferenceSourceForm"
                        placeholder="请选择"
                        @change="onLoadTypeChange"
                        filterable
                    >
                        <el-option
                            v-for="item in interferenceSource"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                        />
                    </el-select>
                </el-form-item>
                <el-form-item label="电压等级">
                    <el-select
                        multiple
                        clearable
                        collapse-tags
                        v-model="scaleForm"
                        placeholder="请选择"
                        @change="onScaleChange"
                        filterable
                    >
                        <el-option v-for="item in level" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="通讯状态">
                    <el-select
                        multiple
                        clearable
                        collapse-tags
                        v-model="tableStore.table.params.comFlag"
                        placeholder="请选择"
                        filterable
                    >
                        <el-option label="正常" value="1" />
                        <el-option label="中断" value="0" />
                    </el-select>
                </el-form-item>
                <el-form-item label="筛选数据">
                    <el-input
                        v-model="tableStore.table.params.searchValue"
                        placeholder="变电站,终端编号,型号或网络参数"
                        maxlength="32"
                        show-word-limit
                        clearable
                        style="min-Width: 280px;"
                    />
                </el-form-item>
            </template>
        </TableHeader>
        <Table isGroup ref="tableRef" />
    </div>
</template>
<script setup lang="tsx">
import { ref, onMounted, provide, reactive } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'

defineOptions({
    name: 'Operationmanagement/accountinformation'
})
const dictData = useDictData()
const interferenceSource = dictData.getBasicData('Interference_Source')
const level = dictData.getBasicData('Dev_Voltage_Stand')
const interferenceSourceForm = ref<string[]>([])
const scaleForm = ref<string[]>([])
const tableStore = new TableStore({
    isWebPaging: true,
    url: '/device-boot/runManage/getLineLedger',
    method: 'POST',
    column: [
        
        { field: 'areaName', title: '省公司', minWidth: 120 },
        { field: 'gdName', title: '市公司', minWidth: 120 },
        { field: 'scale', title: '监测点电压等级', minWidth: 150 },
        { field: 'lineName', title: '监测点名称', minWidth: 120 },
        { field: 'bdName', title: '所属变电站', minWidth: 120 },
        { field: 'loadType', title: '干扰源类型', minWidth: 120 },
        { field: 'objName', title: '监测对象名称', minWidth: 180 },
        { field: 'shortCapacity', title: '最小短路容量(MVA)', minWidth: 190 },
        { field: 'devCapacity', title: '供电终端容量(MVA )', minWidth: 190 },
        { field: 'dealCapacity', title: '用户协议容量(MVA)', minWidth: 190 },
        { field: 'comFlag', title: '通讯状态 ', minWidth: 120 },
        { field: 'id', title: '监测点序号', minWidth: 120 },
        { field: 'devName', title: '监测终端编号 ', minWidth: 140 },
        { field: 'ptType', title: '监测终端接线方式', minWidth: 160 },
        { field: 'voltageDev', title: '电压偏差上限(%)', minWidth: 160 },
        { field: 'uvoltageDev', title: '电压偏差下限(%)', minWidth: 160 },
        {
            field: 'limitValue',
            title: '限值',
            children: [
                { field: 'freqDev', title: '频率(Hz)', minWidth: 120 },
                { field: 'ubalance', title: '三相电压不平衡度(%)', minWidth: 190 },
                { field: 'ineg', title: '负序电流(A)', minWidth: 120 },
                { field: 'flicker', title: '长时间闪变', minWidth: 120 },
                { field: 'uaberrance', title: '电压总谐波畸变率(%)', minWidth: 190 },
                { field: 'oddHarm', title: '奇数次谐波电压(%)', minWidth: 180 },
                { field: 'evenHarm', title: '偶数次谐波电压(%)', minWidth: 180 }
            ]
        },
        {
            field: 'evaluate',
            title: '电流限值',
            children: [
                { field: 'iharm2', title: '2次谐波(A)', minWidth: 120 },
                { field: 'iharm3', title: '3次谐波(A)', minWidth: 120 },
                { field: 'iharm4', title: '4次谐波(A)', minWidth: 120 },
                { field: 'iharm5', title: '5次谐波(A)', minWidth: 120 },
                { field: 'iharm6', title: '6次谐波(A)', minWidth: 120 },
                { field: 'iharm7', title: '7次谐波(A)', minWidth: 120 },
                { field: 'iharm8', title: '8次谐波(A)', minWidth: 120 },
                { field: 'iharm9', title: '9次谐波(A)', minWidth: 120 },
                { field: 'iharm10', title: '10次谐波(A)', minWidth: 140 },
                { field: 'iharm11', title: '11次谐波(A)', minWidth: 140 },
                { field: 'iharm12', title: '12次谐波(A)', minWidth: 140 },
                { field: 'iharm13', title: '13次谐波(A)', minWidth: 140 },
                { field: 'iharm14', title: '14次谐波(A)', minWidth: 140 },
                { field: 'iharm15', title: '15次谐波(A)', minWidth: 140 },
                { field: 'iharm16', title: '16次谐波(A)', minWidth: 140 },
                { field: 'iharm17', title: '17次谐波(A)', minWidth: 140 },
                { field: 'iharm18', title: '18次谐波(A)', minWidth: 140 },
                { field: 'iharm19', title: '19次谐波(A)', minWidth: 140 },
                { field: 'iharm10', title: '20次谐波(A)', minWidth: 140 },
                { field: 'iharm21', title: '21次谐波(A)', minWidth: 140 },
                { field: 'iharm22', title: '22次谐波(A)', minWidth: 140 },
                { field: 'iharm23', title: '23次谐波(A)', minWidth: 140 },
                { field: 'iharm24', title: '24次谐波(A)', minWidth: 140 },
                { field: 'iharm25', title: '25次谐波(A)', minWidth: 140 },
                { field: 'inUharm', title: '0.5-1.5次间谐波(A)', minWidth: 180 },
                { field: 'inUharm16', title: '2.5-15.5次间谐波(A)', minWidth: 190 }
            ]
        }
    ],
    resetCallback: () => {
        interferenceSourceForm.value = []
        scaleForm.value = []
    }
})
tableStore.table.params.scale = []
tableStore.table.params.comFlag = []
tableStore.table.params.loadType = []
tableStore.table.params.statisticalType = {}
tableStore.table.params.serverName = 'event-boot'
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)

onMounted(() => {
    tableStore.index()
})

const onLoadTypeChange = () => {
    tableStore.table.params.loadType = interferenceSource
        .filter(item => {
            return interferenceSourceForm.value.includes(item.id)
        })
        .map(item => {
            return { ...item, label: item.name, value: item.id }
        })
}
const onScaleChange = () => {
    tableStore.table.params.scale = level
        .filter(item => {
            return scaleForm.value.includes(item.id)
        })
        .map(item => {
            return { ...item, label: item.name, value: item.id }
        })
}
</script>
