From 4fb256f3289b84bc2526a15608973fa9f2c66f1d Mon Sep 17 00:00:00 2001 From: zc <2064281269@qq.com> Date: Sun, 26 Oct 2025 10:28:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B1=9E=E6=80=A7=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/menuList.ts | 18 +++ src/views/goods/appCategory/index.vue | 169 ++++++++++++++++++++++++ src/views/goods/appCategory/mock.ts | 56 ++++++++ src/views/goods/appCategory/use-drag.ts | 24 ++++ 4 files changed, 267 insertions(+) create mode 100644 src/views/goods/appCategory/index.vue create mode 100644 src/views/goods/appCategory/mock.ts create mode 100644 src/views/goods/appCategory/use-drag.ts diff --git a/src/config/menuList.ts b/src/config/menuList.ts index 75a59d9..c0f01e6 100644 --- a/src/config/menuList.ts +++ b/src/config/menuList.ts @@ -69,6 +69,24 @@ export default [ modifyTime: '2025-06-20 09:53:53', tag: null, childList: [] + }, + { + id: 127, + resourceName: 'app类目管理', + resourceType: 1, + resourceCode: null, + path: '/goods/appCategory/index', + pid: 37, + resourceDesc: null, + tenantId: 2, + icon: '', + isCache: 1, + visible: 0, + sort: '3', + createTime: '2025-06-20 09:52:12', + modifyTime: '2025-06-20 09:53:53', + tag: null, + childList: [] } /* { id: 127, diff --git a/src/views/goods/appCategory/index.vue b/src/views/goods/appCategory/index.vue new file mode 100644 index 0000000..05be915 --- /dev/null +++ b/src/views/goods/appCategory/index.vue @@ -0,0 +1,169 @@ + + + + + diff --git a/src/views/goods/appCategory/mock.ts b/src/views/goods/appCategory/mock.ts new file mode 100644 index 0000000..f169cfb --- /dev/null +++ b/src/views/goods/appCategory/mock.ts @@ -0,0 +1,56 @@ +interface Tree { + id: number + label: string + children?: Tree[] +} + +export const dataSource = ref([ + { + id: 1, + label: 'Level one 1', + children: [ + { + id: 4, + label: 'Level two 1-1', + children: [ + { + id: 9, + label: 'Level three 1-1-1' + }, + { + id: 10, + label: 'Level three 1-1-2' + } + ] + } + ] + }, + { + id: 2, + label: 'Level one 2', + children: [ + { + id: 5, + label: 'Level two 2-1' + }, + { + id: 6, + label: 'Level two 2-2' + } + ] + }, + { + id: 3, + label: 'Level one 3', + children: [ + { + id: 7, + label: 'Level two 3-1' + }, + { + id: 8, + label: 'Level two 3-2' + } + ] + } +]) diff --git a/src/views/goods/appCategory/use-drag.ts b/src/views/goods/appCategory/use-drag.ts new file mode 100644 index 0000000..cdada0f --- /dev/null +++ b/src/views/goods/appCategory/use-drag.ts @@ -0,0 +1,24 @@ +import type { NodeDropType, RenderContentContext } from 'element-plus' + +type Node = RenderContentContext['node'] + +// 开始拖拽 +export const handleDragStart = (node: Node) => { + console.log('drag start', node) +} +// 拖拽成功完成时触发的事件 + +export const handleDropFinish = (draggingNode: Node, dropNode: Node, dropType: NodeDropType) => { + // 获取拖拽之后最新的ids + const getSortIds = () => { + const parentNode = dropType === 'inner' ? dropNode : dropNode.parent // 获取父节点 + if (!parentNode || !parentNode.childNodes) return [] + return parentNode.childNodes.map((node) => node.data.id) + } + // 获取拖拽到的位置索引 + const sortIds = getSortIds() + if (!sortIds.length) return + api.commodity.sortCategory.post!({ categoryIds: sortIds }).then(() => { + console.log('tree drop:', draggingNode, dropNode.label, dropType) + }) +}