From 5758b8019083321de93c7c97e705d3bf932d0d47 Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Tue, 26 Nov 2024 23:39:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E6=96=B0=E5=A2=9E=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=A1=B6=E7=BA=A7=E8=8F=9C=E5=8D=95=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/menu.ts | 8 ++++---- src/views/system/menu/index.vue | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/api/system/menu.ts b/src/api/system/menu.ts index e7ff8495..a3d9b639 100644 --- a/src/api/system/menu.ts +++ b/src/api/system/menu.ts @@ -49,7 +49,7 @@ const MenuAPI = { * * @param id 菜单ID */ - getFormData(id: number) { + getFormData(id: string) { return request({ url: `${MENU_BASE_URL}/${id}/form`, method: "get", @@ -118,11 +118,11 @@ export interface MenuVO { /** ICON */ icon?: string; /** 菜单ID */ - id?: number; + id?: string; /** 菜单名称 */ name?: string; /** 父菜单ID */ - parentId?: number; + parentId?: string; /** 按钮权限标识 */ perm?: string; /** 跳转路径 */ @@ -144,7 +144,7 @@ export interface MenuForm { /** 菜单ID */ id?: string; /** 父菜单ID */ - parentId?: number; + parentId?: string; /** 菜单名称 */ name?: string; /** 菜单是否可见(1-是 0-否) */ diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index b06202f3..9a96e710 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -23,7 +23,7 @@ v-hasPerm="['sys:menu:add']" type="success" icon="plus" - @click="handleOpenDialog(0)" + @click="handleOpenDialog('0')" > 新增 @@ -357,7 +357,7 @@ const menuOptions = ref([]); // 初始菜单表单数据 const initialMenuFormData = ref({ id: undefined, - parentId: 0, + parentId: "0", visible: 1, sort: 1, type: MenuTypeEnum.MENU, // 默认菜单 @@ -379,7 +379,7 @@ const rules = reactive({ }); // 选择表格的行菜单ID -const selectedMenuId = ref(); +const selectedMenuId = ref(); // 查询菜单 function handleQuery() { @@ -401,7 +401,6 @@ function handleResetQuery() { // 行点击事件 function handleRowClick(row: MenuVO) { - // 记录表格选择的菜单ID,新增子菜单作为父菜单ID selectedMenuId.value = row.id; } @@ -411,10 +410,10 @@ function handleRowClick(row: MenuVO) { * @param parentId 父菜单ID * @param menuId 菜单ID */ -function handleOpenDialog(parentId?: number, menuId?: number) { +function handleOpenDialog(parentId?: string, menuId?: string) { MenuAPI.getOptions(true) .then((data) => { - menuOptions.value = [{ value: 0, label: "顶级菜单", children: data }]; + menuOptions.value = [{ value: "0", label: "顶级菜单", children: data }]; }) .then(() => { dialog.visible = true; @@ -501,12 +500,16 @@ function handleDelete(menuId: number) { ); } +function resetRorm() { + menuFormRef.value.resetFields(); + menuFormRef.value.clearValidate(); + formData.value = { ...initialMenuFormData.value }; +} + // 关闭弹窗 function handleCloseDialog() { dialog.visible = false; - menuFormRef.value.resetFields(); - menuFormRef.value.clearValidate(); - formData.value.id = undefined; + resetRorm(); } onMounted(() => {