<template>
    <div>
        <div>
            <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>
                    <el-form-item label="关联干扰源用户">
                        <el-input
                            v-model="tableStore.table.params.relationUserName"
                            clearable
                            placeholder="请选择关联干扰源用户"
                        ></el-input>
                    </el-form-item>

                    <el-form-item label="是否已上传实测">
                        <el-select
                            v-model="tableStore.table.params.aisFileUpload"
                            clearable
                            placeholder="请选择是否已上传实测"
                            filterable
                        >
                            <el-option label="否" value="0" />
                            <el-option label="是" value="1" />
                        </el-select>
                    </el-form-item>
                </template>
                <template #operation>
                    <el-button icon="el-icon-Upload" type="primary">上传</el-button>
                    <el-button icon="el-icon-Download" type="primary">导出</el-button>
                </template>
            </TableHeader>
            <Table ref="tableRef" />
        </div>
    </div>
</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 { addUse, updateUse, removeUse } from '@/api/advance-boot/bearingCapacity'

const dictData = useDictData()
const interferenceType = dictData.getBasicData('Interference_Source')
const istatusList = dictData.getBasicData('On-network_Status')
const TableHeaderRef = ref()

const tableStore = new TableStore({
    url: '/process-boot/loadTypeUserManage/getLoadTypeRelationList',
    publicHeight: 65,
    method: 'POST',
    column: [
        { width: '60', type: 'checkbox' },
        { field: 'orgName', title: '所属单位' },
        {
            field: 'loadType',
            title: '干扰源类型',
            formatter: row => {
                return interferenceType.filter(item => item.id == row.cellValue)[0]?.name
            }
        },
        { field: 'userName', title: '干扰源用户名称' },
        { field: 'relationUserName', title: '关联干扰源用户名称' },
        {
            field: 'istatus',
            title: '实测报告状态',
            formatter: row => {
                return istatusList.filter(item => item.id == row.cellValue)[0]?.name
            }
        },
        {
            field: 'createBy',
            title: '填报人',
            minWidth: 80,
            formatter: (row: any) => {
                return dictData.state.userList.filter(item => item.id == row.cellValue)[0]?.name
            }
        },
        {
             title: '操作',fixed: 'right',
            width: '180',
            render: 'buttons',
            buttons: [
                {
                    name: 'edit',
                    title: '查看',
                    type: 'primary',

                    icon: 'el-icon-Plus',
                    render: 'basicButton',
                    click: row => {}
                }
            ]
        }
    ],

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

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

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