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) + }) +}