deletemenu

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1193665761703&lmt=1193665780&format=336x280_as&output=html&correlator=1193665761687&url=http%3A%2F%2Fwww.codeguru.cn%2Fpublic%2Fiframe%2Fwinapiiframe.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=1285758818.1193665762&ga_sid=1193665762&ga_hid=111695597&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_his=8&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency">     函数功能:该函数从指定菜单里删除一个菜单项。如果此菜单项打开了一个菜单或子菜单,则此函数销毁该菜单或子菜单的句柄,并释放该菜单或子菜单使用的存储器。

    函数原型:BOOL DelefeMenu(HMENU hMenu,UINT uPosition,UINT uFlags);

    参数:

    hMenu:要被的修改菜单的句柄。

    UPosition:指定将被删除的菜单项,按参数uFlagS确定的含义。

    UFlags:确定参数UPosition加如何被解释。此参数可取下列值之一:

    MF_BYCOMMAND:表示uPosition给出菜单项的标识符。如果MF_BYCOMMAND和MF_BYPOSITION都没被指定,则MF_BYCOMMAND为缺省的标志。

    MF_BYPOSITION:表示uPosition给出菜单项基于零的相对位置。

    返回值:如果函数调用成功,返回值非零;如果函数调用失败,返回值是零。若想获得更多的错误信息, 请调用GetLastError函数。

    备注:只要一个菜单被修改,无论它是否被显示在窗口里,应用程序都应调用DrawMenubar。

    速查:Wihdows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:1.0及以上版本;头文件:Winuser.h;输入库:user32.lib。

// 加载菜单数据 loadMenuData() { this.isLoading = true // 模拟API请求延迟 setTimeout(() => { const mockData = this.generateMockData() if (this.currentPage === 1) { this.menus = mockData } else { // 后续页面追加数据 this.menus = [...this.menus, ...mockData] } // 检查是否加载完成 if (this.currentPage >= this.totalPages) { this.loadComplete = true } this.isLoading = false }, 800) }, // 获取父菜单名称 getParentName(parentId) { const parent = this.menus.find(m => m.id === parentId) return parent ? parent.name : '未知菜单' }, // 上拉触底事件 onReachBottom() { if (this.isLoading || this.loadComplete) return this.currentPage++ this.loadMenuData() }, // 搜索处理 handleSearch() { this.currentPage = 1 this.loadComplete = false this.loadMenuData() }, // 清空搜索 clearSearch() { this.searchValue = '' this.handleSearch() }, // 打开新增菜单弹窗 openAddDialog() { this.isEditing = false this.resetForm() this.showMenuDialog = true }, // 打开编辑菜单弹窗 openEditDialog(menu) { this.isEditing = true // 深拷贝菜单数据到当前编辑对象 this.currentMenu = {...menu} this.showMenuDialog = true }, // 关闭菜单弹窗 closeMenuDialog() { this.showMenuDialog = false this.showTypeOptions = false this.showParentOptions = false this.resetForm() this.clearErrors() }, // 确认删除菜单 confirmDelete(menuId) { uni.showModal({ title: '确认删除', content: '确定要删除该菜单吗?此操作不可撤销', success: (res) => { if (res.confirm) { this.deleteMenu(menuId) } } }) }, // 删除菜单 deleteMenu(menuId) { // 确保 menus 数组存在 if (!this.menus) return // 过滤掉要删除的菜单 this.menus = this.menus.filter(menu => menu.id !== menuId) // 同时删除所有子菜单 this.menus = this.menus.filter(menu => menu.parentId !== menuId) uni.showToast({ title: '菜单删除成功', icon: 'success' }) }, // 重置表单 resetForm() { this.formData = { menuId: '', menuName: '', path: '', icon: '', type: '', parentId: '', sort: 100, status: true, createDate: '', component: '' }; this.$refs.form.resetFields(); }, // 清除错误状态 clearErrors() { this.nameError = false }, // 状态切换 switchChange(e) { this.currentMenu.status = e.detail.value }, // 选择菜单类型 selectType(type) { this.currentMenu.type = type this.showTypeOptions = false // 如果是按钮类型,清除路径 if (type === 'button') { this.currentMenu.path = '' } }, // 选择父菜单 selectParent(parentId) { this.currentMenu.parentId = parentId this.showParentOptions = false }, // 验证名称 validateName() { this.nameError = !this.currentMenu.name || !this.currentMenu.name.trim() return !this.nameError }, // 保存菜单 saveMenu() { // 验证表单 const isNameValid = this.validateName() if (!isNameValid) { uni.showToast({ title: '请填写菜单名称', icon: 'none' }) return } // 验证非按钮类型需要填写路径 if (this.currentMenu.type !== 'button' && !this.currentMenu.path) { uni.showToast({ title: '请填写菜单路径', icon: 'none' }) return } // 确保 menus 数组存在 if (!this.menus) { this.menus = [] } if (this.isEditing) { // 编辑模式:更新现有菜单 const index = this.menus.findIndex(m => m.id === this.currentMenu.id) if (index !== -1) { // 保留原始创建日期 const originalCreateDate = this.menus[index].createDate this.currentMenu.createDate = originalCreateDate // 更新菜单 this.menus.splice(index, 1, {...this.currentMenu}) uni.showToast({ title: '菜单更新成功', icon: 'success' }) } } else { // 新增模式 }, } // 关闭弹窗 this.closeMenuDialog() }, 按照接口完成与接口相关的方法, 根据id删除菜单:/Menu/deleteById、添加菜单:/Menu/insertMenu、分页查询所有菜单/Menu/selectAll、根据菜单id查询菜单信息/Menu/selectByMenuId、根据菜单id去修改菜单 /Menu/updateByMenuId
最新发布
11-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值