诊疗下面没有诊疗项目

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

@@ -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({