17 changed files with 3339 additions and 790 deletions
@ -0,0 +1,380 @@ |
|||||
|
<template> |
||||
|
<el-form |
||||
|
:model="formData" |
||||
|
label-width="120px" |
||||
|
ref="formRef" |
||||
|
:rules="formRules" |
||||
|
class="base-info-form" |
||||
|
> |
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('name')" prop="name"> |
||||
|
<el-input |
||||
|
v-model="formData.name" |
||||
|
clearable |
||||
|
:placeholder="t('namePlaceholder')" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('gender')"> |
||||
|
<el-radio-group |
||||
|
v-model="formData.gender" |
||||
|
:placeholder="t('genderPlaceholder')" |
||||
|
> |
||||
|
<el-radio |
||||
|
v-for="(item, index) in genderList" |
||||
|
:key="index" |
||||
|
:label="item.value" |
||||
|
> |
||||
|
{{ item.name }} |
||||
|
</el-radio> |
||||
|
</el-radio-group> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('phone')" prop="phone"> |
||||
|
<el-input |
||||
|
v-model="formData.phone" |
||||
|
clearable |
||||
|
:placeholder="t('phonePlaceholder')" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('address')"> |
||||
|
<el-input |
||||
|
v-model="formData.address" |
||||
|
clearable |
||||
|
:placeholder="t('addressPlaceholder')" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('nativePlace')"> |
||||
|
<el-input |
||||
|
v-model="formData.native_place" |
||||
|
clearable |
||||
|
:placeholder="t('nativePlacePlaceholder')" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="头像"> |
||||
|
<upload-image v-model="formData.head_img" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('education')"> |
||||
|
<el-select |
||||
|
class="input-width" |
||||
|
v-model="formData.education" |
||||
|
clearable |
||||
|
:placeholder="t('educationPlaceholder')" |
||||
|
> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in educationList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('status')" prop="status"> |
||||
|
<el-select |
||||
|
class="input-width" |
||||
|
v-model="formData.status" |
||||
|
clearable |
||||
|
:placeholder="t('statusPlaceholder')" |
||||
|
> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in statusList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="24"> |
||||
|
<el-form-item :label="t('profile')"> |
||||
|
<el-input |
||||
|
v-model="formData.profile" |
||||
|
type="textarea" |
||||
|
rows="3" |
||||
|
clearable |
||||
|
:placeholder="t('profilePlaceholder')" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('emergencyContactPhone')"> |
||||
|
<el-input |
||||
|
v-model="formData.emergency_contact_phone" |
||||
|
clearable |
||||
|
:placeholder="t('emergencyContactPhonePlaceholder')" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('isSysUser')" prop="is_sys_user"> |
||||
|
<el-radio-group |
||||
|
v-model="formData.is_sys_user" |
||||
|
:placeholder="t('isSysUserPlaceholder')" |
||||
|
> |
||||
|
<el-radio |
||||
|
v-for="(item, index) in is_sys_userList" |
||||
|
:key="index" |
||||
|
:label="item.value" |
||||
|
> |
||||
|
{{ item.name }} |
||||
|
</el-radio> |
||||
|
</el-radio-group> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('idCardFront')"> |
||||
|
<upload-image v-model="formData.id_card_front" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item :label="t('idCardBack')"> |
||||
|
<upload-image v-model="formData.id_card_back" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="24"> |
||||
|
<el-form-item label="所属校区" prop="campus_id"> |
||||
|
<el-select |
||||
|
class="input-width" |
||||
|
v-model="formData.campus_id" |
||||
|
clearable |
||||
|
placeholder="请选择所属校区" |
||||
|
style="width: 300px;" |
||||
|
> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="item in campusList" |
||||
|
:key="item.id" |
||||
|
:label="item.campus_name" |
||||
|
:value="item.id" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
</el-form> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive, computed, watch, onMounted } from 'vue' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { t } from '@/lang' |
||||
|
import type { FormInstance } from 'element-plus' |
||||
|
import { getWithCampusList } from '@/app/api/campus_person_role' |
||||
|
|
||||
|
// Props |
||||
|
interface Props { |
||||
|
id?: string | number |
||||
|
} |
||||
|
|
||||
|
const props = withDefaults(defineProps<Props>(), { |
||||
|
id: '' |
||||
|
}) |
||||
|
|
||||
|
// 表单数据 |
||||
|
const initialFormData = { |
||||
|
name: '', |
||||
|
gender: '', |
||||
|
head_img: '', |
||||
|
phone: '', |
||||
|
address: '', |
||||
|
native_place: '', |
||||
|
education: '', |
||||
|
profile: '', |
||||
|
emergency_contact_phone: '', |
||||
|
id_card_front: '', |
||||
|
id_card_back: '', |
||||
|
status: '', |
||||
|
is_sys_user: '', |
||||
|
campus_id: '' |
||||
|
} |
||||
|
|
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
name: [{ required: true, message: t('namePlaceholder'), trigger: 'blur' }], |
||||
|
gender: [ |
||||
|
{ required: true, message: t('genderPlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
phone: [ |
||||
|
{ required: true, message: t('phonePlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
status: [ |
||||
|
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
is_sys_user: [ |
||||
|
{ required: true, message: t('isSysUserPlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
// 字典数据 |
||||
|
let genderList = ref([]) |
||||
|
let educationList = ref([]) |
||||
|
let statusList = ref([]) |
||||
|
let is_sys_userList = ref([]) |
||||
|
let campusList = ref([]) |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
const genderDictList = async () => { |
||||
|
genderList.value = await (await useDictionary('gender')).data.dictionary |
||||
|
} |
||||
|
|
||||
|
const educationDictList = async () => { |
||||
|
educationList.value = await (await useDictionary('education')).data.dictionary |
||||
|
} |
||||
|
|
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('personnel_status')).data.dictionary |
||||
|
} |
||||
|
|
||||
|
const is_sys_userDictList = async () => { |
||||
|
is_sys_userList.value = await (await useDictionary('global_true_or_false')).data.dictionary |
||||
|
} |
||||
|
|
||||
|
const getCampusList = async () => { |
||||
|
const res = await getWithCampusList({}) |
||||
|
if (res.data) { |
||||
|
campusList.value = res.data |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 初始化字典默认值 |
||||
|
watch( |
||||
|
() => genderList.value, |
||||
|
() => { |
||||
|
if (genderList.value.length > 0 && !formData.gender) { |
||||
|
formData.gender = genderList.value[0].value |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
watch( |
||||
|
() => educationList.value, |
||||
|
() => { |
||||
|
if (educationList.value.length > 0 && !formData.education) { |
||||
|
formData.education = educationList.value[0].value |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
watch( |
||||
|
() => statusList.value, |
||||
|
() => { |
||||
|
if (statusList.value.length > 0 && !formData.status) { |
||||
|
formData.status = statusList.value[0].value |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
watch( |
||||
|
() => is_sys_userList.value, |
||||
|
() => { |
||||
|
if (is_sys_userList.value.length > 0 && !formData.is_sys_user) { |
||||
|
formData.is_sys_user = is_sys_userList.value[0].value |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
// 设置表单数据 |
||||
|
const setFormData = async (data: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
if (data) { |
||||
|
Object.keys(formData).forEach((key: string) => { |
||||
|
if (data[key] != undefined) { |
||||
|
formData[key] = data[key] |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 获取表单数据 |
||||
|
const getFormData = () => { |
||||
|
return { ...formData } |
||||
|
} |
||||
|
|
||||
|
// 验证表单 |
||||
|
const validateForm = async () => { |
||||
|
if (!formRef.value) return false |
||||
|
return await formRef.value.validate() |
||||
|
} |
||||
|
|
||||
|
// 初始化 |
||||
|
onMounted(() => { |
||||
|
genderDictList() |
||||
|
educationDictList() |
||||
|
statusDictList() |
||||
|
is_sys_userDictList() |
||||
|
getCampusList() |
||||
|
}) |
||||
|
|
||||
|
// 暴露方法 |
||||
|
defineExpose({ |
||||
|
setFormData, |
||||
|
getFormData, |
||||
|
validateForm, |
||||
|
formData |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.base-info-form { |
||||
|
.input-width { |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
.el-form-item { |
||||
|
margin-bottom: 18px; |
||||
|
} |
||||
|
|
||||
|
.el-textarea { |
||||
|
:deep(.el-textarea__inner) { |
||||
|
resize: vertical; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,350 @@ |
|||||
|
<template> |
||||
|
<el-form |
||||
|
:model="formData" |
||||
|
label-width="120px" |
||||
|
ref="formRef" |
||||
|
:rules="formRules" |
||||
|
class="detail-info-form" |
||||
|
> |
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="花名" prop="name"> |
||||
|
<el-input |
||||
|
v-model="formData.name" |
||||
|
placeholder="请填写花名" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="门店" prop="store"> |
||||
|
<el-input |
||||
|
v-model="formData.store" |
||||
|
placeholder="请填写门店" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="民族" prop="ethnicity"> |
||||
|
<el-input |
||||
|
v-model="formData.ethnicity" |
||||
|
placeholder="请填写民族" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="生日日期" prop="birthday"> |
||||
|
<el-date-picker |
||||
|
v-model="formData.birthday" |
||||
|
type="date" |
||||
|
placeholder="请选择生日日期" |
||||
|
class="input-width" |
||||
|
value-format="YYYY-MM-DD" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="年龄" prop="age"> |
||||
|
<el-input |
||||
|
v-model="formData.age" |
||||
|
placeholder="请填写年龄" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="司龄" prop="tenure"> |
||||
|
<el-input |
||||
|
v-model="formData.tenure" |
||||
|
placeholder="请填写司龄" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="转正时间" prop="regular_date"> |
||||
|
<el-date-picker |
||||
|
v-model="formData.regular_date" |
||||
|
type="date" |
||||
|
placeholder="请选择转正时间" |
||||
|
class="input-width" |
||||
|
value-format="YYYY-MM-DD" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="是否转正" prop="is_regular"> |
||||
|
<el-select |
||||
|
v-model="formData.is_regular" |
||||
|
placeholder="请选择是否转正" |
||||
|
class="input-width" |
||||
|
clearable |
||||
|
> |
||||
|
<el-option label="是" value="是" /> |
||||
|
<el-option label="否" value="否" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="政治面貌" prop="politics"> |
||||
|
<el-input |
||||
|
v-model="formData.politics" |
||||
|
placeholder="请填写政治面貌" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="毕业院校" prop="university"> |
||||
|
<el-input |
||||
|
v-model="formData.university" |
||||
|
placeholder="请填写毕业院校" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="专业" prop="major"> |
||||
|
<el-input |
||||
|
v-model="formData.major" |
||||
|
placeholder="请填写专业" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="毕业时间" prop="graduation_date"> |
||||
|
<el-date-picker |
||||
|
v-model="formData.graduation_date" |
||||
|
type="date" |
||||
|
placeholder="请选择毕业时间" |
||||
|
class="input-width" |
||||
|
value-format="YYYY-MM-DD" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="户籍所在地" prop="household_place"> |
||||
|
<el-input |
||||
|
v-model="formData.household_place" |
||||
|
placeholder="请填写户籍所在地" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="户籍类型" prop="household_type"> |
||||
|
<el-input |
||||
|
v-model="formData.household_type" |
||||
|
placeholder="请填写户籍类型" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="婚否" prop="marital_status"> |
||||
|
<el-select |
||||
|
v-model="formData.marital_status" |
||||
|
placeholder="请选择婚否" |
||||
|
class="input-width" |
||||
|
clearable |
||||
|
> |
||||
|
<el-option label="已婚" value="已婚" /> |
||||
|
<el-option label="未婚" value="未婚" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="银行卡号" prop="bank_card"> |
||||
|
<el-input |
||||
|
v-model="formData.bank_card" |
||||
|
placeholder="请填写银行卡号" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="开户行" prop="bank_name"> |
||||
|
<el-input |
||||
|
v-model="formData.bank_name" |
||||
|
placeholder="请填写开户行" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="合同到期时间" prop="contract_expire"> |
||||
|
<el-date-picker |
||||
|
v-model="formData.contract_expire" |
||||
|
type="date" |
||||
|
placeholder="请选择合同到期时间" |
||||
|
class="input-width" |
||||
|
value-format="YYYY-MM-DD" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="是否复聘" prop="is_rehired"> |
||||
|
<el-select |
||||
|
v-model="formData.is_rehired" |
||||
|
placeholder="请选择是否复聘" |
||||
|
class="input-width" |
||||
|
clearable |
||||
|
> |
||||
|
<el-option label="是" value="是" /> |
||||
|
<el-option label="否" value="否" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="备注" prop="remark"> |
||||
|
<el-input |
||||
|
v-model="formData.remark" |
||||
|
placeholder="请填写备注" |
||||
|
class="input-width" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
</el-form> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive, computed } from 'vue' |
||||
|
import type { FormInstance } from 'element-plus' |
||||
|
|
||||
|
// Props |
||||
|
interface Props { |
||||
|
id?: string | number |
||||
|
} |
||||
|
|
||||
|
const props = withDefaults(defineProps<Props>(), { |
||||
|
id: '' |
||||
|
}) |
||||
|
|
||||
|
// 表单数据 |
||||
|
const initialFormData = { |
||||
|
name: '', |
||||
|
store: '', |
||||
|
ethnicity: '', |
||||
|
birthday: '', |
||||
|
age: '', |
||||
|
tenure: '', |
||||
|
regular_date: '', |
||||
|
is_regular: '', |
||||
|
politics: '', |
||||
|
university: '', |
||||
|
education: '', |
||||
|
major: '', |
||||
|
graduation_date: '', |
||||
|
native_place: '', |
||||
|
household_place: '', |
||||
|
household_type: '', |
||||
|
household_address: '', |
||||
|
current_address: '', |
||||
|
emergency_contact: '', |
||||
|
emergency_phone: '', |
||||
|
marital_status: '', |
||||
|
bank_card: '', |
||||
|
bank_name: '', |
||||
|
contract_expire: '', |
||||
|
is_rehired: '', |
||||
|
remark: '' |
||||
|
} |
||||
|
|
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
// 这里可以添加需要的验证规则 |
||||
|
name: [{ required: false, message: '请填写花名', trigger: 'blur' }], |
||||
|
store: [{ required: false, message: '请填写门店', trigger: 'blur' }], |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
// 设置表单数据 |
||||
|
const setFormData = async (data: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
if (data) { |
||||
|
Object.keys(formData).forEach((key: string) => { |
||||
|
if (data[key] != undefined) { |
||||
|
formData[key] = data[key] |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 获取表单数据 |
||||
|
const getFormData = () => { |
||||
|
return { ...formData } |
||||
|
} |
||||
|
|
||||
|
// 验证表单 |
||||
|
const validateForm = async () => { |
||||
|
if (!formRef.value) return false |
||||
|
return await formRef.value.validate() |
||||
|
} |
||||
|
|
||||
|
// 暴露方法 |
||||
|
defineExpose({ |
||||
|
setFormData, |
||||
|
getFormData, |
||||
|
validateForm, |
||||
|
formData |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.detail-info-form { |
||||
|
.input-width { |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
.el-form-item { |
||||
|
margin-bottom: 18px; |
||||
|
} |
||||
|
|
||||
|
.el-date-picker { |
||||
|
width: 100%; |
||||
|
|
||||
|
:deep(.el-input__wrapper) { |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
:deep(.el-input) { |
||||
|
width: 100%; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
||||
@ -1,656 +1,274 @@ |
|||||
<template> |
<template> |
||||
<el-dialog v-model="showDialog" :title="formData.id ? t('updatePersonnel') : t('addPersonnel')" width="50%" |
<el-dialog |
||||
class="diy-dialog-wrap" :destroy-on-close="true"> |
v-model="showDialog" |
||||
|
:title="formData.id ? t('updatePersonnel') : t('addPersonnel')" |
||||
<el-tabs v-model="activeTab" class="tab-pane-half"> |
width="70%" |
||||
|
class="personnel-edit-dialog" |
||||
|
:destroy-on-close="true" |
||||
|
:close-on-click-modal="false" |
||||
|
> |
||||
|
|
||||
|
<el-tabs v-model="activeTab" class="personnel-tabs"> |
||||
<!-- Tab 1: 基本信息 --> |
<!-- Tab 1: 基本信息 --> |
||||
<el-tab-pane label="基本信息" name="base"> |
<el-tab-pane label="基本信息" name="base"> |
||||
|
<div class="tab-content"> |
||||
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form"> |
<BaseInfoForm |
||||
|
ref="baseInfoFormRef" |
||||
<el-form-item :label="t('name')" prop="name"> |
:id="formData.id" |
||||
<el-input v-model="formData.name" clearable :placeholder="t('namePlaceholder')" |
/> |
||||
class="input-width" /> |
</div> |
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('gender')"> |
|
||||
<el-radio-group v-model="formData.gender" :placeholder="t('genderPlaceholder')"> |
|
||||
<el-radio v-for="(item, index) in genderList" :key="index" :label="item.value"> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('phone')" prop="phone"> |
|
||||
<el-input v-model="formData.phone" clearable :placeholder="t('phonePlaceholder')" |
|
||||
class="input-width" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('address')"> |
|
||||
<el-input v-model="formData.address" clearable :placeholder="t('addressPlaceholder')" |
|
||||
class="input-width" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('nativePlace')"> |
|
||||
<el-input v-model="formData.native_place" clearable :placeholder="t('nativePlacePlaceholder')" |
|
||||
class="input-width" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item label="头像"> |
|
||||
<upload-image v-model="formData.head_img" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('education')"> |
|
||||
<el-select class="input-width" v-model="formData.education" clearable |
|
||||
:placeholder="t('educationPlaceholder')"> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option v-for="(item, index) in educationList" :key="index" :label="item.name" |
|
||||
:value="item.value" /> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('profile')"> |
|
||||
<el-input v-model="formData.profile" type="textarea" rows="4" clearable |
|
||||
:placeholder="t('profilePlaceholder')" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('emergencyContactPhone')"> |
|
||||
<el-input v-model="formData.emergency_contact_phone" clearable |
|
||||
:placeholder="t('emergencyContactPhonePlaceholder')" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('idCardFront')"> |
|
||||
<upload-image v-model="formData.id_card_front" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('idCardBack')"> |
|
||||
<upload-image v-model="formData.id_card_back" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-select class="input-width" v-model="formData.status" clearable |
|
||||
:placeholder="t('statusPlaceholder')"> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option v-for="(item, index) in statusList" :key="index" :label="item.name" |
|
||||
:value="item.value" /> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('isSysUser')" prop="is_sys_user"> |
|
||||
<el-radio-group v-model="formData.is_sys_user" :placeholder="t('isSysUserPlaceholder')"> |
|
||||
<el-radio v-for="(item, index) in is_sys_userList" :key="index" :label="item.value"> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item label="所属校区" prop="campus_id"> |
|
||||
<el-select class="input-width" v-model="formData.campus_id" clearable placeholder="请选择所属校区"> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option v-for="item in campusList" :key="item.id" :label="item.campus_name" :value="item.id" /> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
</el-form> |
|
||||
|
|
||||
</el-tab-pane> |
</el-tab-pane> |
||||
|
|
||||
|
<!-- Tab 2: 详情信息 --> |
||||
<el-tab-pane label="详情信息" name="info"> |
<el-tab-pane label="详情信息" name="info"> |
||||
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form"> |
<div class="tab-content"> |
||||
|
<DetailInfoForm |
||||
<el-row :gutter="20"> |
ref="detailInfoFormRef" |
||||
<el-col :span="12"> |
:id="formData.id" |
||||
<el-form-item label="花名" prop="info.name"> |
/> |
||||
<el-input v-model="formData.info.name" placeholder="请填写花名" class="input-width" /> |
</div> |
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="门店" prop="info.store"> |
|
||||
<el-input v-model="formData.info.store" placeholder="请填写门店" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="民族" prop="info.ethnicity"> |
|
||||
<el-input v-model="formData.info.ethnicity" placeholder="请填写民族" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-form-item label="生日日期" prop="info.birthday"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.info.birthday" |
|
||||
type="date" |
|
||||
placeholder="请选择生日日期" |
|
||||
class="input-width" |
|
||||
value-format="YYYY-MM-DD" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="年龄" prop="info.age"> |
|
||||
<el-input v-model="formData.info.age" placeholder="请填写年龄" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="司龄" prop="info.tenure"> |
|
||||
<el-input v-model="formData.info.tenure" placeholder="请填写司龄" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
|
|
||||
<el-form-item label="转正时间" prop="info.regular_date"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.info.regular_date" |
|
||||
type="date" |
|
||||
placeholder="请选择转正时间" |
|
||||
class="input-width" |
|
||||
value-format="YYYY-MM-DD" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
|
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="是否转正" prop="info.is_regular"> |
|
||||
<el-select |
|
||||
v-model="formData.info.is_regular" |
|
||||
placeholder="请选择是否转正" |
|
||||
class="input-width" |
|
||||
clearable |
|
||||
> |
|
||||
<el-option label="是" value="是" /> |
|
||||
<el-option label="否" value="否" /> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="政治面貌" prop="info.politics"> |
|
||||
<el-input v-model="formData.info.politics" placeholder="请填写政治面貌" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="毕业院校" prop="info.university"> |
|
||||
<el-input v-model="formData.info.university" placeholder="请填写毕业院校" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<!-- <el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="学历" prop="info.education"> |
|
||||
<el-input v-model="formData.info.education" placeholder="请填写学历" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="专业" prop="info.major"> |
|
||||
<el-input v-model="formData.info.major" placeholder="请填写专业" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> --> |
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="专业" prop="info.major"> |
|
||||
<el-input v-model="formData.info.major" placeholder="请填写专业" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="毕业时间" prop="info.graduation_date"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.info.graduation_date" |
|
||||
type="date" |
|
||||
placeholder="请选择毕业时间" |
|
||||
class="input-width" |
|
||||
value-format="YYYY-MM-DD" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
</el-col> |
|
||||
|
|
||||
|
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
|
|
||||
|
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="户籍所在地" prop="info.household_place"> |
|
||||
<el-input v-model="formData.info.household_place" placeholder="请填写户籍所在地" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="户籍类型" prop="info.household_type"> |
|
||||
<el-input v-model="formData.info.household_type" placeholder="请填写户籍类型" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<!-- <el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="户籍地址" prop="info.household_address"> |
|
||||
<el-input v-model="formData.info.household_address" placeholder="请填写户籍地址" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="现居地址" prop="info.current_address"> |
|
||||
<el-input v-model="formData.info.current_address" placeholder="请填写现居地址" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> --> |
|
||||
|
|
||||
<!-- |
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="紧急联系人" prop="info.emergency_contact"> |
|
||||
<el-input v-model="formData.info.emergency_contact" placeholder="请填写紧急联系人" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="紧急联系人联系电话" prop="info.emergency_phone"> |
|
||||
<el-input v-model="formData.info.emergency_phone" placeholder="请填写紧急联系人联系电话" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> --> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="婚否" prop="info.marital_status"> |
|
||||
<el-select |
|
||||
v-model="formData.info.marital_status" |
|
||||
placeholder="请选择婚否" |
|
||||
class="input-width" |
|
||||
clearable |
|
||||
> |
|
||||
<el-option label="已婚" value="已婚" /> |
|
||||
<el-option label="未婚" value="未婚" /> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="银行卡号" prop="info.bank_card"> |
|
||||
<el-input v-model="formData.info.bank_card" placeholder="请填写银行卡号" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="开户行" prop="info.bank_name"> |
|
||||
<el-input v-model="formData.info.bank_name" placeholder="请填写开户行" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="合同到期时间" prop="info.contract_expire"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.info.contract_expire" |
|
||||
type="date" |
|
||||
placeholder="请选择合同到期时间" |
|
||||
class="input-width" |
|
||||
value-format="YYYY-MM-DD" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
<el-row :gutter="20"> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="是否复聘" prop="info.is_rehired"> |
|
||||
<el-select |
|
||||
v-model="formData.info.is_rehired" |
|
||||
placeholder="请选择是否复聘" |
|
||||
class="input-width" |
|
||||
clearable |
|
||||
> |
|
||||
<el-option label="是" value="是" /> |
|
||||
<el-option label="否" value="否" /> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
|
|
||||
</el-col> |
|
||||
|
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="备注" prop="info.remark"> |
|
||||
<el-input v-model="formData.info.remark" placeholder="请填写备注" class="input-width" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
|
|
||||
</el-row> |
|
||||
|
|
||||
|
|
||||
|
|
||||
</el-form> |
|
||||
</el-tab-pane> |
</el-tab-pane> |
||||
|
|
||||
</el-tabs> |
</el-tabs> |
||||
<template #footer> |
<template #footer> |
||||
<span class="dialog-footer"> |
<span class="dialog-footer"> |
||||
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
||||
<el-button type="primary" :loading="loading" |
<el-button type="primary" :loading="loading" |
||||
@click="confirm(formRef)">{{ t('confirm') }}</el-button> |
@click="confirm">{{ t('confirm') }}</el-button> |
||||
</span> |
</span> |
||||
</template> |
</template> |
||||
</el-dialog> |
</el-dialog> |
||||
</template> |
</template> |
||||
|
|
||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||
import { ref, reactive, computed, watch, onMounted } from 'vue' |
import { ref, reactive } from 'vue' |
||||
import { useDictionary } from '@/app/api/dict' |
import { t } from '@/lang' |
||||
import { t } from '@/lang' |
import { |
||||
import type { FormInstance } from 'element-plus' |
addPersonnel, |
||||
import { |
editPersonnel, |
||||
addPersonnel, |
getPersonnelInfo, |
||||
editPersonnel, |
} from '@/app/api/personnel' |
||||
getPersonnelInfo, |
import BaseInfoForm from './BaseInfoForm.vue' |
||||
} from '@/app/api/personnel' |
import DetailInfoForm from './DetailInfoForm.vue' |
||||
import { getWithCampusList } from '@/app/api/campus_person_role' |
|
||||
|
let showDialog = ref(false) |
||||
let showDialog = ref(false) |
const loading = ref(false) |
||||
const loading = ref(false) |
const activeTab = ref('base') |
||||
const activeTab = ref('base') |
|
||||
/** |
// 表单组件引用 |
||||
* 表单数据 |
const baseInfoFormRef = ref() |
||||
*/ |
const detailInfoFormRef = ref() |
||||
const initialFormData = { |
|
||||
id: '', |
/** |
||||
name: '', |
* 表单数据 |
||||
gender: '', |
*/ |
||||
head_img: '', |
const initialFormData = { |
||||
phone: '', |
id: '', |
||||
address: '', |
info: {} |
||||
native_place: '', |
} |
||||
education: '', |
|
||||
profile: '', |
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
emergency_contact_phone: '', |
|
||||
id_card_front: '', |
const emit = defineEmits(['complete']) |
||||
id_card_back: '', |
|
||||
status: '', |
/** |
||||
is_sys_user: '', |
* 确认 |
||||
campus_id: '', |
*/ |
||||
info:{ |
const confirm = async () => { |
||||
name:'', |
if (loading.value) return |
||||
store:'', |
|
||||
ethnicity:'', |
// 获取两个表单组件的数据 |
||||
birthday:'', |
const baseInfoValid = await baseInfoFormRef.value?.validateForm() |
||||
age:'', |
const detailInfoValid = await detailInfoFormRef.value?.validateForm() |
||||
tenure:'', |
|
||||
regular_date:'', |
if (!baseInfoValid) { |
||||
is_regular:'', |
activeTab.value = 'base' |
||||
politics:'', |
return |
||||
university:'', |
|
||||
education:'', |
|
||||
major:'', |
|
||||
graduation_date:'', |
|
||||
native_place:'', |
|
||||
household_place:'', |
|
||||
household_type:'', |
|
||||
household_address:'', |
|
||||
current_address:'', |
|
||||
emergency_contact:'', |
|
||||
emergency_phone:'', |
|
||||
marital_status:'', |
|
||||
bank_card:'', |
|
||||
bank_name:'', |
|
||||
contract_expire:'', |
|
||||
is_rehired:'', |
|
||||
remark:'' |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
const formData : Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
name: [{ required: true, message: t('namePlaceholder'), trigger: 'blur' }], |
|
||||
gender: [ |
|
||||
{ required: true, message: t('genderPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
phone: [ |
|
||||
{ required: true, message: t('phonePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
address: [ |
|
||||
{ required: true, message: t('addressPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
native_place: [ |
|
||||
{ required: true, message: t('nativePlacePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
education: [ |
|
||||
{ required: true, message: t('educationPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
profile: [ |
|
||||
{ required: true, message: t('profilePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
emergency_contact_phone: [ |
|
||||
{ |
|
||||
required: true, |
|
||||
message: t('emergencyContactPhonePlaceholder'), |
|
||||
trigger: 'blur', |
|
||||
}, |
|
||||
], |
|
||||
id_card_front: [ |
|
||||
{ required: true, message: t('idCardFrontPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
id_card_back: [ |
|
||||
{ required: true, message: t('idCardBackPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
status: [ |
|
||||
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
is_sys_user: [ |
|
||||
{ required: true, message: t('isSysUserPlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
} |
|
||||
}) |
|
||||
|
|
||||
const emit = defineEmits(['complete']) |
|
||||
|
|
||||
/** |
|
||||
* 确认 |
|
||||
* @param formEl |
|
||||
*/ |
|
||||
const confirm = async (formEl : FormInstance | undefined) => { |
|
||||
if (loading.value || !formEl) return |
|
||||
let save = formData.id ? editPersonnel : addPersonnel |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
|
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
} |
||||
|
|
||||
// 获取字典数据 |
loading.value = true |
||||
let genderList = ref([]) |
|
||||
const genderDictList = async () => { |
try { |
||||
genderList.value = await (await useDictionary('gender')).data.dictionary |
// 合并两个表单的数据 |
||||
} |
const baseData = baseInfoFormRef.value?.getFormData() || {} |
||||
genderDictList() |
const detailData = detailInfoFormRef.value?.getFormData() || {} |
||||
watch( |
|
||||
() => genderList.value, |
const submitData = { |
||||
() => { |
...baseData, |
||||
formData.gender = genderList.value[0].value |
...formData, |
||||
} |
info: detailData |
||||
) |
|
||||
let educationList = ref([]) |
|
||||
const educationDictList = async () => { |
|
||||
educationList.value = await (await useDictionary('education')).data.dictionary |
|
||||
} |
|
||||
educationDictList() |
|
||||
watch( |
|
||||
() => educationList.value, |
|
||||
() => { |
|
||||
formData.education = educationList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('personnel_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let is_sys_userList = ref([]) |
|
||||
const is_sys_userDictList = async () => { |
|
||||
is_sys_userList.value = await ( |
|
||||
await useDictionary('global_true_or_false') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
is_sys_userDictList() |
|
||||
watch( |
|
||||
() => is_sys_userList.value, |
|
||||
() => { |
|
||||
formData.is_sys_user = is_sys_userList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
// 获取校区列表 |
|
||||
let campusList = ref([]) |
|
||||
const getCampusList = async () => { |
|
||||
const res = await getWithCampusList({}) |
|
||||
if (res.data) { |
|
||||
campusList.value = res.data |
|
||||
} |
} |
||||
|
|
||||
|
const save = formData.id ? editPersonnel : addPersonnel |
||||
|
|
||||
|
await save(submitData) |
||||
|
|
||||
|
loading.value = false |
||||
|
showDialog.value = false |
||||
|
emit('complete') |
||||
|
} catch (err) { |
||||
|
loading.value = false |
||||
} |
} |
||||
|
} |
||||
|
|
||||
onMounted(() => { |
/** |
||||
getCampusList() |
* 设置表单数据 |
||||
}) |
*/ |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
|
||||
const setFormData = async (row : any = null) => { |
try { |
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
if (row) { |
||||
const data = await (await getPersonnelInfo(row.id)).data |
const data = await (await getPersonnelInfo(row.id)).data |
||||
if (data) |
if (data) { |
||||
Object.keys(formData).forEach((key : string) => { |
formData.id = data.id |
||||
if (data[key] != undefined) formData[key] = data[key] |
// 设置基本信息表单数据 |
||||
}) |
await baseInfoFormRef.value?.setFormData(data) |
||||
|
// 设置详情信息表单数据 |
||||
|
await detailInfoFormRef.value?.setFormData(data.info || {}) |
||||
|
} |
||||
|
} else { |
||||
|
// 新增时重置表单 |
||||
|
await baseInfoFormRef.value?.setFormData() |
||||
|
await detailInfoFormRef.value?.setFormData() |
||||
} |
} |
||||
|
} catch (error) { |
||||
|
console.error('设置表单数据失败:', error) |
||||
|
} finally { |
||||
loading.value = false |
loading.value = false |
||||
} |
} |
||||
|
} |
||||
|
|
||||
// 验证手机号格式 |
defineExpose({ |
||||
const mobileVerify = (rule : any, value : any, callback : any) => { |
showDialog, |
||||
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
setFormData, |
||||
callback(new Error(t('generateMobile'))) |
}) |
||||
} else { |
</script> |
||||
callback() |
|
||||
} |
<style lang="scss" scoped> |
||||
|
.personnel-edit-dialog { |
||||
|
:deep(.el-dialog) { |
||||
|
border-radius: 8px; |
||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); |
||||
} |
} |
||||
|
|
||||
// 验证身份证号 |
:deep(.el-dialog__header) { |
||||
const idCardVerify = (rule : any, value : any, callback : any) => { |
padding: 20px 24px 16px; |
||||
if ( |
border-bottom: 1px solid #f0f0f0; |
||||
value && |
background: #fafafa; |
||||
!/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test( |
border-radius: 8px 8px 0 0; |
||||
value |
|
||||
) |
.el-dialog__title { |
||||
) { |
font-size: 18px; |
||||
callback(new Error(t('generateIdCard'))) |
font-weight: 600; |
||||
} else { |
color: #1f2937; |
||||
callback() |
|
||||
} |
} |
||||
} |
} |
||||
|
|
||||
// 验证邮箱号 |
:deep(.el-dialog__body) { |
||||
const emailVerify = (rule : any, value : any, callback : any) => { |
padding: 24px; |
||||
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
max-height: 70vh; |
||||
callback(new Error(t('generateEmail'))) |
overflow-y: auto; |
||||
} else { |
|
||||
callback() |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
// 验证请输入整数 |
:deep(.el-dialog__footer) { |
||||
const numberVerify = (rule : any, value : any, callback : any) => { |
padding: 16px 24px 20px; |
||||
if (!Number.isInteger(value)) { |
border-top: 1px solid #f0f0f0; |
||||
callback(new Error(t('generateNumber'))) |
background: #fafafa; |
||||
} else { |
border-radius: 0 0 8px 8px; |
||||
callback() |
} |
||||
|
} |
||||
|
|
||||
|
.personnel-tabs { |
||||
|
:deep(.el-tabs__header) { |
||||
|
margin-bottom: 24px; |
||||
|
border-bottom: 2px solid #e5e7eb; |
||||
|
|
||||
|
.el-tabs__nav-wrap { |
||||
|
&::after { |
||||
|
display: none; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.el-tabs__item { |
||||
|
padding: 12px 24px; |
||||
|
font-size: 15px; |
||||
|
font-weight: 500; |
||||
|
color: #6b7280; |
||||
|
border-bottom: none; |
||||
|
transition: all 0.3s ease; |
||||
|
|
||||
|
&:hover { |
||||
|
color: #3b82f6; |
||||
|
} |
||||
|
|
||||
|
&.is-active { |
||||
|
color: #3b82f6; |
||||
|
background: #eff6ff; |
||||
|
border: 1px solid #3b82f6; |
||||
|
border-bottom: 1px solid #eff6ff; |
||||
|
border-radius: 8px 8px 0 0; |
||||
|
position: relative; |
||||
|
top: 2px; |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
defineExpose({ |
.tab-content { |
||||
showDialog, |
padding: 20px; |
||||
setFormData, |
background: #ffffff; |
||||
}) |
border: 1px solid #e5e7eb; |
||||
</script> |
border-radius: 8px; |
||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.dialog-footer { |
||||
|
.el-button { |
||||
|
padding: 10px 24px; |
||||
|
font-size: 14px; |
||||
|
font-weight: 500; |
||||
|
border-radius: 6px; |
||||
|
transition: all 0.3s ease; |
||||
|
|
||||
|
&:hover { |
||||
|
transform: translateY(-1px); |
||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
<style lang="scss" scoped></style> |
|
||||
<style lang="scss"> |
<style lang="scss"> |
||||
.diy-dialog-wrap .el-form-item__label { |
.personnel-edit-dialog .el-form-item__label { |
||||
height: auto !important; |
height: auto !important; |
||||
|
line-height: 1.6; |
||||
|
} |
||||
|
|
||||
|
.personnel-edit-dialog .el-tabs__content { |
||||
|
overflow: visible; |
||||
|
} |
||||
|
|
||||
|
.personnel-edit-dialog .el-dialog__body { |
||||
|
padding: 24px; |
||||
|
} |
||||
|
|
||||
|
// 美化滚动条 |
||||
|
.personnel-edit-dialog .el-dialog__body::-webkit-scrollbar { |
||||
|
width: 6px; |
||||
|
} |
||||
|
|
||||
|
.personnel-edit-dialog .el-dialog__body::-webkit-scrollbar-track { |
||||
|
background: #f1f1f1; |
||||
|
border-radius: 3px; |
||||
|
} |
||||
|
|
||||
|
.personnel-edit-dialog .el-dialog__body::-webkit-scrollbar-thumb { |
||||
|
background: #c1c1c1; |
||||
|
border-radius: 3px; |
||||
|
|
||||
|
&:hover { |
||||
|
background: #a8a8a8; |
||||
} |
} |
||||
|
} |
||||
</style> |
</style> |
||||
File diff suppressed because it is too large
Loading…
Reference in new issue