From c0be78649be0541f6eb0d2d5348c63da07275a3c Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 17 Apr 2024 15:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/system/menu/menu.component.ts | 22 ++++++++++++++++++++- src/app/servies/menu/menu.service.ts | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app/pages/system/menu/menu.component.ts b/src/app/pages/system/menu/menu.component.ts index cde6ec3..794946f 100644 --- a/src/app/pages/system/menu/menu.component.ts +++ b/src/app/pages/system/menu/menu.component.ts @@ -23,6 +23,7 @@ import { NzModalModule } from 'ng-zorro-antd/modal'; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {NzInputNumberComponent} from "ng-zorro-antd/input-number"; +import {NzMessageService} from "ng-zorro-antd/message"; @Component({ selector: 'app-menu', @@ -74,10 +75,12 @@ export class MenuComponent { // 编辑菜单标题 editMenuTitle = ''; constructor(private menuService: MenuService, - private fb: NonNullableFormBuilder) { + private fb: NonNullableFormBuilder, + private message: NzMessageService) { this.queryMenuData(); this.editMenuForm = this.fb.group({ + id: [], menuName: ['', [Validators.required]], menuType: ['1', [Validators.required]], menuUrl: ['', [Validators.required]], @@ -93,6 +96,7 @@ export class MenuComponent { */ queryMenuData() { this.menuService.queryMenuList((data: any) => { + console.log(data); this.menuData = data['return_data']; // 获取菜单树形结构 this.queryMenuTree(); @@ -194,9 +198,25 @@ export class MenuComponent { this.editMenuVisible = true; } + /** + * 提交表单 + */ submitEditMenuForm() { if (this.editMenuForm.valid) { console.log('submit', this.editMenuForm.value); + this.menuService.editMenu(this.editMenuForm.value, (data: any) => { + if (data['return_code'] == '000000') { + // 刷新数据 + this.queryMenuData(); + + this.message.create('success', '操作成功'); + + // 关闭弹窗 + this.closeEditMenu(); + } else { + this.message.create('error', data['return_msg']); + } + }); } else { Object.values(this.editMenuForm.controls).forEach(control => { if (control.invalid) { diff --git a/src/app/servies/menu/menu.service.ts b/src/app/servies/menu/menu.service.ts index 1daebbf..bc76b22 100644 --- a/src/app/servies/menu/menu.service.ts +++ b/src/app/servies/menu/menu.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {environment} from "../../../environments/environment"; import {ObjectData} from "../../utils/objectData.service"; +import {DATA} from "../../data/login/localStorage.namespace"; @Injectable({ providedIn: 'root'