<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="查询" prop="name">
                    <el-input class="w-[280px]" v-model="queryParams.name" 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>
        </el-card>

        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <div class="mt-4">
                <el-table :data="pager.lists" @cell-click="handleCurrentChange">
                    <el-table-column label="项目编码" property="project_code" />
                    <el-table-column label="项目名称" property="project_name" />
                    <el-table-column label="姓名" property="name" />
                    <el-table-column label="身份证号" property="idcard" />
                    <el-table-column label="手机号" property="mobile" />
                    <el-table-column label="身份证正面" property="idcard_front">
                        <template #default="{ row }">
                            <div v-if="row.file && row.idcard_front.length > 0">
                                <el-link :href="row.idcard_front" target="_blank">文件{{ i + 1 }}查看</el-link>
                            </div>
                            <div v-else>
                                暂无文件
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="身份证反面" property="idcard_backend">
                        <template #default="{ row }">
                            <div v-if="row.file && row.idcard_backend.length > 0">
                                <el-link :href="row.idcard_backend" target="_blank">文件{{ i + 1 }}查看</el-link>
                            </div>
                            <div v-else>
                                暂无文件
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="银行卡照片" property="bank_card">
                        <template #default="{ row }">
                            <div v-if="row.file && row.bank_card.length > 0">
                                <el-link :href="row.bank_card" target="_blank">文件{{ i + 1 }}查看</el-link>
                            </div>
                            <div v-else>
                                暂无文件
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="银行卡号" property="bank_no" />
                    <el-table-column label="开户银行" property="deposit_bank" />
                    <el-table-column label="工种" property="work_type_text" />
                    <el-table-column label="人工单价" property="deposit_bank" />
                    <el-table-column label="备注" property="master_name" />
                </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 { useDictData } from "@/hooks/useDictOptions"
import { projectpersonnelLists } from '@/api/project_personnel'
import { defineEmits } from "vue"
const props = defineProps({
    project_id: {
        type: String
    }
})
// 查询条件
const queryParams = reactive({
    project_id: props.project_id,
});


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

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

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

getLists();
</script>