
<template>
    <div class="detail-popup">
        <popup ref="popupRef" title="项目人员详情" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-form ref="formRef" :model="formData" label-width="120px">

                <el-row>
                    <el-col :span="12">
                        <el-form-item label="项目名称">
                            {{ formData.project_name }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="项目编码">
                            {{ formData.project_code }}
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="姓名">
                            {{ formData.name }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="身份证号">
                            {{ formData.idcard
                            }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="工种">
                            {{ formData.work_type_text }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="人工单价">
                            {{ formData.unit_price }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="身份证正面">
                            <div v-if="formData.idcard_front && formData.idcard_front.length > 0">
                                <material-picker v-model="formData.idcard_front" />
                            </div>
                            <div v-else>暂无照片</div>

                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="身份证反面">
                            <div v-if="formData.idcard_backend && formData.idcard_backend.length > 0">
                                <material-picker v-model="formData.idcard_backend" />
                            </div>
                            <div v-else>暂无照片</div>

                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="银行卡照片">
                            <div v-if="formData.bank_card && formData.bank_card.length > 0">
                                <material-picker v-model="formData.bank_card" />
                            </div>
                            <div v-else>暂无照片</div>

                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="银行卡号">
                            {{ formData.bank_no }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="开户银行">
                            {{ formData.deposit_bank }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="备注">
                            {{ formData.remark }}
                        </el-form-item>
                    </el-col>

                </el-row>

                <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
                    <el-tab-pane label="劳动合同" name="first">
                        <el-table :data="laborContractsList">


                            <el-table-column label="姓名" prop="person_name" show-overflow-tooltip />
                            <el-table-column label="身份证号" prop="person_idcard" show-overflow-tooltip />
                            <el-table-column label="合同状态" prop="contract_status_text" show-overflow-tooltip />
                            <el-table-column label="合同类别" prop="contract_type_text" show-overflow-tooltip />
                            <el-table-column label="合同名称" prop="contract_title_text" show-overflow-tooltip />
                            <el-table-column label="合同签定日期" prop="signing_date" show-overflow-tooltip />
                            <el-table-column label="起始时间" prop="start_date" show-overflow-tooltip />
                            <el-table-column label="终止时间" prop="end_date" show-overflow-tooltip />
                            <el-table-column label="备注" prop="remark" show-overflow-tooltip />

                        </el-table>

                    </el-tab-pane>
                    <el-tab-pane label="保险记录" name="second">
                        <el-table :data="insurancesList">
                            <el-table-column label="姓名" prop="person_name" show-overflow-tooltip />
                            <el-table-column label="身份证号" prop="person_idcard" show-overflow-tooltip />
                            <el-table-column label="投保日期" prop="insurance_date" show-overflow-tooltip />
                            <el-table-column label="到期日期" prop="due_date" show-overflow-tooltip />
                            <el-table-column label="保险种类" prop="type" show-overflow-tooltip />
                            <el-table-column label="保单号" prop="insurance_no" show-overflow-tooltip />
                            <el-table-column label="保费（元）" prop="insurance" show-overflow-tooltip />
                            <el-table-column label="投保金额（万元）" prop="insured_amount" show-overflow-tooltip />
                            <el-table-column label="保险公司" prop="insurance_company" show-overflow-tooltip />
                        </el-table>
                    </el-tab-pane>
                    <el-tab-pane label="考勤明细" name="third">
                        <el-table :data="attendancesList">

                            <el-table-column label="日记工单号" prop="attendance_code" show-overflow-tooltip />
                            <el-table-column label="日期" prop="attendance_date" show-overflow-tooltip />
                            <el-table-column label="姓名" prop="person_name" show-overflow-tooltip />
                            <el-table-column label="身份证号" prop="person_idcard" show-overflow-tooltip />
                            <el-table-column label="工种" prop="work_type_text" show-overflow-tooltip />
                            <el-table-column label="上班时间" prop="work_start_time" show-overflow-tooltip />
                            <el-table-column label="下班时间" prop="work_end_time" show-overflow-tooltip />
                            <el-table-column label="记工数量" prop="work_record_num" show-overflow-tooltip />
                            <el-table-column label="日工资" prop="daily_salary" show-overflow-tooltip />
                            <el-table-column label="日生活费" prop="daily_living" show-overflow-tooltip />
                            <el-table-column label="日补贴" prop="daily_subsidy" show-overflow-tooltip />
                            <el-table-column label="日其它" prop="daily_other" show-overflow-tooltip />
                            <el-table-column label="日收入" prop="daily_income" show-overflow-tooltip />
                            <el-table-column label="备注" prop="remark" show-overflow-tooltip />
                        </el-table>
                    </el-tab-pane>
                    <el-tab-pane label="施工记录" name="fourth">
                        <el-table :data="buildworksList">
                            <el-table-column label="施工汇报单号" prop="report_code" show-overflow-tooltip />
                            <el-table-column label="作业编码" prop="zy_code" show-overflow-tooltip />
                            <el-table-column label="分项工程" prop="subentry_engineering" show-overflow-tooltip />
                            <el-table-column label="工序步骤" prop="process_step" show-overflow-tooltip />
                            <el-table-column label="日期" prop="report_date" show-overflow-tooltip />
                            <el-table-column label="姓名" prop="person_name" show-overflow-tooltip />
                            <el-table-column label="身份证号" prop="person_idcard" show-overflow-tooltip />
                            <el-table-column label="工种" prop="work_type_text" show-overflow-tooltip />
                            <el-table-column label="完工量" prop="work_num" show-overflow-tooltip />
                            <el-table-column label="单位" prop="unit" show-overflow-tooltip />
                            <el-table-column label="单价" prop="price" show-overflow-tooltip />
                            <el-table-column label="金额" prop="amount" show-overflow-tooltip />
                        </el-table>
                    </el-tab-pane>
                    <el-tab-pane label="工资付款" name="six">
                        <el-table :data="paymentList">

                            <el-table-column label="ID" prop="id" show-overflow-tooltip />
                            <el-table-column label="工资付款单号" prop="payment_code" show-overflow-tooltip />
                            <el-table-column label="日期" prop="apply_date" show-overflow-tooltip />
                            <el-table-column label="姓名" prop="person_name" show-overflow-tooltip />
                            <el-table-column label="身份证号" prop="person_idcard" show-overflow-tooltip />
                            <el-table-column label="工种" prop="person_work_type_text" show-overflow-tooltip />
                            <el-table-column label="总收入" prop="total_income" show-overflow-tooltip />
                            <el-table-column label="总支出" prop="total_pay_out" show-overflow-tooltip />
                            <el-table-column label="未发放" prop="balance" show-overflow-tooltip />
                            <el-table-column label="本次付款金额" prop="apply_amount" show-overflow-tooltip />
                            <el-table-column label="备注" prop="remark" show-overflow-tooltip />

                        </el-table>
                    </el-tab-pane>
                </el-tabs>


            </el-form>
        </popup>
    </div>
</template>

<script lang="ts" setup name="customdetail">

import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { personnelbuildworks, personnelattendances, personneinsurances, personnelaborContracts, personnelpayments } from '@/api/project_personnel'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
import type { TabsPaneContext } from 'element-plus'
const formDataannex = reactive([])
const laborContractsList = ref([])
const insurancesList = ref([])
const attendancesList = ref([])
const buildworksList = ref([])
const paymentList = ref([])

const datas = reactive({
    provinceOptions: [],
    cityOptions: [],
    areaOptions: [],
});

const activeName = ref('first')

const handleClick = (tab: TabsPaneContext, event: Event) => {
    console.log(tab, event)
}
// 表单数据
const formData = reactive({

})

//获取某个人员下的劳动合同列表
const laborContracts = async (id: any) => {
    let res = await personnelaborContracts({ person_id: id, page_no: 1, page_size: 9999 })
    laborContractsList.value = res.lists

}

//获取某个人员下的保险列表
const insurances = async (id: any) => {
    let res = await personneinsurances({ person_id: id, page_no: 1, page_size: 9999 })
    insurancesList.value = res.lists
}
//某个人员下的考勤明细列表

const attendances = async (id: any) => {
    let res = await personnelattendances({ person_id: id, page_no: 1, page_size: 9999 })
    attendancesList.value = res.lists
}
//某个人员下的施工记录列表
const buildworks = async (id: any) => {
    let res = await personnelbuildworks({ person_id: id, page_no: 1, page_size: 9999 })
    buildworksList.value = res.lists


}

//某个人员下的施工记录列表
const payment = async (id: any) => {
    let res = await personnelpayments({ person_id: id, page_no: 1, page_size: 9999 })
    paymentList.value = res.lists


}


// 获取详情
const setFormData = async (data: Record<any, any>) => {
    laborContracts(data.id)
    attendances(data.id)
    insurances(data.id)
    buildworks(data.id)
    payment(data.id)
    Object.assign(formData, data)
}

const getDetail = async (row: Record<string, any>) => {
    const data = await apiCustomDetail({
        id: row.id
    })
    setFormData(data)
}


// 提交按钮
const handleSubmit = async () => {
    popupRef.value?.close()

}

//打开弹窗
const open = () => {
    console.log('1111111')
    popupRef.value?.open()
}

// 关闭回调
const handleClose = () => {
    emit('close')
}








defineExpose({
    open,
    setFormData,
    getDetail
})
</script>
<style lang="scss" scoped>
.tit {
    font-size: 1.2em;
    margin-bottom: 10px;
}

:deep(.my-label) {
    width: 150px;
}
</style>
