<template>
    <div>
        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>

                <el-form-item label="单位名称" prop="unit_name">
                    <el-input class="w-[280px]" v-model="queryParams.unit_name" clearable placeholder="请输入单位名称" />
                </el-form-item>
                <el-form-item label="资质等级" prop="qualification_grade">
                    <el-input class="w-[280px]" v-model="queryParams.qualification_grade" clearable placeholder="请输入资质等级" />
                </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>
            <div class="mt-4">
                <el-table :data="pager.lists" @cell-click="handleCurrentChange">
                    <el-table-column label="单位名称" prop="unit_name" show-overflow-tooltip />
                    <el-table-column label="单位类别" prop="unit_type_text" show-overflow-tooltip />
                    <el-table-column label="资质等级" prop="qualification_grade" show-overflow-tooltip />
                    <el-table-column label="联系电话" prop="telephone" show-overflow-tooltip />
                    <el-table-column label="责任范围" prop="duty" show-overflow-tooltip />
                </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>
import { usePaging } from "@/hooks/usePaging"
import { apiSupervisionParticipatingUnitsLists, } from '@/api/supervision_participating_units'



import { defineEmits } from "vue"

const props = defineProps({
    project_id: Number
})
// 查询条件
const queryParams = reactive({
    unit_name: '',
    qualification_grade: "",
    project_id: props.project_id || ''

});

// 选中数据
const emits = defineEmits(["customEvent"]);

// 选中数据子父传递
const handleCurrentChange = (value: any) => {
    emits("customEvent", value);
};

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: apiSupervisionParticipatingUnitsLists,
    params: queryParams,
});

getLists();
</script>