fix(manager-web): 参数管理聚合支持分页拉全量并重置空态全选

按 total 循环拉取全部页,避免超过 500 条时缺数据;displaySections 为空时同步重置 isAllSelected。
This commit is contained in:
weirui 2026-08-18 10:19:39 +08:00
parent c55dc8282f
commit d76825fae5

View file

@ -364,6 +364,7 @@ export default {
const keys = sections.map(s => s.key); const keys = sections.map(s => s.key);
if (!keys.length) { if (!keys.length) {
this.activeCollapse = []; this.activeCollapse = [];
this.isAllSelected = false;
return; return;
} }
// 分组不多时全部展开;较多时默认展开前几组 // 分组不多时全部展开;较多时默认展开前几组
@ -504,37 +505,64 @@ export default {
this.filteredParams.forEach(row => { row.selected = false; }); this.filteredParams.forEach(row => { row.selected = false; });
this.syncSelectAllState(); this.syncSelectAllState();
}, },
fetchParams() { fetchParamsPage(page) {
this.loading = true; return new Promise((resolve, reject) => {
Api.admin.getParamsList( Api.admin.getParamsList(
{ {
page: 1, page,
limit: FETCH_LIMIT, limit: FETCH_LIMIT,
paramCode: "" paramCode: ""
}, },
({ data }) => { ({ data }) => {
this.loading = false;
if (data.code === 0) { if (data.code === 0) {
this.allParams = (data.data.list || []).map(item => ({ resolve(data.data || {});
} else {
reject(new Error(data.msg || this.$t('paramManagement.getParamsListFailed')));
}
}
);
});
},
async fetchParams() {
this.loading = true;
try {
const collected = [];
let page = 1;
let total = Infinity;
// 按 total 循环拉全部分页,避免超过 FETCH_LIMIT 时聚合视图缺数据
while (collected.length < total) {
const pageData = await this.fetchParamsPage(page);
const list = pageData.list || [];
total = typeof pageData.total === 'number' ? pageData.total : collected.length + list.length;
collected.push(...list);
if (!list.length) break;
page += 1;
// 防御:异常 total / 接口异常时避免死循环
if (page > 200) break;
}
this.allParams = collected.map(item => ({
...item, ...item,
valueType: item.valueType || "string", valueType: item.valueType || "string",
selected: false, selected: false,
showValue: false showValue: false
})); }));
this.isAllSelected = false;
// 若当前分类已无数据,回退到全部 // 若当前分类已无数据,回退到全部
const exists = this.categoryTabs.some(t => t.key === this.activeCategory); const exists = this.categoryTabs.some(t => t.key === this.activeCategory);
if (!exists) { if (!exists) {
this.activeCategory = 'all'; this.activeCategory = 'all';
this.activeSubCategory = 'all'; this.activeSubCategory = 'all';
} }
} else { } catch (err) {
this.$message.error({ this.$message.error({
message: data.msg || this.$t('paramManagement.getParamsListFailed'), message: (err && err.message) || this.$t('paramManagement.getParamsListFailed'),
showClose: true showClose: true
}); });
} finally {
this.loading = false;
} }
}
);
}, },
handleSearch() { handleSearch() {
this.appliedSearch = this.searchCode; this.appliedSearch = this.searchCode;