<template>
    <el-dialog draggable width="1100px" v-model="dialogVisible" title="暂降事件列表">
        <div style="height: 40vh">
            <vxe-table v-loading="loading" height="auto" auto-resize :data="tableData" v-bind="defaultAttribute">
                <vxe-column type="seq" title="序号" width="80px"></vxe-column>
                <vxe-column field="startTime" title="暂降发生时刻" width="200" sortable></vxe-column>
                <vxe-column field="featureAmplitude" title="暂降(骤升)幅值(%)" width="160" sortable>
                    <template #default="{ row }">
                        {{ (row.featureAmplitude * 100).toFixed(2) }}
                    </template>
                </vxe-column>
                <vxe-column field="duration" title="持续时间(s)" width="120" sortable></vxe-column>
                <vxe-column field="advanceType" title="触发类型" width="100">
                    <template #default="{ row }">
                        {{ type.find(item => item.id === row.advanceType)?.name }}
                    </template>
                </vxe-column>
                <vxe-column field="gdName" title="供电公司" min-width="140"></vxe-column>
                <vxe-column field="subName" title="变电站" min-width="140"></vxe-column>
                <vxe-column field="lineName" title="监测点名称" min-width="140"></vxe-column>
            </vxe-table>
        </div>
    </el-dialog>
</template>
<script lang="ts" setup>
import { ref, inject } from 'vue'

import { defaultAttribute } from '@/components/table/defaultAttribute'
import { getNoDealEventsByLineId } from '@/api/event-boot/areaInfo'
import { useDictData } from '@/stores/dictData'
const dictData = useDictData()
const type = dictData.getBasicData('Event_Type')
const dialogVisible = ref(false)
const tableData = ref([])
const loading = ref(true)
const open = (params: any) => {
    dialogVisible.value = true
    loading.value = true
    getNoDealEventsByLineId(params).then(res => {
        tableData.value = res.data
        loading.value = false
    })
}
defineExpose({ open })
</script>
