From a2afd0a7877bf5d7f2dce65197e1b888f747321d Mon Sep 17 00:00:00 2001 From: yzl Date: Tue, 10 Mar 2026 23:41:47 +0800 Subject: [PATCH] change --- src/components/common/Dialog.vue | 3 ++- src/views/system/menuManagement/index.vue | 32 ++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/components/common/Dialog.vue b/src/components/common/Dialog.vue index 37af04b..ba14d54 100644 --- a/src/components/common/Dialog.vue +++ b/src/components/common/Dialog.vue @@ -21,6 +21,7 @@ interface Props { title: string width?: string | number destroyOnClose?: boolean + type?: string } interface Emits { @@ -31,7 +32,7 @@ interface Emits { } const props = withDefaults(defineProps(), { - width: '400px', + width: '600px', destroyOnClose: true, }) diff --git a/src/views/system/menuManagement/index.vue b/src/views/system/menuManagement/index.vue index 2928ad7..1925a57 100644 --- a/src/views/system/menuManagement/index.vue +++ b/src/views/system/menuManagement/index.vue @@ -33,7 +33,7 @@ - @@ -50,7 +50,7 @@ import MenuForm from '@/components/common/Form.vue' import { MenuTableColumns, MenuiconOptions, menuiconMap, MenuFormItemOptions } from './options' import { rules } from './rules' -import { getMenuApi } from '@/api/modules/menu' +import { getMenuApi,createMenuApi,editMenuApi,deleteMenuApi } from '@/api/modules/menu' // 定义header配置 const menuTitle = ref('菜单管理') const menuHeaderButtons = [ @@ -64,6 +64,7 @@ const treeProps = { children: 'son' } // 定义弹窗配置 const dialogVisible = ref(false) const dialogTitle = ref('') +const dialogType = ref('add') // 定义菜单表单数据 const menuForm = ref({ @@ -90,15 +91,12 @@ const menuFormOptionsMap = ref({ ] }) - - /** @description: 新增菜单 **/ const handleAddMenu = () => { dialogVisible.value = true dialogTitle.value = '新增菜单' - console.log('新增菜单') } /** @@ -139,6 +137,10 @@ onMounted(async () => { const handleEditMenu = (row: any) => { dialogVisible.value = true dialogTitle.value = '编辑菜单' + dialogType.value = 'edit' + menuForm.value = { ...row, + parentName: row.name + } console.log('编辑菜单', row) } const handleDeleteMenu = (row: any) => { @@ -151,8 +153,26 @@ const handleToggleStatus = (row: any) => { /** @description: 处理弹窗提交/取消/关闭事件 **/ -const handleSubmit = () => { +const handleSubmit = async () => { console.log('提交菜单表单') + try { + await menuFormRef.value?.validate() + if (dialogType.value === 'add') { + const params = { + ...menuForm.value, + parent_id: '0' + } + await createMenuApi(params) + } else { + await editMenuApi(menuForm.value) + } + dialogVisible.value = false + // 刷新菜单列表 + // onMounted() + } catch (err) { + console.log('表单验证失败') + return + } } const handleCancel = () => { dialogVisible.value = false