From 941dbbc783aa61580b762c38866729e47f455089 Mon Sep 17 00:00:00 2001 From: sheng <15292050171@163.com> Date: Wed, 26 Jul 2023 18:12:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=88=97=E8=A1=A8=E4=B8=8A=E7=A7=BB=E4=B8=8B?= =?UTF-8?q?=E7=A7=BB=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/menu/index.vue | 35 ++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 96203c8..8e3c783 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -49,13 +49,13 @@ - + - + @@ -160,6 +160,7 @@ const ElementTreeLine = getElementLabelLine(h); const filterText = ref(''); const treeRef = ref>(); let drawerVisible = ref(false) +let treeSelectNode = ref(null) watch(filterText, (val) => { treeRef.value!.filter(val); @@ -315,12 +316,13 @@ const addChildMenu = () => { handleDrawerClose(); }; -const handleNodeClick = (data: any) => { +const handleNodeClick = (record: any, node: Node) => { + treeSelectNode.value = node; Object.keys(toRaw(data)).forEach((key: string) => { - form[key] = data[key]; + form[key] = record[key]; }); delete form.component_name; - form.id = data.id; + form.id = record.id; isAddNewMenu.value = false; }; @@ -367,6 +369,29 @@ const handleDeleteMenu = () => { }) }; +/** + * 移动操作 + */ +const handleSort = (type: string) => { + if (!form.id && treeSelectNode.value) { + warningMessage('请选择菜单!') + return + } + const parentList = treeSelectNode.value?.parent.childNodes || []; + const index = parentList.findIndex(i => i.data.id === form.id) + const record = parentList.find(i => i.data.id === form.id) + + if (type === 'up') { + if (index === 0) return + parentList.splice(index - 1, 0, record as any) + parentList.splice(index + 1, 1) + } + if (type === 'down') { + parentList.splice(index + 2, 0, record as any) + parentList.splice(index, 1) + } +} + // 页面打开后获取列表数据 onMounted(() => { getData();