诊疗下面没有诊疗项目

This commit is contained in:
2026-01-22 14:03:38 +08:00
parent 1dd7ee3428
commit 49550fcc2e
19 changed files with 1268 additions and 25 deletions

View File

@@ -183,6 +183,23 @@
prop="statusEnum_enumText"
:show-overflow-tooltip="true"
/>
<el-table-column
label="划价标记"
align="center"
key="pricingFlag_enumText"
prop="pricingFlag_enumText"
:show-overflow-tooltip="true"
width="100"
>
<template #default="scope">
<el-tag
:type="scope.row.pricingFlag === 1 ? 'success' : scope.row.pricingFlag === 0 ? 'danger' : 'info'"
size="small"
>
{{ scope.row.pricingFlag_enumText || (scope.row.pricingFlag === 1 ? '允许' : scope.row.pricingFlag === 0 ? '不允许' : '未设置') }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"

View File

@@ -8,6 +8,7 @@
@current-change="handleCurrentChange"
row-key="patientId"
@cell-click="clickRow"
@row-click="clickRow"
>
<el-table-column label="名称" align="center" prop="adviceName" />
<el-table-column label="类型" align="center" prop="activityType_enumText" />
@@ -38,6 +39,10 @@ const props = defineProps({
type: Object,
required: true,
},
popoverVisible: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['selectAdviceBase']);
const total = ref(0);
@@ -61,30 +66,80 @@ const throttledGetList = throttle(
watch(
() => props.adviceQueryParams,
(newValue) => {
queryParams.value.searchKey = newValue.searchKey;
queryParams.value.adviceType = newValue.adviceType;
// 只有在弹窗打开时才响应 adviceQueryParams 的变化,避免选择项目后弹窗关闭时触发不必要的请求
if (!props.popoverVisible) {
return;
}
queryParams.value.searchKey = newValue?.searchKey;
queryParams.value.adviceType = newValue?.adviceType;
throttledGetList();
},
{ deep: true }
);
getList();
// 监听弹窗打开状态,当弹窗打开时主动加载数据
watch(
() => props.popoverVisible,
(visible) => {
if (visible) {
// 弹窗打开时,确保 adviceQueryParams 同步到 queryParams
if (props.adviceQueryParams) {
queryParams.value.searchKey = props.adviceQueryParams.searchKey;
queryParams.value.adviceType = props.adviceQueryParams.adviceType;
}
// 主动触发数据加载
getList();
} else {
// 弹窗关闭时,清空列表数据,避免显示错误的数据
adviceBaseList.value = [];
total.value = 0;
}
}
);
// 移除组件初始化时的 getList() 调用,避免在没有 adviceType 时查询所有类型的数据
// getList();
function getList() {
// 验证是否已选择患者
if (!props.patientInfo || Object.keys(props.patientInfo).length === 0) {
console.log('[adviceBaseList] getList() 跳过:未选择患者');
return; // 不执行API调用
}
// 只有在弹窗打开时才执行查询
if (!props.popoverVisible) {
console.log('[adviceBaseList] getList() 跳过:弹窗未打开');
return;
}
// 必须有 adviceType 才查询,避免查询所有类型的数据
if (!queryParams.value.adviceType) {
console.log('[adviceBaseList] getList() 跳过adviceType 未设置,当前值:', queryParams.value.adviceType);
return;
}
queryParams.value.organizationId = props.patientInfo.orgId;
console.log('[adviceBaseList] getList() 请求参数:', JSON.stringify(queryParams.value));
getAdviceBaseInfo(queryParams.value).then((res) => {
adviceBaseList.value = res.data.records;
total.value = res.data.total;
console.log('[adviceBaseList] getList() 响应数据:', {
total: res.data?.total,
recordsCount: res.data?.records?.length || 0,
firstRecord: res.data?.records?.[0]?.adviceName || '无数据',
adviceType: queryParams.value.adviceType
});
adviceBaseList.value = res.data.records || [];
total.value = res.data.total || 0;
nextTick(() => {
currentIndex.value = 0;
if (adviceBaseList.value.length > 0) {
adviceBaseRef.value.setCurrentRow(adviceBaseList.value[0]);
adviceBaseRef.value?.setCurrentRow(adviceBaseList.value[0]);
}
});
}).catch((err) => {
console.error('[adviceBaseList] getList() 请求失败:', err);
adviceBaseList.value = [];
total.value = 0;
});
}
@@ -136,8 +191,12 @@ const handleCurrentChange = (currentRow) => {
currentSelectRow.value = currentRow;
};
function clickRow(row) {
emit('selectAdviceBase', row);
function clickRow(row, column, cell, event) {
// cell-click 事件会传递 row, column, cell, event 四个参数
// 确保传递的是完整的行数据
if (row) {
emit('selectAdviceBase', row);
}
}
defineExpose({

View File

@@ -301,6 +301,7 @@ const nextId = ref(1);
const unitCodeList = ref([]);
const adviceTableRef = ref([]);
const organization = ref([]);
const orgTreeLoaded = ref(false);
const rowRules = ref({
conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }],
dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
@@ -449,6 +450,10 @@ function handleDiagnosisChange(item, row) {
function handleFocus(row, index) {
rowIndex.value = index;
// 打开当前行弹窗前,先关闭其它行,避免多个弹窗同时存在
prescriptionList.value.forEach((r, i) => {
if (i !== index) r.showPopover = false;
});
// 如果当前行已选择adviceType同步到adviceQueryParams
if (row.adviceType !== undefined) {
adviceQueryParams.value.adviceType = row.adviceType;
@@ -457,7 +462,9 @@ function handleFocus(row, index) {
}
function handleBlur(row) {
row.showPopover = false;
// 不能在 input blur 时立刻关闭弹窗:
// 点击弹窗里的表格会先触发 blur导致弹窗瞬间关闭从而“点了项目没反应”
// 弹窗关闭交给 selectAdviceBase()(选中后关闭)以及 handleFocus()(切行时关闭其他行)
}
function handleChange(value) {
@@ -465,10 +472,37 @@ function handleChange(value) {
}
/**
* 选择药品回调
* 选择药品/诊疗项目回调
* 这里恢复为之前“能正常工作”的简单逻辑,只做最小必要的修正
*/
function selectAdviceBase(key, row) {
getOrgList();
if (!row) {
console.error('[selectAdviceBase] row 为空');
return;
}
// 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];
if (currentRow) {
currentRow.showPopover = false;
}
// 诊疗(adviceType=3) 才需要加载执行科室树,且只加载一次
if (row.adviceType === 3) {
ensureOrgTreeLoaded();
}
// 构建单位列表(保持原有逻辑)
unitCodeList.value = [];
unitCodeList.value.push({ value: row.unitCode, label: row.unitCode_dictText, type: 'unit' });
if (row.doseUnitCode != row.minUnitCode) {
@@ -488,10 +522,14 @@ function selectAdviceBase(key, row) {
type: 'minUnit',
});
}
// 将选中的基础项“覆盖”到当前处方行(这是之前正常工作的核心逻辑)
prescriptionList.value[rowIndex.value] = {
...prescriptionList.value[rowIndex.value],
...JSON.parse(JSON.stringify(row)),
};
// 后续字段处理保持原样
prescriptionList.value[rowIndex.value].orgId = undefined;
prescriptionList.value[rowIndex.value].dose = undefined;
prescriptionList.value[rowIndex.value].unitCodeList = unitCodeList.value;
@@ -500,12 +538,11 @@ function selectAdviceBase(key, row) {
prescriptionList.value[rowIndex.value].minUnitCode = JSON.parse(JSON.stringify(row.doseUnitCode));
prescriptionList.value[rowIndex.value].unitCode =
row.partAttributeEnum == 1 ? row.minUnitCode : row.unitCode;
// prescriptionList.value[rowIndex.value].doseUnitCode_dictText = row.minUnitCode_dictText;
prescriptionList.value[rowIndex.value].definitionId = JSON.parse(
JSON.stringify(row)
).chargeItemDefinitionId;
// 库存列表 + 价格列表拼成批次号的下拉框
// 库存列表 + 价格列表拼成批次号的下拉框(非诊疗)
if (row.adviceType != 3) {
if (row.inventoryList && row.inventoryList.length == 0) {
expandOrder.value = [];
@@ -532,9 +569,15 @@ function selectAdviceBase(key, row) {
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
}
} else {
// 诊疗:设置执行科室和价格
prescriptionList.value[rowIndex.value].orgId = JSON.parse(JSON.stringify(row)).positionId;
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
if (row.priceList && row.priceList.length > 0) {
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
} else {
prescriptionList.value[rowIndex.value].unitPrice = 0;
}
}
expandOrder.value = [key];
nextTick(() => {
if (row.adviceType == 1) {
@@ -549,11 +592,18 @@ function selectAdviceBase(key, row) {
});
}
function getOrgList() {
getOrgTree().then((res) => {
organization.value = res.data.records;
console.log(organization.value,"organization.value")
});
function ensureOrgTreeLoaded() {
if (orgTreeLoaded.value) return;
orgTreeLoaded.value = true;
getOrgTree()
.then((res) => {
// 组织机构树接口通常返回分页 records这里做兼容兜底
organization.value = res?.data?.records ?? res?.data ?? [];
})
.catch(() => {
// 加载失败时允许重试
orgTreeLoaded.value = false;
});
}
function handleDelete() {