diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue index ff0780ec..1231db37 100644 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue @@ -445,15 +445,28 @@ 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 = genderDict.sort((a, b) => { + const sortedGenders = uniqueGenders.sort((a, b) => { return (a.sort || 0) - (b.sort || 0); }); - // 转换为组件需要的格式 + + // 转换为组件需要的格式,确保 value 是字符串类型 administrativegenderList.value = sortedGenders.map(item => ({ - value: item.value, // 使用字典键值 + value: String(item.value), // 确保值为字符串类型 info: item.label // 使用字典标签 })); + + console.log('性别字典数据加载完成:', administrativegenderList.value); } catch (error) { console.error('获取性别字典数据失败:', error); // 降级方案:使用默认的性别选项 @@ -527,6 +540,8 @@ const options = ref(pcas); // 地区数据 const title = ref('新增患者'); const visible = ref(false); +const isEditMode = ref(false); // 标记是否为编辑模式 +const originalFormData = ref({}); // 存储原始数据,用于编辑模式比较 const emits = defineEmits(['submit']); // 声明自定义事件 const validateUniquePatient = (rule, value, callback) => { @@ -536,6 +551,13 @@ const validateUniquePatient = (rule, value, callback) => { return callback(); // 不满足条件,不校验 } + // 修改模式下,如果姓名和身份证与原值相同,跳过校验 + if (isEditMode.value && + originalFormData.value.name === name && + originalFormData.value.idCard === idCard) { + return callback(); + } + // 使用 axios 直接请求,避免依赖 proxy.$http import('@/utils/request').then(({ default: request }) => { request({ @@ -1161,6 +1183,11 @@ const getCountryCodeOptions = async () => { // 显示弹框 function show() { + // 重置为新增模式 + isEditMode.value = false; + title.value = '新增患者'; + originalFormData.value = {}; + // queryParams.roleId = props.roleId; getList(); // 调用从字典管理获取性别数据的函数 @@ -1206,6 +1233,10 @@ function reset() { organizationId: undefined, birthDate: undefined, }; + // 重置编辑模式状态 + isEditMode.value = false; + title.value = '新增患者'; + originalFormData.value = {}; proxy.resetForm('patientRef'); } /** 提交按钮 */ @@ -1376,13 +1407,32 @@ watch( // 设置查看模式 function setViewMode(isView) { isViewMode.value = isView; + if (isView) { + title.value = '查看患者'; + } } // 设置表单数据 function setFormData(rowData) { + // 标记为编辑模式 + isEditMode.value = true; + title.value = '修改患者'; + // 深拷贝数据以避免引用问题 form.value = JSON.parse(JSON.stringify(rowData)); + // 确保性别值为字符串类型,以便与下拉框选项匹配 + if (form.value.genderEnum !== undefined && form.value.genderEnum !== null) { + form.value.genderEnum = String(form.value.genderEnum); + } + + // 保存原始数据,用于唯一性校验比较 + originalFormData.value = { + name: rowData.name, + idCard: rowData.idCard, + identifierNo: rowData.identifierNo + }; + // 如果有地址信息,设置级联选择器 if (rowData.addressProvince || rowData.addressCity || rowData.addressDistrict) { // 构建地址数组 @@ -1399,7 +1449,7 @@ function setFormData(rowData) { } } - // 设置患者ID信息 - 如果没有patientIdInfoList则创建一个 + // 设置患者 ID 信息 - 如果没有 patientIdInfoList 则创建一个 if (!form.value.patientIdInfoList || form.value.patientIdInfoList.length === 0) { form.value.patientIdInfoList = [ { @@ -1413,10 +1463,29 @@ function setFormData(rowData) { form.value.typeCode = '01'; } - // 设置活动标识 - 根据activeFlag设置tempFlag + // 设置活动标识 - 根据 activeFlag 设置 tempFlag if (form.value.activeFlag) { form.value.tempFlag = form.value.activeFlag === 2 ? '1' : '0'; } + + // 根据出生日期自动计算年龄 + if (form.value.birthDate) { + const birthDate = new Date(form.value.birthDate); + const today = new Date(); + + let age = today.getFullYear() - birthDate.getFullYear(); + const monthDiff = today.getMonth() - birthDate.getMonth(); + + // 计算精确年龄(考虑是否已过生日) + if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) { + age--; + } + + // 只有当年龄为正数时才设置 + if (age >= 0) { + form.value.age = age; + } + } } // 将地址转换为级联选择器所需的代码 diff --git a/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue b/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue index f9ef33ed..f958a514 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue @@ -191,11 +191,18 @@ const filteredAdviceBaseList = computed(() => { } // 过滤无库存的药品(只针对药品类型 adviceType === 1) + // Bug #129 修复:确保库存为0的药品不被检索出来 result = result.filter(item => { if (item.adviceType === 1) { // 检查是否有库存 if (item.inventoryList && item.inventoryList.length > 0) { - const totalQuantity = item.inventoryList.reduce((sum, inv) => sum + (inv.quantity || 0), 0); + // 计算总库存数量,确保转换为数字进行正确计算 + const totalQuantity = item.inventoryList.reduce((sum, inv) => { + const qty = inv.quantity !== undefined && inv.quantity !== null + ? (typeof inv.quantity === 'number' ? inv.quantity : Number(inv.quantity) || 0) + : 0; + return sum + qty; + }, 0); return totalQuantity > 0; } return false; // 无库存列表或库存为空,视为无库存 diff --git a/openhis-ui-vue3/src/views/doctorstation/components/infectiousReport/index.vue b/openhis-ui-vue3/src/views/doctorstation/components/infectiousReport/index.vue new file mode 100644 index 00000000..85b3cec9 --- /dev/null +++ b/openhis-ui-vue3/src/views/doctorstation/components/infectiousReport/index.vue @@ -0,0 +1,1225 @@ + + + + + \ No newline at end of file diff --git a/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmMedicineList.vue b/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmMedicineList.vue index 0f4059cc..8a1f214c 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmMedicineList.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmMedicineList.vue @@ -3,7 +3,7 @@