fix: 移除 refreshBusinessStatus 死代码,消除 N+1 无效请求
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ enum Api {
|
|||||||
deletePendingTask = '/tasktask/taskTask/deletePendingTask',
|
deletePendingTask = '/tasktask/taskTask/deletePendingTask',
|
||||||
updateTitleAndDeadline = '/tasktask/taskTask/updateTitleAndDeadline',
|
updateTitleAndDeadline = '/tasktask/taskTask/updateTitleAndDeadline',
|
||||||
currentNodeInfo = '/act/task/currentNodeInfo',
|
currentNodeInfo = '/act/task/currentNodeInfo',
|
||||||
getBusinessStatus = '/tasktask/taskTask/getBusinessStatus',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,11 +210,6 @@ export const updateTitleAndDeadline = (params) => {
|
|||||||
*/
|
*/
|
||||||
export const queryCurrentNodeInfo = (params) => defHttp.get({ url: Api.currentNodeInfo, params });
|
export const queryCurrentNodeInfo = (params) => defHttp.get({ url: Api.currentNodeInfo, params });
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务状态(单条)
|
|
||||||
* @param params { businessId: string }
|
|
||||||
*/
|
|
||||||
export const getBusinessStatus = (params) => defHttp.get({ url: Api.getBusinessStatus, params });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【用于评论功能】自定义文件上传-方法
|
* 【用于评论功能】自定义文件上传-方法
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
import { defHttp } from '/@/utils/http/axios';
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { showImportValidationErrors } from '/@/utils/helper/importError';
|
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 { dateUtil } from '/@/utils/dateUtil';
|
||||||
|
|
||||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
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) {
|
if (result && result.length > 0) {
|
||||||
record.children = getDataByResult(result);
|
record.children = getDataByResult(result);
|
||||||
await refreshFeedbackCounts(record.children);
|
await refreshFeedbackCounts(record.children);
|
||||||
await refreshBusinessStatus(record.children);
|
|
||||||
// 触发表格重新渲染
|
// 触发表格重新渲染
|
||||||
updateTableDataRecord(record.id, { ...record });
|
updateTableDataRecord(record.id, { ...record });
|
||||||
} else {
|
} 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();
|
getDataByResult(result.items) && loadDataByExpandedRows();
|
||||||
if (result.items && result.items.length > 0) {
|
if (result.items && result.items.length > 0) {
|
||||||
await refreshFeedbackCounts(result.items);
|
await refreshFeedbackCounts(result.items);
|
||||||
await refreshBusinessStatus(result.items);
|
// 触发表格重新渲染以显示更新后的 implCount / closedCount
|
||||||
// 触发表格重新渲染以显示更新后的 implCount / closedCount / businessStatus
|
|
||||||
setTableData([...getDataSource()]);
|
setTableData([...getDataSource()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@
|
|||||||
import Icon from '/@/components/Icon/index';
|
import Icon from '/@/components/Icon/index';
|
||||||
import SzSelectDept from '/@/components/Form/src/jeecg/components/SzSelectDept.vue';
|
import SzSelectDept from '/@/components/Form/src/jeecg/components/SzSelectDept.vue';
|
||||||
import SzDeptUserModal from '/@/components/semri/deptUserComponent/SzDeptUserModal.vue';
|
import SzDeptUserModal from '/@/components/semri/deptUserComponent/SzDeptUserModal.vue';
|
||||||
import { startProcessSchedules, getBusinessStatus } from '/@/api/common/api';
|
import { startProcessSchedules } from '/@/api/common/api';
|
||||||
import { dateUtil } from '/@/utils/dateUtil';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
import FlowScheduleStartModal from './components/DqInspectTaskFlowScheduleStartModal.vue';
|
import FlowScheduleStartModal from './components/DqInspectTaskFlowScheduleStartModal.vue';
|
||||||
import BusinessProcessListModal from '/src/components/semri/process/BusinessProcessListModal.vue';
|
import BusinessProcessListModal from '/src/components/semri/process/BusinessProcessListModal.vue';
|
||||||
@@ -610,30 +610,8 @@
|
|||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshBusinessStatus(records) {
|
|
||||||
if (!records || records.length === 0) return;
|
|
||||||
try {
|
|
||||||
const results = await Promise.all(records.map((item) => getBusinessStatus({ businessId: item.id }).catch(() => null)));
|
|
||||||
const statusMap: Record<string, string> = {};
|
|
||||||
for (const item of results) {
|
|
||||||
if (item?.businessId) {
|
|
||||||
statusMap[item.businessId] = item.status_dictText || '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const item of records) {
|
|
||||||
const status = statusMap[item.id];
|
|
||||||
if (status !== undefined) {
|
|
||||||
item.status_dictText = status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// 静默处理查询异常
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onFetchSuccess(result) {
|
async function onFetchSuccess(result) {
|
||||||
if (result?.items?.length > 0) {
|
if (result?.items?.length > 0) {
|
||||||
await refreshBusinessStatus(result.items);
|
|
||||||
setTableData([...getDataSource()]);
|
setTableData([...getDataSource()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user