<template>
|
<ProDialog
|
:title="form.isDetail ? '人员详情' : '人员信息编辑'"
|
v-model="visible"
|
@close="onDialogClose"
|
destroy-on-close
|
draggable
|
:width="900"
|
>
|
<ProForm :model="form" ref="dialogForm" label-width="120px" :is-read="form.isDetail">
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 label="姓名:" prop="name" :check-rules="[{ message: '请输入姓名' }]">
|
<ProFormText placeholder="请输入姓名" v-model.trim="form.name"></ProFormText>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 v-if="form.isDetail" label="报名时间:" prop="regiterTime">
|
<div>{{ format(form.regiterTime, 'YYYY-MM-DD HH:mm') }}</div>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="身份证号:"
|
prop="identity"
|
:check-rules="[{ message: '请输入身份证号', type: 'idCard' }]"
|
>
|
<ProFormText placeholder="请输入身份证号" v-model.trim="form.identity"></ProFormText>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 v-if="form.isDetail" label="实名时间:" prop="userRealTime">
|
<div>{{ format(form.userRealTime, 'YYYY-MM-DD HH:mm') }}</div>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="手机号:"
|
prop="contactPhoneNumber"
|
:check-rules="[{ message: '请输入手机号', type: 'phone' }]"
|
>
|
<ProFormText
|
placeholder="请输入手机号"
|
v-model.trim="form.contactPhoneNumber"
|
></ProFormText>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 v-if="form.isDetail" label="签约时间:" prop="userSignContractTime">
|
<div>{{ format(form.userSignContractTime, 'YYYY-MM-DD HH:mm') }}</div>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="性别:"
|
prop="gender"
|
required
|
:check-rules="[{ message: '请选择性别' }]"
|
>
|
<ProFormRadio
|
v-model="form.gender"
|
:value-enum="EnumUserGenderTextForPerson"
|
:buttonStyle="false"
|
></ProFormRadio>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 v-if="form.isDetail" label="电子合同:" prop="contractUrl">
|
<ProFormUpload
|
v-model:file-url="form.contractUrl"
|
:limit="1"
|
:limitFileSize="10"
|
accept="jpg/jpeg,png,pdf"
|
></ProFormUpload>
|
</ProFormItemV2>
|
</ProFormColItem>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="年龄:"
|
prop="age"
|
:check-rules="[{ message: '请输入年龄', type: 'number' }]"
|
>
|
<ProFormInputNumber
|
v-model="form.age"
|
:controls="false"
|
:min="0"
|
:max="9999"
|
placeholder="请输入年龄"
|
>
|
<template #readContent>
|
<span v-if="form.age">{{ form.age }}岁</span>
|
<span v-else></span>
|
</template>
|
</ProFormInputNumber>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormItemV2
|
label="身份证正面:"
|
prop="identityImg"
|
:check-rules="[{ message: '请上传身份证正面', type: 'upload' }]"
|
>
|
<ProFormImageUpload
|
v-model:file-url="form.identityImg"
|
:limitFileSize="10"
|
:showTip="false"
|
>
|
</ProFormImageUpload>
|
</ProFormItemV2>
|
<ProFormItemV2
|
label="身份证反面:"
|
prop="identityBackImg"
|
:check-rules="[{ message: '请上传身份证反面', type: 'upload' }]"
|
>
|
<ProFormImageUpload
|
v-model:file-url="form.identityBackImg"
|
:limitFileSize="10"
|
:showTip="false"
|
>
|
</ProFormImageUpload>
|
</ProFormItemV2>
|
</ProForm>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button v-if="form.isDetail" @click="emit('onCancel')">关闭</el-button>
|
<template v-else>
|
<el-button type="primary" @click="handleConfirm">提交</el-button>
|
<el-button @click="handleReset">重置</el-button>
|
<el-button @click="emit('onCancel')">取消</el-button>
|
</template>
|
</span>
|
</template>
|
</ProDialog>
|
</template>
|
|
<script setup lang="ts">
|
import { FormInstance } from 'element-plus';
|
import {
|
ProDialog,
|
ProForm,
|
ProFormItemV2,
|
ProFormText,
|
UploadUserFile,
|
ProFormCol,
|
ProFormColItem,
|
ProFormImageUpload,
|
ProFormRadio,
|
ProFormUpload,
|
ProFormInputNumber,
|
} from '@bole-core/components';
|
import { deepClone, format } from '@/utils';
|
import { EnumUserGender, EnumUserGenderTextForPerson } from '@/constants';
|
|
defineOptions({
|
name: 'StaffInfoDialog',
|
});
|
|
type Form = {
|
title?: string;
|
id: string;
|
name: string;
|
identity: string;
|
contactPhoneNumber: string;
|
gender: EnumUserGender;
|
age: number;
|
identityImg: UploadUserFile[];
|
identityBackImg: UploadUserFile[];
|
contractUrl: UploadUserFile[];
|
regiterTime: string;
|
userRealTime: string;
|
userSignContractTime: string;
|
isDetail: boolean;
|
};
|
|
const visible = defineModel({ type: Boolean });
|
|
const form = defineModel<Form>('form');
|
let defaultForm: Form = null;
|
|
watch(
|
visible,
|
(visible) => {
|
if (visible) {
|
defaultForm = deepClone(unref(form));
|
}
|
},
|
{
|
immediate: true,
|
}
|
);
|
|
const emit = defineEmits<{
|
(e: 'onConfirm'): void;
|
(e: 'onCancel'): void;
|
}>();
|
|
const dialogForm = ref<FormInstance>();
|
|
function onDialogClose() {
|
if (!dialogForm.value) return;
|
dialogForm.value.resetFields();
|
}
|
|
function handleConfirm() {
|
if (!dialogForm.value) return;
|
dialogForm.value.validate((valid) => {
|
if (valid) {
|
emit('onConfirm');
|
} else {
|
return;
|
}
|
});
|
}
|
|
function handleReset() {
|
form.value = { ...defaultForm };
|
}
|
</script>
|