diff --git a/web/.env.development b/web/.env.development index f7bcb53..176b8ec 100644 --- a/web/.env.development +++ b/web/.env.development @@ -2,8 +2,8 @@ ENV = 'development' # 本地环境接口地址 -VITE_API_URL = 'https://demo.dvadmin.com/api' -#VITE_API_URL = 'http://192.168.1.160:8000' +#VITE_API_URL = 'https://demo.dvadmin.com/api' +VITE_API_URL = 'http://192.168.1.160:8002' # 是否启用按钮权限 VITE_PM_ENABLED = true 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();