<template>
    <TableHeader area datePicker ref="TableHeaderRef">
        <template #select>
            <el-form-item label="问题来源">
                <el-select v-model="tableStore.table.params.searchState1" placeholder="请选择问题来源">
                    <el-option
                        v-for="item in uploadData"
                        :key="item.id"
                        :label="item.label"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="填报进度">
                <el-select v-model="tableStore.table.params.searchState2" placeholder="请选择填报进度">
                    <el-option
                        v-for="item in uploadData"
                        :key="item.id"
                        :label="item.label"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="审核状态">
                <el-select v-model="tableStore.table.params.searchState3" placeholder="请选择审核状态">
                    <el-option
                        v-for="item in uploadData"
                        :key="item.id"
                        :label="item.label"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="问题名称">
                <el-select v-model="tableStore.table.params.searchState4" placeholder="请输入问题名称">
                    <el-option
                        v-for="item in uploadData"
                        :key="item.id"
                        :label="item.label"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
        </template>
        <template #operation>
            <el-button icon="el-icon-Plus" type="primary" @click="add">新增</el-button>
            <el-button icon="el-icon-EditPen" type="primary">填报</el-button>
            <el-button icon="el-icon-Delete" type="primary">删除</el-button>
            <el-button icon="el-icon-SuccessFilled" type="primary">归档</el-button>
            <el-button icon="el-icon-PieChart" type="primary">历史审核记录</el-button>
        </template>
    </TableHeader>
    <Table ref="tableRef" />
    <!-- 新增 -->
    <NewlyAdd v-if="showNewlyAdded" @handleClose="handleClose" @onSubmit="onSubmit"  />
</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 NewlyAdd from './NewlyAdd.vue'
const dictData = useDictData()
const uploadData = [
    {
        id: 0,

        label: '未上传'
    },
    {
        id: 1,

        label: '已上传'
    }
]

const showNewlyAdded = ref(false)
const TableHeaderRef = ref()
const ruleFormRef = ref()
const tableStore:any = new TableStore({
    url: '/system-boot/area/areaSelect',
    publicHeight: 65,
    method: 'POST',
    column: [
        { width: '60', type: 'checkbox' },
        {
            field: 'index',
            title: '序号',
            width: '60',
            formatter: (row: any) => {
                return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
            }
        },
        { field: 'orgName', title: '所属单位' },
        {
            field: 'problemSources',
            title: '问题来源'
        },
        { field: 'powerQualityProblemNo', title: '问题编号' },
        { field: 'problemName', title: '问题名称' },
        { field: 'dataDate', title: '问题新建时间' },
        { field: 'reportProcess', title: '填报进度' },
        { field: 'reportProcessStatus', title: '审核状态' },
        {
            title: '详情',
            width: '120',
            render: 'buttons',
            buttons: [
                {
                    name: 'edit',
                    title: '查看',
                    type: 'primary',
                    disabled: row => {
                        return row.reportProcess != 'Not_Reported' && row.reportProcess != 'Archived'
                    },
                    icon: 'el-icon-Plus',
                    render: 'basicButton',
                    click: async row => {}
                }
            ]
        }
    ],

    loadCallback: () => {
        tableStore.table.data = [
            {
                status: 2
            }
        ]
    }
})

tableStore.table.params.searchState1 = ''
tableStore.table.params.searchState2 = ''
tableStore.table.params.searchState3 = ''
tableStore.table.params.searchState4 = ''

provide('tableStore', tableStore)
onMounted(() => {
    tableStore.index()
})
// 新增
const add = () => {
    showNewlyAdded.value = true
}
const onSubmit = () => {
    console.log(123)
}
// 关闭弹框
const handleClose = () => {
    showNewlyAdded.value = false
}
</script>
