<template>
    <div class="dictiontary-list-detail child-router">
        <TableHeader :showSearch="false" showCustomColumn>
            <template #select>
                <el-form-item label="">
                    <span class="text-large font-600 mr-3">{{ props.timePopUpBox.time }}</span>
                </el-form-item>
                <el-form-item>
                    <el-radio-group v-model="radio2" @change="tableStore.index()">
                        <el-radio-button label="基础数据" value="1" />
                        <el-radio-button label="谐波电压" value="2" />
                        <el-radio-button label="谐波电流" value="3" />
                        <el-radio-button label="间谐波电压" value="4" />
                    </el-radio-group>
                </el-form-item>
            </template>
            <template #operation>
                <el-button icon="el-icon-Back" @click="$emit('close')">返回</el-button>
            </template>
        </TableHeader>
        <Table ref="tableRef" isGroup />
    </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 TableHeader from '@/components/table/header/index.vue'
import { ElMessage } from 'element-plus'
import { dictDataDelete } from '@/api/system-boot/dicData'

defineOptions({
    name: 'setting/dictionary/list/detail'
})
const radio2 = ref('1')
interface Props {
    timePopUpBox: anyObj
}
const props = withDefaults(defineProps<Props>(), {
    timePopUpBox: () => {
        return {}
    }
})
const popupEditRef = ref()
const tableStore = new TableStore({
    url: '/harmonic-boot/powerStatistics/getTargetByTime',
    method: 'POST',
    showPage: false,
    column: [
        {
            title: '指标',
            field: 'anotherName',
            minWidth: '120px',
            formatter: row => {
                row.column.title =
                    radio2.value == '1' ? '指标' : (row.column.title = radio2.value == '4' ? '间谐波次数' : '谐波次数')
                return row.cellValue
            }
        },
        { title: '单位', field: 'unit' },
        {
            title: '最小值',
            field: 'min',
            children: [
                {
                    title: 'A',
                    field: 'minphaseA',
                    formatter: row => formatter(row)
                },
                { title: 'B', field: 'minphaseB', formatter: row => formatter(row) },
                { title: 'C', field: 'minphaseC', formatter: row => formatter(row) }
            ]
        },
        {
            title: '最大值',
            field: 'max',
            children: [
                { title: 'A', field: 'maxphaseA', formatter: row => formatter(row) },
                { title: 'B', field: 'maxphaseB', formatter: row => formatter(row) },
                { title: 'C', field: 'maxphaseC', formatter: row => formatter(row) }
            ]
        },
        {
            title: '平均值',
            field: 'avg',
            children: [
                { title: 'A', field: 'avgphaseA', formatter: row => formatter(row) },
                { title: 'B', field: 'avgphaseB', formatter: row => formatter(row) },
                { title: 'C', field: 'avgphaseC', formatter: row => formatter(row) }
            ]
        },
        {
            title: 'cp95值',
            field: 'cp95',
            children: [
                { title: 'A', field: 'cp95PhaseA', formatter: row => formatter(row) },
                { title: 'B', field: 'cp95PhaseB', formatter: row => formatter(row) },
                { title: 'C', field: 'cp95PhaseC', formatter: row => formatter(row) }
            ]
        }
    ],
    beforeSearchFun: () => {
        tableStore.table.params.field = props.timePopUpBox.field
        tableStore.table.params.lineId = props.timePopUpBox.lineId
        tableStore.table.params.searchBeginTime = props.timePopUpBox.time
        tableStore.table.params.searchEndTime = props.timePopUpBox.time
        tableStore.table.params.statisticalId = radio2.value
    },
    loadCallback: () => {}
})

provide('tableStore', tableStore)
const formatter = (row: any) => {
    return row.cellValue || '/'
}
onMounted(() => {
    tableStore.index()
})
</script>
