<template>
    <div class="default-main">
        <!-- 模版 -->
        <TableHeader datePicker showExport :showReset="false" ref="TableHeaderRef">
            <template #select>
                <!-- <el-form-item label="关键字">
                    <el-input v-model="tableStore.table.params.searchValue" clearable placeholder="请输入关键字" />
                </el-form-item> -->
            </template>
            <template #operation>
                <el-button type="primary" icon="el-icon-CreditCard"
                    @click="push('/admin/division/compute')">谐波贡献度计算</el-button>
                <el-button type="primary" icon="el-icon-Tickets"
                    @click="push('/admin/division/aListOfLoadData')">用采数据列表</el-button>
            </template>
        </TableHeader>
        <Table ref="tableRef"></Table>

    </div>
</template>
<script setup lang="ts">
import { onMounted, ref, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import TableHeader from '@/components/table/header/index.vue'
import { ElMessage } from 'element-plus'
import Table from '@/components/table/index.vue'
import { useAdminInfo } from '@/stores/adminInfo'
import { deleteByIds } from '@/api/advance-boot/division'
import { useRouter } from 'vue-router'
const { push } = useRouter()
defineOptions({
    name: 'harmonic-boot/detailedAnalysis/responsibility'
})

const TableHeaderRef = ref()

const tableStore = new TableStore({
    url: '/advance-boot/responsibility/responsibilityList',
    method: 'POST',
    column: [
        { title: '供电公司', field: 'gdName' },
        { title: '变电站', field: 'subName' },
        { title: '终端名称', field: 'devName' },
        { title: 'IP', field: 'ip' ,width:'120px' },
        { title: '监测点名称', field: 'lineName' },
        { title: '类型', field: 'dataType' },
        { title: '谐波次数', field: 'dataTimes' },
        { title: '用采数据', field: 'userDataName' },
        { title: '计算时间', field: 'updateTime' },
        { title: '计算窗口', field: 'timeWindow' },
        {
            title: '操作',
            width: '180',
            render: 'buttons',
            buttons: [

                {
                    name: 'edit',
                    title: '查看详情 ',
                    type: 'primary',
                    icon: 'el-icon-Plus',
                    render: 'basicButton',

                    click: row => {
             
                        push({
                            path: "/admin/division/detail",
                            query: {
                                id: row.id,
                                time: row.dataTimes,
                                name: `${row.gdName}>${row.subName}>${row.devName}>${row.lineName}`
                            }
                        })
                    }
                },
                {
                    title: '删除',
                    type: 'danger',
                    icon: 'el-icon-Delete',
                    render: 'confirmButton',

                    popconfirm: {
                        confirmButtonText: '确认',
                        cancelButtonText: '取消',
                        confirmButtonType: 'danger',
                        title: '确定删除吗？'
                    },
                    click: row => {
                        deleteByIds([row.id]).then(() => {
                            ElMessage.success('删除成功')
                            tableStore.index()
                        })
                    }
                }
            ]
        }
    ],
    loadCallback: () => { }
})
tableStore.table.params.searchValue = ''
// 弹框





provide('tableStore', tableStore)
onMounted(() => {
    tableStore.index()

})
</script>
<style lang="scss"></style>
