● fix(patient): 修复性别显示&字典获取问题,优化患者弹窗标题
- 修复 patientAddDialog 中 proxy.getDictDataByType is not a function 错误,
改用 getDicts('gend') 获取性别字典数据
- 修复患者列表性别字段显示数字问题:outpatienrecords 补装性别字典,
patientmanagement 增加 {dictValue,dictLabel}→{value,label} 格式转换
- 清理未使用的 patient_gender_enum 枚举引用
- 修复查看/编辑弹窗标题始终显示"修改患者":setFormData 查看模式下
不再覆盖 setViewMode 设置的标题
This commit is contained in:
@@ -589,11 +589,11 @@ import {updatePatient} from '@/views/patientmanagement/patientmanagement/compone
|
||||
import {getGenderAndAge, isValidCNidCardNumber, isValidCNPhoneNumber,} from '../../../../utils/validate';
|
||||
import {ElMessage} from 'element-plus';
|
||||
import {getConfigKey} from '@/api/system/config'; // 导入获取配置的方法
|
||||
import {getDicts} from '@/api/system/dict/data'; // 导入获取字典数据的方法
|
||||
|
||||
const router = useRouter();
|
||||
const { proxy } = getCurrentInstance();
|
||||
const {
|
||||
patient_gender_enum,
|
||||
sys_idtype,
|
||||
prfs_enum,
|
||||
blood_rh,
|
||||
@@ -603,7 +603,6 @@ const {
|
||||
link_relation_code,
|
||||
nationality_code,
|
||||
} = proxy.useDict(
|
||||
'patient_gender_enum',
|
||||
'sys_idtype',
|
||||
'prfs_enum',
|
||||
'blood_rh',
|
||||
@@ -634,14 +633,15 @@ const getPatientDerivedOptions = async () => {
|
||||
try {
|
||||
console.log('开始获取患者来源字典数据...');
|
||||
// 从字典管理获取患者来源数据,字典类型为patient_derived
|
||||
const patientDerivedDict = await proxy.getDictDataByType('patient_derived');
|
||||
console.log('获取到的患者来源原始数据:', patientDerivedDict);
|
||||
|
||||
const response = await getDicts('patient_derived');
|
||||
console.log('获取到的患者来源原始数据:', response);
|
||||
|
||||
// 确保数据是数组
|
||||
if (!Array.isArray(patientDerivedDict)) {
|
||||
console.error('患者来源数据格式错误,不是数组:', patientDerivedDict);
|
||||
if (!response || response.code !== 200 || !Array.isArray(response.data)) {
|
||||
console.error('患者来源数据格式错误:', response);
|
||||
return;
|
||||
}
|
||||
const patientDerivedDict = response.data;
|
||||
|
||||
// 按字典排序字段(sort字段)升序排序
|
||||
const sortedPatientDerived = patientDerivedDict.sort((a, b) => {
|
||||
@@ -675,33 +675,20 @@ const getPatientDerivedOptions = async () => {
|
||||
// 从字典管理获取性别数据
|
||||
const getGenderOptions = async () => {
|
||||
try {
|
||||
// 从字典管理获取性别数据
|
||||
const genderDict = await proxy.getDictDataByType('性别');
|
||||
|
||||
// 去重:使用 Map 根据 value 去重
|
||||
const uniqueMap = new Map();
|
||||
genderDict.forEach(item => {
|
||||
if (!uniqueMap.has(item.value)) {
|
||||
uniqueMap.set(item.value, item);
|
||||
}
|
||||
});
|
||||
const uniqueGenders = Array.from(uniqueMap.values());
|
||||
|
||||
// 按字典排序字段排序
|
||||
const sortedGenders = uniqueGenders.sort((a, b) => {
|
||||
return (a.sort || 0) - (b.sort || 0);
|
||||
});
|
||||
|
||||
// 转换为组件需要的格式,确保 value 是字符串类型
|
||||
administrativegenderList.value = sortedGenders.map(item => ({
|
||||
value: String(item.value), // 确保值为字符串类型
|
||||
info: item.label // 使用字典标签
|
||||
const response = await getDicts('gend');
|
||||
if (!response || response.code !== 200 || !Array.isArray(response.data)) {
|
||||
console.error('性别字典数据格式错误:', response);
|
||||
return;
|
||||
}
|
||||
// 下拉显示标签(dictLabel),值用键值(dictValue)
|
||||
administrativegenderList.value = response.data.map(item => ({
|
||||
value: String(item.dictValue || item.value),
|
||||
info: item.dictLabel || item.label
|
||||
}));
|
||||
|
||||
console.log('性别字典数据加载完成:', administrativegenderList.value);
|
||||
} catch (error) {
|
||||
console.error('获取性别字典数据失败:', error);
|
||||
// 降级方案:使用默认的性别选项
|
||||
// 降级方案
|
||||
administrativegenderList.value = [
|
||||
{ value: '1', info: '男' },
|
||||
{ value: '2', info: '女' },
|
||||
@@ -715,14 +702,15 @@ const getGenderOptions = async () => {
|
||||
const getEducationLevelOptions = async () => {
|
||||
try {
|
||||
// 从字典管理获取文化程度数据
|
||||
const educationDict = await proxy.getDictDataByType('文化程度');
|
||||
console.log('获取到的文化程度数据:', educationDict);
|
||||
|
||||
const response = await getDicts('文化程度');
|
||||
console.log('获取到的文化程度原始数据:', response);
|
||||
|
||||
// 确保数据是数组
|
||||
if (!Array.isArray(educationDict)) {
|
||||
console.error('文化程度数据格式错误,不是数组:', educationDict);
|
||||
if (!response || response.code !== 200 || !Array.isArray(response.data)) {
|
||||
console.error('文化程度数据格式错误:', response);
|
||||
return;
|
||||
}
|
||||
const educationDict = response.data;
|
||||
|
||||
// 按字典编码顺序升序排列(根据截图显示,排序字段为字典编码)
|
||||
const sortedEducation = educationDict.sort((a, b) => {
|
||||
@@ -1646,9 +1634,12 @@ function setViewMode(isView) {
|
||||
|
||||
// 设置表单数据
|
||||
function setFormData(rowData) {
|
||||
// 查看模式不改变标题(setViewMode 已设置 '查看患者')
|
||||
if (!isViewMode.value) {
|
||||
title.value = '修改患者';
|
||||
}
|
||||
// 标记为编辑模式
|
||||
isEditMode.value = true;
|
||||
title.value = '修改患者';
|
||||
|
||||
// 深拷贝数据以避免引用问题
|
||||
form.value = JSON.parse(JSON.stringify(rowData));
|
||||
|
||||
@@ -132,11 +132,18 @@
|
||||
min-width="100"
|
||||
/>
|
||||
<vxe-column
|
||||
field="genderEnum_enumText"
|
||||
field="genderEnum"
|
||||
title="性别"
|
||||
width="80"
|
||||
align="center"
|
||||
/>
|
||||
>
|
||||
<template #default="scope">
|
||||
<dict-tag
|
||||
:options="genderDict"
|
||||
:value="scope.row.genderEnum"
|
||||
/>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column
|
||||
field="idCard"
|
||||
title="身份证"
|
||||
@@ -216,6 +223,7 @@ const doctorList = ref([]);
|
||||
const loading = ref(false);
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { gend: genderDict } = proxy.useDict('gend');
|
||||
const route = useRoute();
|
||||
|
||||
const data = reactive({
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
>
|
||||
<template #default="scope">
|
||||
<dict-tag
|
||||
:options="patient_gender_enum"
|
||||
:options="genderDict"
|
||||
:value="scope.row.genderEnum"
|
||||
class="dict-tag"
|
||||
/>
|
||||
@@ -296,6 +296,7 @@ import {nextTick, ref} from 'vue';
|
||||
import {useRoute} from 'vue-router';
|
||||
import {useRouter} from 'vue-router';
|
||||
import {addPatient, listPatient, lists, updatePatient} from './component/api';
|
||||
import {getDicts} from '@/api/system/dict/data';
|
||||
import PatientAddDialog from '@/views/charge/outpatientregistration/components/patientAddDialog';
|
||||
|
||||
const route = useRoute();
|
||||
@@ -323,7 +324,6 @@ const selectedOptions = ref([]); // v-model 绑定的选中值
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const {
|
||||
patient_gender_enum,
|
||||
sys_idtype,
|
||||
prfs_enum,
|
||||
blood_rh,
|
||||
@@ -333,7 +333,6 @@ const {
|
||||
link_relation_code,
|
||||
nationality_code,
|
||||
} = proxy.useDict(
|
||||
'patient_gender_enum',
|
||||
'sys_idtype',
|
||||
'prfs_enum',
|
||||
'blood_rh',
|
||||
@@ -343,6 +342,15 @@ const {
|
||||
'link_relation_code',
|
||||
'nationality_code'
|
||||
);
|
||||
const genderDict = ref([]);
|
||||
getDicts('gend').then(response => {
|
||||
if (response && response.code === 200 && Array.isArray(response.data)) {
|
||||
genderDict.value = response.data.map(item => ({
|
||||
value: String(item.dictValue || item.value),
|
||||
label: item.dictLabel || item.label,
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
const data = reactive({
|
||||
isViewMode: false,
|
||||
|
||||
Reference in New Issue
Block a user