From 720fe95797f30d76146972647aa73df61909c205 Mon Sep 17 00:00:00 2001 From: zhaojiangbing <1846027296@qq.com> Date: Sun, 15 Dec 2024 23:54:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20menu=E7=9B=B8=E5=85=B3=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=8C=B9=E9=85=8D=E4=BB=A5=E5=8F=8A=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/menu/index.vue | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index 174ad44..3320fe6 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -40,11 +40,14 @@ :data="editData!" @updateEdit="handleUpdateEdit" /> - 从菜单列表选择一项后,进行编辑 + + 从菜单列表选择一项后,进行编辑 - + - + @@ -71,16 +74,11 @@ const handleUpdateEdit = async (data: Partial) => { } // 拖拽节点 const allowDrag = (draggingNode: Node) => { - return ( - draggingNode.data.parent_id !== 0 || draggingNode.data.parent_id != null - ) + return draggingNode.data.parentId !== 0 || draggingNode.data.parentId != null } type DropType = 'prev' | 'inner' | 'next' const allowDrop = (draggingNode: Node, dropNode: Node, type: DropType) => { - if ( - draggingNode.data.parent_id === 0 || - draggingNode.data.parent_id == null - ) { + if (draggingNode.data.parentId === 0 || draggingNode.data.parentId == null) { return type !== 'inner' } } @@ -129,15 +127,15 @@ const resetStatus = () => { const genMenuSortId = (list: ITreeItemData[]) => { if (list && list.length) { - return list[list.length - 1].sort_id + 1 + return list[list.length - 1].sortId + 1 } return 0 } const handleAddRootMenu = async (data: MenuData) => { - // parent_id , sord_id - data.parent_id = 0 - data.sort_id = genMenuSortId(menus.value) // 根节点是根据 所有的父节点来计算的, 儿子是根据爸爸有几个儿子来算的 + // parentId , sord_id + data.parentId = 0 + data.sortId = genMenuSortId(menus.value) // 根节点是根据 所有的父节点来计算的, 儿子是根据爸爸有几个儿子来算的 let res = await store.appendMenu(data) if (res) { proxy?.$message.success('根菜单添加成功了') @@ -149,8 +147,8 @@ const genChild = (data: MenuData) => { if (!parent.children) { parent.children = [] } - data.sort_id = genMenuSortId(parent.children) - data.parent_id = parent.id + data.sortId = genMenuSortId(parent.children) + data.parentId = parent.id return data } const handleChildRootMenu = async (data: MenuData) => { From 751ef1be0dbbe0d2031d1748d51e626f79e9e986 Mon Sep 17 00:00:00 2001 From: zjb Date: Mon, 16 Dec 2024 14:05:03 +0800 Subject: [PATCH 2/3] feat: patch update menu --- src/apis/menu.ts | 2 +- src/stores/menu.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apis/menu.ts b/src/apis/menu.ts index eb6839f..9f9b948 100644 --- a/src/apis/menu.ts +++ b/src/apis/menu.ts @@ -40,5 +40,5 @@ export const updateMenuById = ( * @returns */ export const updateBulkMenu = (data: Partial[]): Promise => { - return request.patch('/menu/update', { access: data }) + return request.patch('/menu', { access: data }) } diff --git a/src/stores/menu.ts b/src/stores/menu.ts index 2b3ef15..27fe573 100644 --- a/src/stores/menu.ts +++ b/src/stores/menu.ts @@ -57,7 +57,7 @@ export const useMenuStore = defineStore('menu', () => { const updateBulkMenu = async () => { // 1.更新sortId - state.menuTreeData.forEach((menu, idx) => (menu.sort_id = idx)) + state.menuTreeData.forEach((menu, idx) => (menu.sortId = idx)) // 2.删除子节点 const menus = state.menuTreeData.map((menu) => { const temp = { ...menu } From 380838d0e12ec7676b09432b09f17b9f696e8d7c Mon Sep 17 00:00:00 2001 From: zhaojiangbing <1846027296@qq.com> Date: Mon, 16 Dec 2024 22:07:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E8=A7=92=E8=89=B2=E5=88=86?= =?UTF-8?q?=E9=85=8D=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 1 + src/views/system/role/components/roleMenu.vue | 124 ++++++++---------- 2 files changed, 58 insertions(+), 67 deletions(-) diff --git a/components.d.ts b/components.d.ts index cce62eb..a21c513 100644 --- a/components.d.ts +++ b/components.d.ts @@ -20,6 +20,7 @@ declare module 'vue' { ElCard: typeof import('element-plus/es')['ElCard'] ElCol: typeof import('element-plus/es')['ElCol'] ElContainer: typeof import('element-plus/es')['ElContainer'] + ElDialog: typeof import('element-plus/es')['ElDialog'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] diff --git a/src/views/system/role/components/roleMenu.vue b/src/views/system/role/components/roleMenu.vue index b59d1d1..432e00b 100644 --- a/src/views/system/role/components/roleMenu.vue +++ b/src/views/system/role/components/roleMenu.vue @@ -1,4 +1,4 @@ - - - - - - - +