优化分类树加载逻辑,新增批量查询子节点接口以减少数据库往返,提升性能。重构相关服务和控制器,确保系统的可维护性和扩展性。

This commit is contained in:
geht
2026-05-15 09:58:30 +08:00
parent bc1de2c765
commit ffc390f3de
8 changed files with 85 additions and 13 deletions

View File

@@ -294,9 +294,8 @@
async function loadCategoryTree() {
treeLoading.value = true;
try {
const root = await fetchWarehouseCategoryRoot();
const [root, res] = await Promise.all([fetchWarehouseCategoryRoot(), loadCategoryTreeRoot({ async: false, pcode: 'XSLMES_WH' })]);
warehouseCategoryRootId.value = root?.id != null ? String(root.id) : '';
const res = await loadCategoryTreeRoot({ async: false, pcode: 'XSLMES_WH' });
rawWarehouseCategoryTree.value = Array.isArray(res) ? res : [];
if (!warehouseCategoryRootId.value || !rawWarehouseCategoryTree.value.length) {
createMessage.warning('未加载到仓库分类树,请确认已执行库脚本并已在「分类字典」中维护根节点 XSLMES_WH。');
@@ -385,6 +384,8 @@
title: '仓库管理',
api: list,
columns,
// 避免:表格默认 immediate 请求一次 + onMounted 末尾 reload 再请求一次(进入页列表闪两次)
immediate: false,
canResize: true,
formConfig: {
schemas: searchFormSchema,