<template>
    <div class="default-main">
        <TableHeader date-picker area showExport>
            <template #select>
                    <el-form-item label="统计类型:" v-if="false">
                        <el-select
                            v-model="tableStore.table.params.statisticalType"
                            placeholder="请选择统计类型"
                            value-key="id"
                            style="width: 100%"
                        >
                            <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="电压等级:" v-if="false">
                        <el-select
                            v-model="tableStore.table.params.scale"
                            multiple
                            collapse-tags
                            clearable
                            placeholder="请选择电压等级"
                            style="width: 100%"
                            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="终端厂家:" v-if="false">
                        <el-select
                            v-model="tableStore.table.params.manufacturer"
                            multiple
                            collapse-tags
                            clearable
                            placeholder="请选择终端厂家"
                            style="width: 100%"
                            value-key="id"
                        >
                            <el-option
                                v-for="(item, index) in terminaloption"
                                :key="index"
                                :label="item.name"
                                :value="item"
                            ></el-option>
                        </el-select>
                    </el-form-item> 
                    
                    <el-form-item label="干扰源类型:">
                        <el-select
                            v-model="tableStore.table.params.loadType"
                            multiple
                            collapse-tags
                            clearable
                            placeholder="请选择干扰源类型"
                            style="width: 100%"
                            value-key="id"
                        >
                            <el-option
                                v-for="(item, index) in interfereoption"
                                :key="index"
                                :label="item.name"
                                :value="item"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="电网标志">
                    <el-select v-model="tableStore.table.params.powerFlag" placeholder="请选择电网标志">
                        <el-option v-for="item in sign" :key="item.id" :label="item.name" :value="item.algoDescribe" />
                    </el-select>
                    </el-form-item>
            </template>
        </TableHeader>
        <Table ref="tableRef" />
    </div>
</template>
<script lang="ts" setup>
import { ref, onMounted, watch } from 'vue'
import { useDictData } from '@/stores/dictData'
import { getAreaDept } from '@/api/harmonic-boot/area'
import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'

defineOptions({
    name: 'harmonic-boot/area/harmonicDistortionRate'
})

const dictData = useDictData()
//字典获取电压等级
const voltageleveloption = dictData.getBasicData('Dev_Voltage_Stand')
//字典获取终端厂家
const terminaloption = dictData.getBasicData('Dev_Manufacturers')
//字典获取统计类型
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
//字典获取干扰源类型
const interfereoption = dictData.getBasicData('Interference_Source')
const sign = dictData.getBasicData('power_flag')



const tableStore = new TableStore({
    url: '/harmonic-boot/tHDistortion/getTHDistortionTableData',
    isWebPaging: true,
    method: 'POST',
     column: [
        {
            field: 'index',
            title: '序号',
            width: '80',
            formatter: (row: any) => {
                return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
            }
        },  
        {
            field: 'subStation',
            title: '变电站',
             minWidth: 150
        },
         {
            field: 'city',
            title: '所在地市',
            minWidth: 100
        },
        {
            field: 'manufacturer',
            title: '终端厂家',
            minWidth: 80
        },
         {
            field: 'deviceName',
            title: '终端名称',
            minWidth: 80
        },
      
        {
            title: '网络参数',
            field: 'ip',
            align: 'center',
            formatter: function (row) {
                return row.cellValue ? row.cellValue : '/'
            },
            minWidth: 120
        },
        {
            title: '监测点名称',
            field: 'lineName',
            align: 'center',
            formatter: function (row) {
                return row.cellValue ? row.cellValue : '/'
            },
            minWidth: 100
        },
        {
            title: '总谐波畸变率(%)',
            field: 'distortion',
            align: 'center',
            formatter: function (row) {
                return row.cellValue == 3.14159 ? '暂无数据' : row.cellValue
            },
            minWidth: 120
        }
    ],

  
})

tableStore.table.params.statisticalType = classificationData[0]
tableStore.table.params.scale = []
tableStore.table.params.manufacturer = []
tableStore.table.params.loadType = []
tableStore.table.params.serverName = 'harmonicBoot'
tableStore.table.params.powerFlag = sign[0]?.algoDescribe || 0
provide('tableStore', tableStore)


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