修改媒体类型和区域新建子集不刷新问题

This commit is contained in:
wangchengming 2025-10-15 21:09:51 +08:00
parent 6e9c66c82d
commit 08cc123cb4
2 changed files with 131 additions and 62 deletions

View File

@ -162,7 +162,6 @@ const loadChildren = async (row, treeNode, resolve) => {
resolve(response.data);
} catch (error) {
console.error('加载子节点失败:', error);
resolve([]);
}
}
@ -242,7 +241,41 @@ const submitForm = () => {
}
} else {
//
getsysRegionTreeList(form.value.parentId || 0);
const parentId = form.value.parentId || 0;
if (parentId === '0' || parentId === 0) {
// -
getsysRegionTreeList();
} else {
// -
const parentRow = findRowById(parentId);
if (parentRow) {
//
queryParams.value.parentId = parentId;
sysRegionListByPid(queryParams.value).then(res => {
// 使 splice
if (!parentRow.childList) {
parentRow.childList = [];
}
parentRow.childList.splice(0, parentRow.childList.length, ...res.data);
parentRow.hasChildren = res.data && res.data.length > 0;
//
nextTick(() => {
//
tableRef.value?.toggleRowExpansion(parentRow, false);
setTimeout(() => {
tableRef.value?.toggleRowExpansion(parentRow, true);
tableRef.value?.doLayout();
}, 50);
});
});
} else {
//
getsysRegionTreeList();
}
}
}
//

View File

@ -161,7 +161,6 @@ const loadChildren = async (row, treeNode, resolve) => {
resolve(response.data);
} catch (error) {
console.error('加载子节点失败:', error);
resolve([]);
}
};
@ -240,7 +239,44 @@ const submitForm = () => {
}
} else {
//
getsysMediaTypeTreeList(form.value.parentId || 0);
const parentId = form.value.parentId || 0;
if (parentId === '0' || parentId === 0) {
// -
getsysMediaTypeTreeList();
} else {
// - 使
const parentRow = findRowById(parentId);
if (parentRow) {
// 1: 使
if (!parentRow.childList) {
//
parentRow.childList = [];
}
//
queryParams.value.parentId = parentId;
sysMediaTypeListByPid(queryParams.value).then(res => {
// 使 splice
parentRow.childList.splice(0, parentRow.childList.length, ...res.data);
parentRow.hasChildren = res.data && res.data.length > 0;
//
nextTick(() => {
//
tableRef.value?.toggleRowExpansion(parentRow, false);
setTimeout(() => {
tableRef.value?.toggleRowExpansion(parentRow, true);
tableRef.value?.doLayout();
}, 50);
});
});
} else {
//
getsysMediaTypeTreeList();
}
}
}
//