<!--  -->
<template>
   <HcCard>
    <template #header>
        员工档案信息编辑
    </template>
    <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="left" label-width="auto" size="large">
                <el-row :gutter="20">
                    <el-col :span="8">
                        <el-form-item label="姓名:" prop="name">
                            <el-input v-model="formModel.name"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="年龄:" prop="location">
                            <el-input v-model="formModel.age" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="手机号:">
                            <el-select v-model="formModel.phone" class="block" placeholder="请选择" size="large">
                                <el-input v-model="formModel.phone" placeholder=""/>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="身份证号码:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="性别:">
                            <el-select v-model="formModel.sex" clearable placeholder="请选择" style="width: 100%;">
                                <el-option
                                label="男"
                                value="1"
                                />
                                <el-option
                                label="女"
                                value="2"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="民族:">
                            <el-input v-model="formModel.nation" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="身份证号码:" prop="type">
                            <el-input v-model="formModel.idNumber" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="出生日期:" >
                            <el-date-picker
                            v-model="formModel.birthday"
                            type="date"
                            placeholder=""
                            disabled
                            style="width: 100%;"
                             />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="试用期:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="身份证地址:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="入职时间:">
                            <el-date-picker
                            v-model="formModel.entryTime"
                            type="date"
                            placeholder=""
                            style="width: 100%;"
                             />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="合同类型:">
                            <el-input v-model="formModel.contactType" placeholder="" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="员工身份证（人像）:">
                            <!-- <el-input v-model="formModel.deptId" placeholder=""/> -->
                            <HcUploadFile
                            ref="HcUploadFileRef"
                                :options="UploadFileOptions"
                                @progress="HcUploadFileProgress"
                                @success="HcUploadFileSuccess"
                                @change="HcUploadFileChange"
                            >
                            <el-button size="large" type="primary" hc-btn>
                                <HcIcon name="upload-cloud-2"/>
                                <span>上传图像</span>
                            </el-button>
                            <span class="hc-form-file-pdf" v-show="infoData?.originalName">
                              {{ infoData?.originalName }}
                            </span>
                        </HcUploadFile>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="司龄:">
                            <el-input v-model="formModel.deptId" placeholder="" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="合同开始日期:">
                            <el-date-picker
                            v-model="formModel.startTime"
                            type="date"
                            placeholder=""
                            style="width: 100%;"
                             />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="员工身份证（国徽）:">
                            <HcUploadFile
                            ref="HcUploadFileRef"
                                :options="UploadFileOptions"
                                @progress="HcUploadFileProgress"
                                @success="HcUploadFileSuccess"
                                @change="HcUploadFileChange"
                            >
                                <el-button size="large" type="primary" hc-btn>
                                    <HcIcon name="upload-cloud-2"/>
                                    <span>上传图像</span>
                                </el-button>
                                <span class="hc-form-file-pdf" v-show="infoData?.originalName">
                                {{ infoData?.originalName }}
                                </span>
                             </HcUploadFile>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="职位:">
                            <el-input v-model="formModel.deptName" placeholder="" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="合同结束日期:">
                            <el-date-picker
                            v-model="formModel.startTime"
                            type="date"
                            placeholder=""
                            style="width: 100%;"
                            disabled
                             />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="婚姻状况:">
                             <el-select v-model="formModel.marriage" clearable placeholder="请选择" style="width: 100%;">
                                  <el-option
                                label="已婚"
                                value="1"
                                />
                                <el-option
                                label="未婚"
                                value="2"
                             />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="邮箱:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="续签次数:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="户籍:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="部门:">
                            <el-input v-model="formModel.deptId" placeholder="" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="合同附件:">
                            <el-link type="primary" :href="formModel.pdflink">附件.pdf</el-link>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="学历:">
                            <el-select v-model="formModel.education" class="m-2" placeholder="请选择" size="large" style="width: 100%;">
                                <el-option
                                v-for="item in educationalOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="直属主管:">
                            <el-input v-model="formModel.deptId" placeholder="" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="紧急联系人姓名:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="专业:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="政治面貌:">
                            <el-select v-model="formModel.political" clearable placeholder="请选择" style="width: 100%;">
                                  <el-option
                                label="党员"
                                value="1"
                                />
                                <el-option
                                label="非党员"
                                value="2"
                             />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="联系人电话:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="开户行:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="员工状态:">
                            <el-select v-model="formModel.staus" clearable placeholder="请选择" style="width: 100%;">
                                  <el-option
                                label="在职"
                                value="1"
                                />
                                <el-option
                                label="离职"
                                value="2"
                             />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="联系人关系:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="银行卡号:">
                            <el-input v-model="formModel.deptId" placeholder=""/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="员工类型:">
                            <el-select v-model="formModel.type" class="m-2" placeholder="请选择" size="large" style="width: 100%;">
                                <el-option
                                v-for="item in typeOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="员工照片:">
                            <HcUploadFile
                            ref="HcUploadFileRef"
                                :options="UploadFileOptions"
                                @progress="HcUploadFileProgress"
                                @success="HcUploadFileSuccess"
                                @change="HcUploadFileChange"
                            >
                                <el-button size="large" type="primary" hc-btn>
                                    <HcIcon name="upload-cloud-2"/>
                                    <span>上传图像</span>
                                </el-button>
                                <span class="hc-form-file-pdf" v-show="infoData?.originalName">
                                {{ infoData?.originalName }}
                                </span>
                        </HcUploadFile>
                          
                        </el-form-item>
                    </el-col>
                </el-row>
    </el-form>
    <template #action>
        <div style="text-align: center;">
            <el-button size="large" type="info" hc-btn @click="goBackClick">
                <HcIcon name="arrow-go-back"/>
                <span>取消并返回</span>
            </el-button>
            <el-button size="large" type="primary" hc-btn >
                <HcIcon name="check-double"/>
                <span>提交保存</span>
            </el-button>
        </div>
    </template>
   </HcCard>
</template>

<script setup>
import {ref, watch} from  'vue'
import {getTokenHeader} from "~src/api/request/header";
import {getObjValue} from "js-fast-way"
import {useRouter, useRoute} from 'vue-router'

//初始变量
const router = useRouter()

const formRef = ref(null)
const formModel = ref({})
const formRules = {
    
}
//返回
const goBackClick = () => {
    router.back()
}
//学历
const educationalOptions=ref([
    {
        value: '1',
        label: '小学/初中',
    },
    {
        value: '2',
        label: '高中',
    },
    {
        value: '3',
        label: '专科',
    },
    {
        value: '4',
        label: '本科',
    },
    {
        value: '5',
        label: '硕士',
    },
    {
        value: '6',
        label: '博士',
    },
])
//员工类型
const typeOptions=ref([
    {
        value: '1',
        label: '全职'
    },
    {
        value: '2',
        label: '兼职',
    },
    {
        value: '3',
        label: '劳务派遣',
    },
    {
        value: '4',
        label: '实习',
    },
])
//上传配置
const UploadFileOptions = {
    //此处设置header
    headers: getTokenHeader(),
}

// 文件上传进度
const HcUploadFileProgress = (res) => {
    console.log('文件上传进度', res)
}
const infoData=ref({})
const HcUploadFileRef=ref(null)
// 文件上传成功的回调
const HcUploadFileSuccess = (res) => {
    const { originalName } = getObjValue(res.resData)
    infoData.value.originalName = originalName
    HcUploadFileRef.value?.setModalShow(false);
   
}

// 文件全部上传成功
const HcUploadFileChange = () => {
    console.log('文件全部上传成功')
}
</script>
<style lang='scss' scoped>
</style>