Fix Bug #408: 门诊医生站:检查标签页:选中检查申请记录后,"检查明细"标签页显示"暂无数据"
根因:handleRowClick 中 const resp = res.data || res 对 Axios 拦截器已解包的响应 进行二次解包,导致 resp 被赋为 ExamApply 实体对象(不含 items),后续 items 提取 逻辑始终返回空数组,明细列表无法加载。 修复:用 res.code !== undefined 判定 res 是否已是 AjaxResult 体,若是则直接使用, 否则再执行 res.data 解包。items 和数据提取统一从正确层级取值,避免二次解包。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1136,17 +1136,19 @@ function handleRowClick(row) {
|
||||
selectedItems.value = [];
|
||||
activeDetailTab.value = 'applyForm';
|
||||
request({ url: `/exam/apply/${row.applyNo}`, method: 'get' }).then(async res => {
|
||||
const resp = res.data || res;
|
||||
// Bug #408修复: items 在 AjaxResult 顶层(res.items / resp.items),不在 ExamApply 对象内
|
||||
// 防御性提取:优先取顶层 items,兼容嵌套在 resp.data.items 的情况
|
||||
let rawItems = res.items || resp.items;
|
||||
if (!rawItems && resp.data && typeof resp.data === 'object') {
|
||||
rawItems = resp.data.items;
|
||||
}
|
||||
rawItems = rawItems || [];
|
||||
const d = resp.data || resp;
|
||||
if (d) Object.assign(form, d);
|
||||
if (Array.isArray(rawItems) && rawItems.length > 0) {
|
||||
// 响应结构判定:Axios拦截器对 code===200 返回 res.data(AjaxResult体),
|
||||
// 但某些情况下可能返回完整 Axios 响应 {data: AjaxResult}。
|
||||
// 用 res.code 判定是否已是 AjaxResult 体,避免二次解包导致 items 丢失。
|
||||
const isAjaxResult = res && typeof res === 'object' && res.code !== undefined;
|
||||
const ajaxBody = isAjaxResult ? res : (res.data || res);
|
||||
|
||||
// items 在 AjaxResult 顶层,data 字段是 ExamApply 实体
|
||||
const rawItems = Array.isArray(ajaxBody.items) ? ajaxBody.items : [];
|
||||
const detailData = ajaxBody.data || {};
|
||||
|
||||
if (detailData && typeof detailData === 'object') Object.assign(form, detailData);
|
||||
|
||||
if (rawItems.length > 0) {
|
||||
try {
|
||||
// 为每个项目加载检查方法
|
||||
const itemsWithMethods = await Promise.all(rawItems.map(async m => {
|
||||
|
||||
Reference in New Issue
Block a user