fix(prescription): 解决处方列表中科室选择和数据删除问题
- 为科室选择下拉框添加最小宽度样式,确保内容完整显示 - 添加orgTreeLoading状态管理,避免重复加载组织机构树 - 在selectAdviceBase方法中添加异步处理和边界检查逻辑 - 实现诊疗项目默认使用患者就诊科室的逻辑验证 - 修复ensureOrgTreeLoaded方法中的加载状态管理 - 在处方删除操作中添加encounterId和patientId参数传递 - 优化组织机构树查找算法,提升性能表现
This commit is contained in:
@@ -135,6 +135,8 @@
|
|||||||
value-key="id"
|
value-key="id"
|
||||||
check-strictly
|
check-strictly
|
||||||
placeholder="请选择执行科室"
|
placeholder="请选择执行科室"
|
||||||
|
style="min-width: 150px; width: auto;"
|
||||||
|
class="org-select"
|
||||||
/>
|
/>
|
||||||
<span class="total-amount">
|
<span class="total-amount">
|
||||||
总金额:{{ scope.row.totalPrice ? scope.row.totalPrice + ' 元' : '0.00 元' }}
|
总金额:{{ scope.row.totalPrice ? scope.row.totalPrice + ' 元' : '0.00 元' }}
|
||||||
@@ -302,6 +304,7 @@ const unitCodeList = ref([]);
|
|||||||
const adviceTableRef = ref([]);
|
const adviceTableRef = ref([]);
|
||||||
const organization = ref([]);
|
const organization = ref([]);
|
||||||
const orgTreeLoaded = ref(false);
|
const orgTreeLoaded = ref(false);
|
||||||
|
const orgTreeLoading = ref(false);
|
||||||
const rowRules = ref({
|
const rowRules = ref({
|
||||||
conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }],
|
conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }],
|
||||||
dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
|
dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
|
||||||
@@ -473,9 +476,9 @@ function handleChange(value) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择药品/诊疗项目回调
|
* 选择药品/诊疗项目回调
|
||||||
* 这里恢复为之前“能正常工作”的简单逻辑,只做最小必要的修正
|
* 这里恢复为之前"能正常工作"的简单逻辑,只做最小必要的修正
|
||||||
*/
|
*/
|
||||||
function selectAdviceBase(key, row) {
|
async function selectAdviceBase(key, row) {
|
||||||
if (!row) {
|
if (!row) {
|
||||||
console.error('[selectAdviceBase] row 为空');
|
console.error('[selectAdviceBase] row 为空');
|
||||||
return;
|
return;
|
||||||
@@ -491,6 +494,16 @@ function selectAdviceBase(key, row) {
|
|||||||
rowIndex.value = foundIndex;
|
rowIndex.value = foundIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rowIndex 理论上由 handleFocus 设置;防御一下越界
|
||||||
|
if (rowIndex.value < 0 || rowIndex.value >= prescriptionList.value.length) {
|
||||||
|
const foundIndex = prescriptionList.value.findIndex((item) => item.uniqueKey === key);
|
||||||
|
if (foundIndex === -1) {
|
||||||
|
console.error('[selectAdviceBase] 找不到对应行,key =', key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rowIndex.value = foundIndex;
|
||||||
|
}
|
||||||
|
|
||||||
// 关闭当前行弹窗
|
// 关闭当前行弹窗
|
||||||
const currentRow = prescriptionList.value[rowIndex.value];
|
const currentRow = prescriptionList.value[rowIndex.value];
|
||||||
if (currentRow) {
|
if (currentRow) {
|
||||||
@@ -499,7 +512,7 @@ function selectAdviceBase(key, row) {
|
|||||||
|
|
||||||
// 诊疗(adviceType=3) 才需要加载执行科室树,且只加载一次
|
// 诊疗(adviceType=3) 才需要加载执行科室树,且只加载一次
|
||||||
if (row.adviceType === 3) {
|
if (row.adviceType === 3) {
|
||||||
ensureOrgTreeLoaded();
|
await ensureOrgTreeLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建单位列表(保持原有逻辑)
|
// 构建单位列表(保持原有逻辑)
|
||||||
@@ -573,11 +586,24 @@ function selectAdviceBase(key, row) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 诊疗:设置执行科室和价格
|
// 诊疗:设置执行科室和价格
|
||||||
// 🔧 Bug Fix #238: 如果positionId为空,使用orgId作为默认值
|
// 🔧 Bug Fix #238: 诊疗项目默认使用患者就诊科室(需确保科室在当前用户权限范围内)
|
||||||
const rowData = JSON.parse(JSON.stringify(row));
|
if (!prescriptionList.value[rowIndex.value].orgId && props.patientInfo.orgId) {
|
||||||
const selectedPositionId = rowData.positionId;
|
// 检查患者就诊科室是否在当前用户的organization树中
|
||||||
const selectedOrgId = rowData.orgId;
|
const orgIdStr = String(props.patientInfo.orgId);
|
||||||
prescriptionList.value[rowIndex.value].orgId = selectedPositionId || selectedOrgId;
|
const findOrgInTree = (tree, targetId) => {
|
||||||
|
for (const node of tree) {
|
||||||
|
if (String(node.id) === targetId) return true;
|
||||||
|
if (node.children && node.children.length > 0) {
|
||||||
|
if (findOrgInTree(node.children, targetId)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (findOrgInTree(organization.value, orgIdStr)) {
|
||||||
|
prescriptionList.value[rowIndex.value].orgId = props.patientInfo.orgId;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (row.priceList && row.priceList.length > 0) {
|
if (row.priceList && row.priceList.length > 0) {
|
||||||
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
|
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
|
||||||
} else {
|
} else {
|
||||||
@@ -603,16 +629,33 @@ function selectAdviceBase(key, row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ensureOrgTreeLoaded() {
|
function ensureOrgTreeLoaded() {
|
||||||
if (orgTreeLoaded.value) return;
|
if (orgTreeLoaded.value && organization.value.length > 0) {
|
||||||
orgTreeLoaded.value = true;
|
return Promise.resolve();
|
||||||
getOrgTree()
|
}
|
||||||
|
if (orgTreeLoading.value) {
|
||||||
|
// 如果正在加载中,等待加载完成
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
if (!orgTreeLoading.value) {
|
||||||
|
clearInterval(timer);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
orgTreeLoading.value = true;
|
||||||
|
return getOrgTree()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
// 组织机构树接口通常返回分页 records,这里做兼容兜底
|
// 组织机构树接口通常返回分页 records,这里做兼容兜底
|
||||||
organization.value = res?.data?.records ?? res?.data ?? [];
|
organization.value = res?.data?.records ?? res?.data ?? [];
|
||||||
|
orgTreeLoaded.value = true;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// 加载失败时允许重试
|
// 加载失败时允许重试
|
||||||
orgTreeLoaded.value = false;
|
orgTreeLoaded.value = false;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
orgTreeLoading.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,4 +949,23 @@ defineExpose({ getListInfo });
|
|||||||
.el-table__cell .el-form-item--default {
|
.el-table__cell .el-form-item--default {
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 🔧 Bug Fix #238: 科室选择框样式,确保内容完整显示 */
|
||||||
|
.org-select {
|
||||||
|
min-width: 150px;
|
||||||
|
width: auto;
|
||||||
|
|
||||||
|
:deep(.el-select__wrapper) {
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-select__selection) {
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-select__selected-item) {
|
||||||
|
max-width: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1991,6 +1991,8 @@ function handleDelete() {
|
|||||||
requestId: deleteItem.requestId,
|
requestId: deleteItem.requestId,
|
||||||
dbOpType: '3',
|
dbOpType: '3',
|
||||||
adviceType: deleteItem.adviceType,
|
adviceType: deleteItem.adviceType,
|
||||||
|
encounterId: deleteItem.encounterId, // 🔧 BugFix#219: 添加就诊ID
|
||||||
|
patientId: deleteItem.patientId, // 🔧 BugFix#219: 添加患者ID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -981,6 +981,8 @@ function handleDelete(pIndex) {
|
|||||||
prescriptionNo: deleteItem.prescriptionNo,
|
prescriptionNo: deleteItem.prescriptionNo,
|
||||||
dbOpType: '3',
|
dbOpType: '3',
|
||||||
adviceType: deleteItem.adviceType,
|
adviceType: deleteItem.adviceType,
|
||||||
|
encounterId: deleteItem.encounterId, // 🔧 BugFix#219: 添加就诊ID
|
||||||
|
patientId: deleteItem.patientId, // 🔧 BugFix#219: 添加患者ID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user