Compare commits

...

2 Commits

Author SHA1 Message Date
c5908f4376 refactor(credit): 移除后端标记字段并优化数据统计逻辑
- 删除了不再使用的 hasData 字段及其相关注释
- 移除了 normalizeHasData 工具函数
- 将总数统计逻辑改为基于后端返回的 count 字段或列表长度
- 更新了标签页数据检测逻辑为基于记录数判断
- 修正了标签页高亮显示的注释说明
2026-01-28 23:53:10 +08:00
f78aa97bd1 feat(credit): 为企业信用模块添加数据统计和标签高亮功能
- 在CreditCompany模型中新增多个信用相关记录数字段用于数据统计
- 实现标签页数据高亮显示功能,通过记录数判断标签是否有数据
- 添加tabCountFieldMap映射配置不同标签对应的记录数字段
- 实现syncTabsHasDataFromCounts方法同步标签数据状态
- 新增normalizeHasData方法规范化数据存在性判断逻辑
- 添加CSS样式实现有数据标签的红色高亮显示效果
- 更新开发环境API地址配置并移除注释标记
2026-01-28 23:45:27 +08:00
3 changed files with 124 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
VITE_APP_NAME=后台管理(开发环境)
#VITE_API_URL=http://127.0.0.1:9200/api
VITE_API_URL=http://127.0.0.1:9200/api
#VITE_SERVER_API_URL=http://127.0.0.1:8000/api

View File

@@ -108,6 +108,56 @@ export interface CreditCompany {
cechnologyLevel?: string;
// 是否小微企业
smallEnterprise?: string;
// 记录数
creditAdministrativeLicense?: number;
// 记录数
creditBankruptcy?: number;
// 记录数
creditBranch?: number;
// 记录数
creditBreachOfTrust?: number;
// 记录数
creditCaseFiling?: number;
// 记录数
creditCompetitor?: number;
// 记录数
creditCourtAnnouncement?: number;
// 记录数
creditCourtSession?: number;
// 记录数
creditCustomer?: number;
// 记录数
creditDeliveryNotice?: number;
// 记录数
creditExternal?: number;
// 记录数
creditFinalVersion?: number;
// 记录数
creditGqdj?: number;
// 记录数
creditHistoricalLegalPerson?: number;
// 记录数
creditJudgmentDebtor?: number;
// 记录数
creditJudicialDocument?: number;
// 记录数
creditJudiciary?: number;
// 记录数
creditMediation?: number;
// 记录数
creditNearbyCompany?: number;
// 记录数
creditPatent?: number;
// 记录数
creditRiskRelation?: number;
// 记录数
creditSupplier?: number;
// 记录数
creditSuspectedRelationship?: number;
// 记录数
creditUser?: number;
// 记录数
creditXgxf?: number;
// 备注
comments?: string;
// 是否推荐

View File

@@ -40,7 +40,16 @@
:tabBarGutter="9"
class="credit-company-tabs"
>
<a-tab-pane v-for="tab in tabList" :key="tab.key" :tab="tab.label">
<a-tab-pane v-for="tab in tabList" :key="tab.key">
<template #tab>
<span
:class="{
'credit-company-tab-has-data': tabHasData[tab.key]
}"
>
{{ tab.label }}
</span>
</template>
<a-space style="margin-bottom: 12px">
<a-button
type="primary"
@@ -272,6 +281,38 @@
{ key: '历史法定代表人', label: '历史法定代表人' }
];
/**
* 企业详情接口会下发各子表“记录数”(见 CreditCompany 模型中 `// 记录数` 字段)。
* 用这个来做 Tab 高亮,避免为了计算高亮去逐个请求所有子表接口。
*/
const tabCountFieldMap: Record<string, keyof CreditCompany> = {
招投标: 'creditUser',
对外投资: 'creditExternal',
风险关系: 'creditRiskRelation',
竞争对手: 'creditCompetitor',
供应商: 'creditSupplier',
客户: 'creditCustomer',
司法案件: 'creditJudiciary',
被执行人: 'creditJudgmentDebtor',
限制高消费: 'creditXgxf',
终本案件: 'creditFinalVersion',
开庭公告: 'creditCourtSession',
法院公告: 'creditCourtAnnouncement',
失信被执行人: 'creditBreachOfTrust',
裁判文书: 'creditJudicialDocument',
立案信息: 'creditCaseFiling',
诉前调解: 'creditMediation',
送达公告: 'creditDeliveryNotice',
股权冻结: 'creditGqdj',
附近企业: 'creditNearbyCompany',
分支机构: 'creditBranch',
破产重整: 'creditBankruptcy',
行政许可: 'creditAdministrativeLicense',
疑似关系: 'creditSuspectedRelationship',
专利: 'creditPatent',
历史法定代表人: 'creditHistoricalLegalPerson'
};
type TabApiConfig = {
page: (
params: any
@@ -1183,6 +1224,7 @@
};
const tabState = reactive<Record<string, TabState>>({});
const tabHasData = reactive<Record<string, boolean>>({});
tabList.forEach((tab) => {
tabState[tab.key] = {
loading: false,
@@ -1195,6 +1237,7 @@
},
loadedSignature: undefined
};
tabHasData[tab.key] = false;
});
const activeTab = ref(tabList[0].key);
@@ -1492,6 +1535,15 @@
tabState[tab.key].loading = false;
tabState[tab.key].loadedSignature = undefined;
resetTabPagination(tab.key);
tabHasData[tab.key] = false;
});
};
const syncTabsHasDataFromCounts = () => {
tabList.forEach((tab) => {
const field = tabCountFieldMap[tab.key];
const raw = (form as any)?.[field] ?? (props.data as any)?.[field] ?? 0;
tabHasData[tab.key] = Number(raw) > 0;
});
};
@@ -1536,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 });
@@ -1545,8 +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] = (state.pagination.total ?? 0) > 0;
if (!state.columns.length) {
state.columns = buildColumns(key, state.data);
}
@@ -1584,6 +1644,7 @@
assignObject(form, props.data);
}
activeTab.value = tabList[0].key;
syncTabsHasDataFromCounts();
loadTabData(activeTab.value, true);
} else {
showRelatedImport.value = false;
@@ -1604,7 +1665,16 @@
resetForm();
clearTabData();
assignObject(form, data);
syncTabsHasDataFromCounts();
loadTabData(activeTab.value, true);
}
);
</script>
<style scoped>
/* Tab label highlight when the module record-count field is > 0. */
.credit-company-tab-has-data {
color: #ff4d4f;
font-weight: 600;
}
</style>