患者档案(现为患者列表)->修改和查看按钮调出窗口与新建患者保持一致
This commit is contained in:
@@ -342,6 +342,7 @@
|
||||
<script setup name="PatientAddDialog">
|
||||
import pcas from 'china-division/dist/pcas-code.json';
|
||||
import {addPatient, getOutpatientRegistrationList, patientlLists} from './outpatientregistration';
|
||||
import {updatePatient} from '@/views/patientmanagement/patientmanagement/component/api';
|
||||
import {getGenderAndAge, isValidCNidCardNumber, isValidCNPhoneNumber,} from '../../../../utils/validate';
|
||||
import {ElMessage} from 'element-plus';
|
||||
|
||||
@@ -1224,13 +1225,26 @@ function submitForm() {
|
||||
}
|
||||
form.value.address = getAddress(form);
|
||||
|
||||
// 提交新增患者请求
|
||||
addPatient(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('新增成功');
|
||||
getPatientInfo(response.data.idCard);
|
||||
visible.value = false;
|
||||
reset();
|
||||
});
|
||||
// 判断是修改还是新增
|
||||
if (form.value.busNo != undefined) {
|
||||
// 修改患者
|
||||
updatePatient(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('修改成功');
|
||||
visible.value = false;
|
||||
// 触发提交成功事件,让父组件刷新列表
|
||||
emits('submit', 'update');
|
||||
});
|
||||
} else {
|
||||
// 新增患者
|
||||
addPatient(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('新增成功');
|
||||
getPatientInfo(response.data.idCard);
|
||||
visible.value = false;
|
||||
reset();
|
||||
// 触发提交成功事件,让父组件刷新列表
|
||||
emits('submit', 'add');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1270,8 +1284,66 @@ const typeChange = () => {
|
||||
form.value.genderEnum = info.gender;
|
||||
}
|
||||
};
|
||||
// 设置查看模式
|
||||
function setViewMode(isView) {
|
||||
isViewMode.value = isView;
|
||||
}
|
||||
|
||||
// 设置表单数据
|
||||
function setFormData(rowData) {
|
||||
// 深拷贝数据以避免引用问题
|
||||
form.value = JSON.parse(JSON.stringify(rowData));
|
||||
|
||||
// 如果有地址信息,设置级联选择器
|
||||
if (rowData.addressProvince || rowData.addressCity || rowData.addressDistrict) {
|
||||
// 构建地址数组
|
||||
const addressParts = [
|
||||
rowData.addressProvince,
|
||||
rowData.addressCity,
|
||||
rowData.addressDistrict,
|
||||
rowData.addressStreet,
|
||||
].filter(part => part); // 过滤空值
|
||||
|
||||
if (addressParts.length > 0) {
|
||||
const codes = convertAddressToCodes(addressParts);
|
||||
selectedOptions.value = codes.filter((code) => code !== null);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置患者ID信息 - 如果没有patientIdInfoList则创建一个
|
||||
if (!form.value.patientIdInfoList || form.value.patientIdInfoList.length === 0) {
|
||||
form.value.patientIdInfoList = [
|
||||
{
|
||||
typeCode: '01',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// 确保必要字段有默认值
|
||||
if (!form.value.typeCode) {
|
||||
form.value.typeCode = '01';
|
||||
}
|
||||
|
||||
// 设置活动标识 - 根据activeFlag设置tempFlag
|
||||
if (form.value.activeFlag) {
|
||||
form.value.tempFlag = form.value.activeFlag === 2 ? '1' : '0';
|
||||
}
|
||||
}
|
||||
|
||||
// 将地址转换为级联选择器所需的代码
|
||||
function convertAddressToCodes(addressParts) {
|
||||
return addressParts.map((part) => {
|
||||
if (!part) return null;
|
||||
// 这里需要根据实际的地址名称找到对应的代码
|
||||
// 由于数据结构的复杂性,这里先返回空值
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
setViewMode,
|
||||
setFormData,
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user