fix: 移除 refreshBusinessStatus 死代码,消除 N+1 无效请求

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wsm
2026-07-16 09:11:45 +08:00
co-authored by Claude Opus 4.7
parent 6432395d36
commit 4dd45eeab0
3 changed files with 4 additions and 67 deletions
+2 -38
View File
@@ -118,7 +118,7 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { showImportValidationErrors } from '/@/utils/helper/importError';
import { startProcessSchedules, getBusinessStatus } from '/@/api/common/api';
import { startProcessSchedules } from '/@/api/common/api';
import { dateUtil } from '/@/utils/dateUtil';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
@@ -360,7 +360,6 @@ import { defHttp } from '/@/utils/http/axios';
if (result && result.length > 0) {
record.children = getDataByResult(result);
await refreshFeedbackCounts(record.children);
await refreshBusinessStatus(record.children);
// 触发表格重新渲染
updateTableDataRecord(record.id, { ...record });
} else {
@@ -443,40 +442,6 @@ import { defHttp } from '/@/utils/http/axios';
}
}
/**
* 批量查询业务状态并更新到 records 中
*/
async function refreshBusinessStatus(records) {
const ids = collectAllIds(records);
if (ids.length === 0) return;
try {
const results = await Promise.all(
ids.map((id) =>
getBusinessStatus({ businessId: id }).catch(() => null)
)
);
const statusMap: Record<string, string> = {};
for (const item of results) {
if (item?.businessId) {
statusMap[item.businessId] = item.status_dictText || '';
}
}
const updateFn = (list) => {
if (!list) return;
for (const item of list) {
const status = statusMap[item.id];
if (status !== undefined) {
item.status_dictText = status;
}
if (item.children) updateFn(item.children);
}
};
updateFn(records);
} catch (e) {
// 静默处理查询异常
}
}
/**
* 接口请求成功后回调
*/
@@ -484,8 +449,7 @@ import { defHttp } from '/@/utils/http/axios';
getDataByResult(result.items) && loadDataByExpandedRows();
if (result.items && result.items.length > 0) {
await refreshFeedbackCounts(result.items);
await refreshBusinessStatus(result.items);
// 触发表格重新渲染以显示更新后的 implCount / closedCount / businessStatus
// 触发表格重新渲染以显示更新后的 implCount / closedCount
setTableData([...getDataSource()]);
}
}