<template>
    <div>
        <el-card class="!border-none mb-4" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="审核状态" prop="project_type">
                    <el-select v-model="queryParams.check_status">
                        <el-option v-for="(item, index) in dictData.check_status" :key="index" :label="item.name"
                            :value="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <div class="mt-4">
                <el-table border :data="pager.lists" @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="序号" type="index" width="55" />
                    <el-table-column label="审批主题" prop="title" show-overflow-tooltip />
                    <el-table-column label="申请人" prop="create_user" show-overflow-tooltip />
                    <el-table-column label="审核状态" prop="check_status" show-overflow-tooltip />
                    <el-table-column label="申请时间" prop="create_time" show-overflow-tooltip />
                    <el-table-column label="审批类型" prop="flow_type_name" show-overflow-tooltip />
                    <el-table-column label="审批流程" prop="flow_name" show-overflow-tooltip />
                    <el-table-column label="当前审批人" prop="current_check_user" show-overflow-tooltip />
                    <el-table-column label="抄送人" prop="copy_user" show-overflow-tooltip />
                    <el-table-column label="操作" width="170" fixed="right">
                        <template #default="{ row }">
                            <router-link :to="{
                                path: row.path,
                                query: { listId: row.content_id }
                            }">
                                <el-button v-perms="['safety.safety_target/edit']" type="primary" link>
                                    详情
                                </el-button>
                            </router-link>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>

<script lang="ts" setup name="projectLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { flowapproveLists } from '@/api/approve.ts'

// 查询条件
const queryParams = reactive({
    type: 1,
    check_status: '',
})


// 选中数据
const selectData = ref<any[]>([])

// 表格选择后回调事件
const handleSelectionChange = (val: any[]) => {
    selectData.value = val.map(({ id }) => id)
}

// 获取字典数据
const { dictData } = useDictData('check_status')
// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: flowapproveLists,
    params: queryParams
})





getLists()
</script>

