<template>
    <TableHeader area ref="TableHeaderRef">
        <template #select>
            <el-form-item label="干扰源类型">
                <el-select v-model="tableStore.table.params.loadType" clearable placeholder="请选择干扰源类型">
                    <el-option
                        v-for="item in interferenceType"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="干扰源用户名称">
                <el-input
                    v-model="tableStore.table.params.userName"
                    clearable
                    placeholder="请选择干扰源用户名称"
                ></el-input>
            </el-form-item>
        </template>
        <template #operation>
            <el-button icon="el-icon-Stamp" type="primary">审核</el-button>
        </template>
    </TableHeader>
    <Table ref="tableRef" />
    <!-- 审核 -->
    <Audit ref="AuditRef" @onSubmit="tableStore.index()" />
</template>

<script setup lang="ts">
import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { mainHeight } from '@/utils/layout'
import { useDictData } from '@/stores/dictData'
import Audit from './audit.vue'

const dictData = useDictData()
const interferenceType = dictData.getBasicData('Interference_Source')

const TableHeaderRef = ref()
const AuditRef = ref()

const tableStore = new TableStore({
    url: '/process-boot/loadTypeUserManage/getLoadTypeUserList',
    publicHeight: 65,
    method: 'POST',
    column: [
        { field: 'orgName', title: '所属单位' },
        {
            field: 'loadType',
            title: '干扰源类型',
            formatter: row => {
                return interferenceType.filter(item => item.id == row.cellValue)[0]?.name
            }
        },
        { field: 'userName', title: '干扰源用户名称' },
        { field: 'recordTime', title: '建档时间' },
        { field: 'iuploadTime', title: '报告提交评估时间' },
        {
            title: '操作',
            width: '120',
            render: 'buttons',
            buttons: [
                {
                    name: 'edit',
                    title: '审核',
                    type: 'primary',

                    icon: 'el-icon-Plus',
                    render: 'basicButton',
                    click: row => {
                        AuditRef.value.open('入网评估报告审核', row)
                    }
                }
            ]
        }
    ],

    beforeSearchFun: () => {
        tableStore.table.params.orgNo = tableStore.table.params.deptIndex
        tableStore.table.params.checkType = 1
    }
})

tableStore.table.params.loadType = ''
tableStore.table.params.userName = ''

provide('tableStore', tableStore)
onMounted(() => {
    tableStore.index()
})
</script>
