
<template>
    <div >
        <TableHeader ref="TableHeaderRef">
            <template v-slot:select>
               <el-form-item label="名称">
                    <el-input v-model="tableStore.table.params.searchValue" clearable
                        placeholder="请输入搜索名称" maxlength="32" show-word-limit/>
                </el-form-item>
            </template>

        </TableHeader>
        
        <Table ref="tableRef" isGroup/>
    </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'

const tableRef = ref()
const tableStore = new TableStore({
    url: '/supervision-boot/libModel/pageLibModelQuery',
    method: 'POST',
    showPage: true, // 确保启用分页
        publicHeight: 60,
    column: [
        {
            title: '典型设备',
            children: [
                {
                    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: 200 },
                { field: 'voltage', title: '电压等级',minWidth: 100  },
                { field: 'capacity', title: '容量',minWidth: 100  }
            ]
        },
        {
            title: '各次谐波阻抗 (Ω)',
            width: 1800,
            children: Array.from({ length: 24 }, (_, i) => ({
                field: `i${i + 2}`,
                title: `${i + 2}次`,
                minWidth: 100
            }))
        }
    ],
    // 在请求发送前处理参数
    beforeSearchFun: () => {
            tableStore.table.params.pageSize = 100
    },
    resetCallback: () => {
        tableStore.table.params.searchValue = ''
    },
})

tableStore.table.params.type = 0
provide('tableStore', tableStore)


// 暴露查询方法给父组件调用
const queryData = () => {
    tableStore.index()
}

defineExpose({
    queryData
})


</script>


