<template>
    <TableHeader area ref="TableHeaderRef" showCustomColumn>
        <template #select>
            <el-form-item label="干扰源类型">
                <el-select v-model="tableStore.table.params.loadType" clearable placeholder="请选择干扰源类型" filterable>
                    <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 '../undocumented/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: [
        { title: '序号', field: 'index', width: 80, formatter: (row: any) => {
            return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
        }
        },
        { 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: '操作',fixed: 'right',
            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>
