修改人员列表和档案
This commit is contained in:
parent
7c382a14c5
commit
5f1ac04e0f
@ -12,6 +12,12 @@
|
|||||||
<el-form-item label="姓名" prop="name">
|
<el-form-item label="姓名" prop="name">
|
||||||
<el-input v-model="formData.name" placeholder="请输入姓名" />
|
<el-input v-model="formData.name" placeholder="请输入姓名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="性别" prop="gender">
|
||||||
|
<el-select v-model="formData.gender" placeholder="请选择性别">
|
||||||
|
<el-option label="男" :value="1" />
|
||||||
|
<el-option label="女" :value="2" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="身份证号" prop="idcard">
|
<el-form-item label="身份证号" prop="idcard">
|
||||||
<el-input v-model="formData.idcard" placeholder="请输入身份证号" />
|
<el-input v-model="formData.idcard" placeholder="请输入身份证号" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -82,6 +88,7 @@ const formData = ref({
|
|||||||
password: undefined,
|
password: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
address: '',
|
address: '',
|
||||||
|
gender: undefined,
|
||||||
detailAddress: '',
|
detailAddress: '',
|
||||||
orgid: undefined,
|
orgid: undefined,
|
||||||
orgname: undefined,
|
orgname: undefined,
|
||||||
@ -100,6 +107,15 @@ const formRules = reactive({
|
|||||||
name: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
|
||||||
orgid: [{ required: true, message: '机构ID不能为空', trigger: 'blur' }],
|
orgid: [{ required: true, message: '机构ID不能为空', trigger: 'blur' }],
|
||||||
orgname: [{ required: true, message: '机构名称不能为空', trigger: 'blur' }],
|
orgname: [{ required: true, message: '机构名称不能为空', trigger: 'blur' }],
|
||||||
|
gender: [{ required: true, message: '性别不能为空', trigger: 'blur' }],
|
||||||
|
idcard: [
|
||||||
|
{ required: true, message: '身份证号不能为空', trigger: 'blur' },
|
||||||
|
{
|
||||||
|
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
|
||||||
|
message: '请输入正确的身份证号码',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
@ -138,6 +154,7 @@ watch(() => formData.value.detailAddress, (newValue) => {
|
|||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number, userProfile?: any) => {
|
const open = async (type: string, id?: number, userProfile?: any) => {
|
||||||
|
console.log(userProfile)
|
||||||
userdata.value = userProfile
|
userdata.value = userProfile
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = t('action.' + type)
|
dialogTitle.value = t('action.' + type)
|
||||||
@ -215,6 +232,7 @@ const resetForm = () => {
|
|||||||
password: undefined,
|
password: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
address: '',
|
address: '',
|
||||||
|
gender: undefined,
|
||||||
detailAddress: '',
|
detailAddress: '',
|
||||||
orgid: undefined,
|
orgid: undefined,
|
||||||
orgname: undefined,
|
orgname: undefined,
|
||||||
|
@ -68,6 +68,13 @@
|
|||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
width="100"
|
width="100"
|
||||||
/>
|
/>
|
||||||
|
<el-table-column label="性别" align="center" prop="gender" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag :type="scope.row.gender === 1 ? 'success' : 'info'">
|
||||||
|
{{ scope.row.gender === 1 ? '男' : '女' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="手机号码" align="center" prop="phone" width="120" />
|
<el-table-column label="手机号码" align="center" prop="phone" width="120" />
|
||||||
<el-table-column label="身份证号" align="center" prop="idcard" width="180" />
|
<el-table-column label="身份证号" align="center" prop="idcard" width="180" />
|
||||||
<el-table-column label="机构ID" align="center" prop="orgid" width="80" />
|
<el-table-column label="机构ID" align="center" prop="orgid" width="80" />
|
||||||
@ -219,7 +226,7 @@ const openForm = (type: string, id?: number, name?: string) => {
|
|||||||
if (type === 'bind') {
|
if (type === 'bind') {
|
||||||
deviceBindRef.value?.open(id, name)
|
deviceBindRef.value?.open(id, name)
|
||||||
} else {
|
} else {
|
||||||
formRef.value?.open(type, id)
|
formRef.value?.open(type, id,userProfile.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||||
<el-form
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading">
|
||||||
ref="formRef"
|
|
||||||
:model="formData"
|
|
||||||
:rules="formRules"
|
|
||||||
label-width="100px"
|
|
||||||
v-loading="formLoading"
|
|
||||||
>
|
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="姓名" prop="name">
|
<el-form-item label="姓名" prop="name">
|
||||||
@ -29,13 +23,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="户籍住址" prop="address">
|
<el-form-item label="户籍住址" prop="address">
|
||||||
<el-cascader
|
<el-cascader
|
||||||
v-model="selectedOptions"
|
v-model="selectedOptions" :options="options" @change="handleAddressChange"
|
||||||
:options="options"
|
placeholder="请选择省/市/区" clearable class="w-[450px]" />
|
||||||
@change="handleAddressChange"
|
|
||||||
placeholder="请选择省/市/区"
|
|
||||||
clearable
|
|
||||||
class="w-[450px]"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="血型" prop="bloodtype">
|
<el-form-item label="血型" prop="bloodtype">
|
||||||
<el-select v-model="formData.bloodtype" placeholder="请选择血型">
|
<el-select v-model="formData.bloodtype" placeholder="请选择血型">
|
||||||
@ -153,8 +142,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PersonArchiveApi, PersonArchiveVO } from '@/api/personarchive'
|
import { PersonArchiveApi, PersonArchiveVO } from '@/api/personarchive'
|
||||||
import {provinceAndCityData,
|
import {
|
||||||
pcTextArr,
|
provinceAndCityData,
|
||||||
|
pcTextArr,
|
||||||
regionData,
|
regionData,
|
||||||
pcaTextArr,
|
pcaTextArr,
|
||||||
codeToText,
|
codeToText,
|
||||||
@ -277,6 +267,42 @@ watch(() => formData.value.address, (newValue) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份证号计算年龄
|
||||||
|
* @param idcard 18位身份证号
|
||||||
|
* @returns 计算出的年龄
|
||||||
|
*/
|
||||||
|
const calculateAgeFromIdcard = (idcard: string): number | undefined => {
|
||||||
|
if (!idcard || idcard.length !== 18) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从身份证号中提取出生日期
|
||||||
|
const year = idcard.substring(6, 10)
|
||||||
|
const month = idcard.substring(10, 12)
|
||||||
|
const day = idcard.substring(12, 14)
|
||||||
|
const birthDate = new Date(`${year}-${month}-${day}`)
|
||||||
|
|
||||||
|
// 计算年龄
|
||||||
|
const today = new Date()
|
||||||
|
let age = today.getFullYear() - birthDate.getFullYear()
|
||||||
|
const monthDiff = today.getMonth() - birthDate.getMonth()
|
||||||
|
|
||||||
|
// 如果还没过生日,年龄减1
|
||||||
|
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
||||||
|
age--
|
||||||
|
}
|
||||||
|
|
||||||
|
return age
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加身份证号变化监听
|
||||||
|
watch(() => formData.value.idcard, (newIdcard) => {
|
||||||
|
if (newIdcard) {
|
||||||
|
formData.value.age = calculateAgeFromIdcard(newIdcard)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number, userProfile?: any, currentPerson?: any) => {
|
const open = async (type: string, id?: number, userProfile?: any, currentPerson?: any) => {
|
||||||
userData.value = userProfile
|
userData.value = userProfile
|
||||||
@ -296,7 +322,7 @@ const open = async (type: string, id?: number, userProfile?: any, currentPerson?
|
|||||||
// 获取省市区编码
|
// 获取省市区编码
|
||||||
const provinceCode = Object.keys(codeToText).find(key => codeToText[key] === addressParts[0])
|
const provinceCode = Object.keys(codeToText).find(key => codeToText[key] === addressParts[0])
|
||||||
let cityCode = Object.keys(codeToText).find(key => codeToText[key] === addressParts[1])
|
let cityCode = Object.keys(codeToText).find(key => codeToText[key] === addressParts[1])
|
||||||
if(provinceCode == '12'){
|
if (provinceCode == '12') {
|
||||||
cityCode = '1201'
|
cityCode = '1201'
|
||||||
}
|
}
|
||||||
const areaCode = Object.keys(codeToText).find(key => codeToText[key] === addressParts[2])
|
const areaCode = Object.keys(codeToText).find(key => codeToText[key] === addressParts[2])
|
||||||
@ -305,6 +331,10 @@ const open = async (type: string, id?: number, userProfile?: any, currentPerson?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 如果有身份证号,触发一次年龄计算
|
||||||
|
if (formData.value.idcard) {
|
||||||
|
formData.value.age = calculateAgeFromIdcard(formData.value.idcard)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
@ -347,7 +377,12 @@ const open = async (type: string, id?: number, userProfile?: any, currentPerson?
|
|||||||
createby: undefined,
|
createby: undefined,
|
||||||
updateby: undefined
|
updateby: undefined
|
||||||
}
|
}
|
||||||
|
// 如果有身份证号,触发一次年龄计算
|
||||||
|
if (newFormData.idcard) {
|
||||||
|
newFormData.age = calculateAgeFromIdcard(newFormData.idcard)
|
||||||
|
}
|
||||||
formData.value = newFormData
|
formData.value = newFormData
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
@ -57,7 +57,7 @@ v-model="queryParams.idcard" placeholder="请输入身份证号" clearable @keyu
|
|||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item command="handleDelete">
|
<el-dropdown-item command="handleDelete">
|
||||||
<el-button type="danger" link>
|
<el-button type="danger" link>
|
||||||
<Icon icon="ep:delete" />删除
|
<Icon icon="ep:delete" />删除档案
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
@ -141,9 +141,9 @@ const getList = async () => {
|
|||||||
try {
|
try {
|
||||||
//首先获取用户信息
|
//首先获取用户信息
|
||||||
userProfile.value = await getUserProfile()
|
userProfile.value = await getUserProfile()
|
||||||
console.log(userProfile.value)
|
|
||||||
queryParams.orgid = userProfile.value.dept.id
|
queryParams.orgid = userProfile.value.dept.id
|
||||||
const data = await PersonApi.getPersonPage(queryParams)
|
const data = await PersonApi.getPersonPage(queryParams)
|
||||||
|
console.log(data.list)
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
@ -209,7 +209,8 @@ const handleExport = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 操作分发 */
|
/** 操作分发 */
|
||||||
const handleCommand = async (command: string, row: PersonArchiveVO) => {
|
const handleCommand = async (command: string, row:any) => {
|
||||||
|
console.log(row)
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'handleCreate':
|
case 'handleCreate':
|
||||||
if(row.id){
|
if(row.id){
|
||||||
|
Loading…
Reference in New Issue
Block a user