fix(components): 菜单管理调整

This commit is contained in:
2026-03-27 14:03:42 +08:00
parent 120a5b4dfd
commit ca3d697941
9 changed files with 11075 additions and 103 deletions

View File

@@ -346,10 +346,6 @@ const pageResourceOptions = pageResourceItems.map(item => ({
const selectedPageResource = computed(() => pageResourceMap.get(model.value.pageResourcePath) ?? null);
const displayRoutePath = computed(() => {
if (selectedPageResource.value) {
return selectedPageResource.value.path;
}
return joinRoutePaths(currentParentFullPath.value, model.value.path);
});
@@ -357,14 +353,6 @@ const hasCompatibleViewRouteData = computed(() =>
Boolean(getNullableText(model.value.component) && getNullableText(model.value.path))
);
const isSelectedPageResourceCompatible = computed(() => {
if (!selectedPageResource.value) {
return false;
}
return Boolean(getRelativeRoutePath(selectedPageResource.value.path, currentParentFullPath.value));
});
const rules = computed(() => {
const pathRule: RuleFormItem = {
message: $t('page.system.menu.form.path'),
@@ -403,11 +391,6 @@ const rules = computed(() => {
return;
}
if (!isSelectedPageResourceCompatible.value) {
callback(new Error($t('page.system.menu.form.pageResourceParentMismatch')));
return;
}
callback();
}
};
@@ -569,14 +552,16 @@ const parentTreeOptions = computed<ParentTreeOption[]>(() => {
];
});
function filterParentTreeNode(value: string, data: ParentTreeOption) {
function filterParentTreeNode(value: string, data: { label?: string }) {
const keyword = value.trim().toLowerCase();
if (!keyword) {
return true;
}
return data.label.toLowerCase().includes(keyword);
return String(data.label ?? '')
.toLowerCase()
.includes(keyword);
}
function closeModal() {
@@ -642,7 +627,13 @@ function syncViewRouteFields() {
return;
}
model.value.path = getRelativeRoutePath(pageResource.path, currentParentFullPath.value);
const nextRelativePath =
getRelativeRoutePath(pageResource.path, currentParentFullPath.value) ||
normalizeRoutePart(model.value.path) ||
normalizeRoutePart(pageResource.path).split('/').filter(Boolean).at(-1) ||
'';
model.value.path = nextRelativePath;
model.value.component = pageResource.component;
model.value.componentName = pageResource.name;
model.value.routePropsJson = stringifyRouteProps(pageResource.props as Record<string, unknown> | null);
@@ -867,8 +858,11 @@ watch(
watch(
() => model.value.parentId,
() => {
async () => {
syncCurrentRouteFields();
await nextTick();
clearFormValidation();
}
);