From c5908f4376714a1e5cfabf86c60403937979da8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 28 Jan 2026 23:53:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor(credit):=20=E7=A7=BB=E9=99=A4=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E6=A0=87=E8=AE=B0=E5=AD=97=E6=AE=B5=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了不再使用的 hasData 字段及其相关注释 - 移除了 normalizeHasData 工具函数 - 将总数统计逻辑改为基于后端返回的 count 字段或列表长度 - 更新了标签页数据检测逻辑为基于记录数判断 - 修正了标签页高亮显示的注释说明 --- .../components/creditCompanyInfo.vue | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/views/credit/creditCompany/components/creditCompanyInfo.vue b/src/views/credit/creditCompany/components/creditCompanyInfo.vue index 89ed995..ce058df 100644 --- a/src/views/credit/creditCompany/components/creditCompanyInfo.vue +++ b/src/views/credit/creditCompany/components/creditCompanyInfo.vue @@ -477,9 +477,7 @@ 'recommend', 'url', 'comments', - 'companyId', - // Backend flag; do not show in tables. - 'hasData' + 'companyId' ]); const commonTitleMap: Record = { @@ -1541,20 +1539,6 @@ }); }; - const normalizeHasData = ( - res: any, - list: Record[], - total: number - ) => { - const hasDataRaw = - res?.hasData ?? (list.length ? (list[0] as any)?.hasData : undefined); - return ( - Number(hasDataRaw) === 1 || - list.some((row) => Number((row as any)?.hasData) === 1) || - (total ?? 0) > 0 - ); - }; - const syncTabsHasDataFromCounts = () => { tabList.forEach((tab) => { const field = tabCountFieldMap[tab.key]; @@ -1604,8 +1588,9 @@ const requestedPage = state.pagination.current; let res = await fetchPage(requestedPage); - const total = res?.count ?? 0; let list = res?.list || []; + const total = + typeof (res as any)?.count === 'number' ? (res as any).count : list.length; if (total > 0 && list.length === 0 && requestedPage > 1) { setTabPagination(key, { current: 1 }); @@ -1613,14 +1598,15 @@ list = res?.list || []; } - state.pagination.total = res?.count ?? 0; + state.pagination.total = + typeof (res as any)?.count === 'number' ? (res as any).count : list.length; // Keep the count field in sync (only when backend returns a count), so Tab highlight can update after import/refresh. const countField = tabCountFieldMap[key]; if (countField && typeof (res as any)?.count === 'number') { (form as any)[countField] = (res as any).count; } state.data = list; - tabHasData[key] = normalizeHasData(res as any, list, state.pagination.total); + tabHasData[key] = (state.pagination.total ?? 0) > 0; if (!state.columns.length) { state.columns = buildColumns(key, state.data); } @@ -1686,7 +1672,7 @@