诊疗下面没有项目的代码冲突
This commit is contained in:
@@ -99,17 +99,48 @@ watch(
|
||||
|
||||
// 移除组件初始化时的 getList() 调用,避免在没有 adviceType 时查询所有类型的数据
|
||||
// getList();
|
||||
async function getList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
// 统一调用 getAdviceBaseInfo,因为后端在这个接口里实现了库存和价格查询
|
||||
const res = await getAdviceBaseInfo(props.adviceQueryParams);
|
||||
adviceBaseList.value = res.data?.records || [];
|
||||
} catch (error) {
|
||||
console.error('获取医嘱列表失败:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
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) => {
|
||||
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]);
|
||||
}
|
||||
});
|
||||
}).catch((err) => {
|
||||
console.error('[adviceBaseList] getList() 请求失败:', err);
|
||||
adviceBaseList.value = [];
|
||||
total.value = 0;
|
||||
});
|
||||
}
|
||||
|
||||
// 处理键盘事件
|
||||
|
||||
Reference in New Issue
Block a user