<template>
    <div>
        <div>
            <TableHeader ref="TableHeaderRef" showExport>
                <template #select>
                    <el-form-item label="所在地市">
                        <el-select v-model="tableStore.table.params.city" clearable placeholder="请选择所在地市">
                            <el-option
                                v-for="item in areaOptionList"
                                :key="item.id"
                                :label="item.name"
                                :value="item.name"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="用户名称">
                        <el-input
                            style="width: 200px"
                            placeholder="请输入用户名称"
                            v-model="tableStore.table.params.userName"
                            clearable
                            maxlength="32"
                            show-word-limit
                        ></el-input>
                    </el-form-item>
                    <el-form-item label="接入变电站">
                        <el-input
                            style="width: 200px"
                            placeholder="请输入接入变电站"
                            v-model="tableStore.table.params.projectName"
                            clearable
                            maxlength="32"
                            show-word-limit
                        ></el-input>
                    </el-form-item>
                    <el-form-item label="电站电压等级">
                        <el-select v-model="tableStore.table.params.scale" clearable placeholder="请选择电站电压等级">
                            <el-option
                                v-for="item in voltageleveloption"
                                :key="item.id"
                                :label="item.name"
                                :value="item.name"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="接入母线">
                        <el-input
                            style="width: 200px"
                            placeholder="请输入接入母线"
                            v-model="tableStore.table.params.projectName"
                            clearable
                            maxlength="32"
                            show-word-limit
                        ></el-input>
                    </el-form-item>
                </template>
                <template #operation>
                    <el-button icon="el-icon-Plus" type="primary" @click="addForm">新增</el-button>
                    <el-button icon="el-icon-Delete">删除</el-button>
                </template>
            </TableHeader>
            <Table ref="tableRef" />
        </div>
    </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 { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox, ElDatePicker } from 'element-plus'
import { useRouter } from 'vue-router'
const { push } = useRouter()
const dictData = useDictData()
const areaOptionList = dictData.getBasicData('jibei_area')
//字典获取电压等级
const voltageleveloption = dictData.getBasicData('Dev_Voltage_Stand')
const tableStore: any = new TableStore({
    url: '/user-boot/user/getAllUserSimpleList',
    method: 'GET',
    publicHeight: 65,
    column: [
        { field: 'timerName', title: '所属地市' },
        { field: 'timerName', title: '用户名称' },
        { field: 'timerName', title: '接入变电站' },
        { field: 'timerName', title: '电站电压等级' },
        { field: 'timerName', title: '接入母线' },
        { field: 'timerName', title: '接入电压等级' },
        { field: 'timerName', title: '供电设备容量(MVA)' },
        { field: 'timerName', title: '最小短路容量(MVA)' },
        { field: 'timerName', title: '用户协议容量(MVA)' },

        {
            title: '操作',
            width: '220',
            render: 'buttons',
            buttons: [
                {
                    name: 'edit',
                    title: '编辑',
                    type: 'primary',
                    icon: 'el-icon-EditPen',
                    render: 'basicButton',

                    click: async row => {}
                },
                {
                    name: 'edit',
                    title: '查看',
                    type: 'primary',
                    icon: 'el-icon-EditPen',
                    render: 'basicButton',

                    click: async row => {}
                }
            ]
        }
    ],

    loadCallback: () => {
        // 格式化 cron 表达式
        tableStore.table.data = []
    }
})
tableStore.table.params.searchValue = ''
tableStore.table.params.searchState = ''

provide('tableStore', tableStore)
// 新增评估用户页面
const addForm = () => {
    push({
        path: 'addUser',
        query: {
            type: 1,
            t: Date.now()
        }
    })
}
onMounted(() => {
    tableStore.index()
})
</script>
