调整
This commit is contained in:
parent
9f346a575f
commit
b5de0abf81
@ -278,14 +278,14 @@ watch(() => formData.value.address, (newValue) => {
|
||||
})
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number, userProfile?: any) => {
|
||||
const open = async (type: string, id?: number, userProfile?: any, currentPerson?: any) => {
|
||||
userData.value = userProfile
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
if (type === 'update' && id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await PersonArchiveApi.getPersonArchiveByUserid(id)
|
||||
@ -308,6 +308,46 @@ const open = async (type: string, id?: number, userProfile?: any) => {
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
} else if (currentPerson) {
|
||||
// 创建时,如果有传入的人员信息,则使用这些信息
|
||||
const newFormData = {
|
||||
id: undefined,
|
||||
userid: currentPerson.id,
|
||||
orgid: userProfile.dept.id,
|
||||
orgname: userProfile.dept.name,
|
||||
name: currentPerson.name,
|
||||
gender: currentPerson.gender,
|
||||
age: currentPerson.age,
|
||||
idcard: currentPerson.idcard,
|
||||
address: currentPerson.address || '',
|
||||
phone: currentPerson.phone,
|
||||
bloodtype: undefined,
|
||||
sleepsituation: undefined,
|
||||
height: undefined,
|
||||
weight: undefined,
|
||||
waist: undefined,
|
||||
hip: undefined,
|
||||
drinking: undefined,
|
||||
disability: undefined,
|
||||
drugallergy: undefined,
|
||||
exposure: undefined,
|
||||
diseasehistory: undefined,
|
||||
surgeryhistory: undefined,
|
||||
traumahistory: undefined,
|
||||
transfusionhistory: undefined,
|
||||
disabilitydesc: undefined,
|
||||
drugallergydesc: undefined,
|
||||
exposuredesc: undefined,
|
||||
diseasehistorydesc: undefined,
|
||||
surgeryhistorydesc: undefined,
|
||||
traumahistorydesc: undefined,
|
||||
transfusionhistorydesc: undefined,
|
||||
createtime: undefined,
|
||||
updatetime: undefined,
|
||||
createby: undefined,
|
||||
updateby: undefined
|
||||
}
|
||||
formData.value = newFormData
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
@ -323,13 +363,13 @@ const submitForm = async () => {
|
||||
const data = formData.value as unknown as PersonArchiveVO
|
||||
if (formType.value === 'create') {
|
||||
data.orgid = userData.value.dept.id
|
||||
data.orgname = userData.value.nickname
|
||||
data.orgname = userData.value.dept.name
|
||||
data.createtime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
await PersonArchiveApi.createPersonArchive(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
data.orgid = userData.value.dept.id
|
||||
data.orgname = userData.value.nickname
|
||||
data.orgname = userData.value.dept.name
|
||||
data.updatetime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
await PersonArchiveApi.updatePersonArchive(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
|
@ -38,17 +38,8 @@ v-model="queryParams.idcard" placeholder="请输入身份证号" clearable @keyu
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="身份证号" align="center" prop="idcard" />
|
||||
<el-table-column label="血型" align="center" prop="bloodtype">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.bloodtype === 'A'" type="success">A</el-tag>
|
||||
<el-tag v-else-if="scope.row.bloodtype === 'B'" type="danger">B</el-tag>
|
||||
<el-tag v-else-if="scope.row.bloodtype === 'AB'" type="warning">AB</el-tag>
|
||||
<el-tag v-else-if="scope.row.bloodtype === 'O'" type="info">O</el-tag>
|
||||
<el-tag v-else type="info">其他</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" align="center" prop="phone" />
|
||||
<el-table-column label="户籍住址" align="center" prop="address" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="地址" align="center" prop="address" width="400"/>
|
||||
<el-table-column label="操作" align="center" width="160">
|
||||
<template #default="scope">
|
||||
<div class="flex items-center justify-center">
|
||||
@ -150,6 +141,7 @@ const getList = async () => {
|
||||
try {
|
||||
//首先获取用户信息
|
||||
userProfile.value = await getUserProfile()
|
||||
console.log(userProfile.value)
|
||||
queryParams.orgid = userProfile.value.dept.id
|
||||
const data = await PersonApi.getPersonPage(queryParams)
|
||||
list.value = data.list
|
||||
@ -173,8 +165,8 @@ const resetQuery = () => {
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = async (type: string, id?: number) => {
|
||||
if (type == 'update') {
|
||||
const openForm = async (type: string, id?: number, currentPerson?: any) => {
|
||||
if (type == 'update' && id) {
|
||||
const res = await PersonArchiveApi.getPersonArchiveByUserid(id)
|
||||
if (!res) {
|
||||
message.error('该人员没有档案')
|
||||
@ -184,7 +176,7 @@ const openForm = async (type: string, id?: number) => {
|
||||
formRef.value.open(type, id, userProfile.value)
|
||||
}
|
||||
} else {
|
||||
formRef.value.open(type, id, userProfile.value)
|
||||
formRef.value.open(type, id, userProfile.value, currentPerson)
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,10 +219,10 @@ const handleCommand = async (command: string, row: PersonArchiveVO) => {
|
||||
return
|
||||
}
|
||||
else{
|
||||
openForm('create')
|
||||
openForm('create', row.id, row)
|
||||
}
|
||||
}else{
|
||||
openForm('create')
|
||||
openForm('create', row.id, row)
|
||||
}
|
||||
break
|
||||
case 'handleDelete':
|
||||
|
Loading…
Reference in New Issue
Block a user