|
|
@ -1,6 +1,6 @@ |
|
|
|
import { Component } from '@angular/core'; |
|
|
|
import { Component } from '@angular/core'; |
|
|
|
import {NzTreeComponent} from "ng-zorro-antd/tree"; |
|
|
|
import {NzTreeComponent} from "ng-zorro-antd/tree"; |
|
|
|
import {NgIf} from "@angular/common"; |
|
|
|
import {NgForOf, NgIf} from "@angular/common"; |
|
|
|
import {NzIconDirective} from "ng-zorro-antd/icon"; |
|
|
|
import {NzIconDirective} from "ng-zorro-antd/icon"; |
|
|
|
import {NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; |
|
|
|
import {NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; |
|
|
|
import {MenuService} from "../../../servies/menu/menu.service"; |
|
|
|
import {MenuService} from "../../../servies/menu/menu.service"; |
|
|
@ -17,8 +17,12 @@ import {NzDescriptionsComponent, NzDescriptionsItemComponent} from "ng-zorro-ant |
|
|
|
import {MenuTypePipe} from "../../../pipes/menu/menu-type.pipe"; |
|
|
|
import {MenuTypePipe} from "../../../pipes/menu/menu-type.pipe"; |
|
|
|
import {NzFormDirective, NzFormLabelComponent} from "ng-zorro-antd/form"; |
|
|
|
import {NzFormDirective, NzFormLabelComponent} from "ng-zorro-antd/form"; |
|
|
|
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; |
|
|
|
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; |
|
|
|
import {NzInputDirective} from "ng-zorro-antd/input"; |
|
|
|
import { NzFormModule } from 'ng-zorro-antd/form'; |
|
|
|
|
|
|
|
import {NzInputDirective, NzInputGroupComponent} from "ng-zorro-antd/input"; |
|
|
|
import { NzModalModule } from 'ng-zorro-antd/modal'; |
|
|
|
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"; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-menu', |
|
|
|
selector: 'app-menu', |
|
|
@ -36,14 +40,21 @@ import { NzModalModule } from 'ng-zorro-antd/modal'; |
|
|
|
NzRowDirective, |
|
|
|
NzRowDirective, |
|
|
|
NzColDirective, |
|
|
|
NzColDirective, |
|
|
|
NzButtonComponent, |
|
|
|
NzButtonComponent, |
|
|
|
NzDescriptionsComponent, |
|
|
|
|
|
|
|
NzDescriptionsItemComponent, |
|
|
|
|
|
|
|
MenuTypePipe, |
|
|
|
MenuTypePipe, |
|
|
|
|
|
|
|
NzModalModule, |
|
|
|
NzFormDirective, |
|
|
|
NzFormDirective, |
|
|
|
ReactiveFormsModule, |
|
|
|
ReactiveFormsModule, |
|
|
|
NzInputDirective, |
|
|
|
|
|
|
|
NzFormLabelComponent, |
|
|
|
NzFormLabelComponent, |
|
|
|
NzModalModule |
|
|
|
NzInputDirective, |
|
|
|
|
|
|
|
NzDescriptionsItemComponent, |
|
|
|
|
|
|
|
NzDescriptionsComponent, |
|
|
|
|
|
|
|
NzInputGroupComponent, |
|
|
|
|
|
|
|
NzFormModule, |
|
|
|
|
|
|
|
NzFlexDirective, |
|
|
|
|
|
|
|
NzSelectComponent, |
|
|
|
|
|
|
|
NzOptionComponent, |
|
|
|
|
|
|
|
NgForOf, |
|
|
|
|
|
|
|
NzInputNumberComponent |
|
|
|
], |
|
|
|
], |
|
|
|
templateUrl: './menu.component.html', |
|
|
|
templateUrl: './menu.component.html', |
|
|
|
styleUrl: './menu.component.less' |
|
|
|
styleUrl: './menu.component.less' |
|
|
@ -60,13 +71,15 @@ export class MenuComponent { |
|
|
|
editMenuVisible = false; |
|
|
|
editMenuVisible = false; |
|
|
|
// 编辑菜单表单
|
|
|
|
// 编辑菜单表单
|
|
|
|
editMenuForm: FormGroup; |
|
|
|
editMenuForm: FormGroup; |
|
|
|
|
|
|
|
// 编辑菜单标题
|
|
|
|
|
|
|
|
editMenuTitle = ''; |
|
|
|
constructor(private menuService: MenuService, |
|
|
|
constructor(private menuService: MenuService, |
|
|
|
private fb: NonNullableFormBuilder) { |
|
|
|
private fb: NonNullableFormBuilder) { |
|
|
|
this.queryMenuData(); |
|
|
|
this.queryMenuData(); |
|
|
|
|
|
|
|
|
|
|
|
this.editMenuForm = this.fb.group({ |
|
|
|
this.editMenuForm = this.fb.group({ |
|
|
|
menuName: ['', [Validators.required]], |
|
|
|
menuName: ['', [Validators.required]], |
|
|
|
menuType: ['', [Validators.required]], |
|
|
|
menuType: ['1', [Validators.required]], |
|
|
|
menuUrl: ['', [Validators.required]], |
|
|
|
menuUrl: ['', [Validators.required]], |
|
|
|
menuPSid: [''], |
|
|
|
menuPSid: [''], |
|
|
|
menuUrlImg: [''], |
|
|
|
menuUrlImg: [''], |
|
|
@ -108,11 +121,14 @@ export class MenuComponent { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
clickNode(nodeData: any) { |
|
|
|
clickNode(nodeData: any) { |
|
|
|
const menuId = nodeData['keys'][0]; |
|
|
|
const menuId = nodeData['keys'][0]; |
|
|
|
|
|
|
|
if (menuId != null) { |
|
|
|
const menuObj = this.menuData.find((o: any) => o.id == menuId); |
|
|
|
const menuObj = this.menuData.find((o: any) => o.id == menuId); |
|
|
|
if (menuObj != null && menuObj.menuPSid != null) { |
|
|
|
if (menuObj != null && menuObj.menuPSid != null) { |
|
|
|
// 获取父级菜单
|
|
|
|
// 获取父级菜单
|
|
|
|
menuObj['parentMenu'] = this.menuData.find((o: any) => o.id == menuObj.menuPSid); |
|
|
|
menuObj['parentMenu'] = this.menuData.find((o: any) => o.id == menuObj.menuPSid); |
|
|
|
|
|
|
|
} |
|
|
|
this.menuDetail = menuObj; |
|
|
|
this.menuDetail = menuObj; |
|
|
|
|
|
|
|
console.log(this.menuDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -146,16 +162,49 @@ export class MenuComponent { |
|
|
|
return dataTree; |
|
|
|
return dataTree; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 编辑菜单 |
|
|
|
* 编辑菜单 |
|
|
|
|
|
|
|
* @param edit 编辑状态 true:增加 false:修改 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
openEditMenu() { |
|
|
|
openEditMenu(edit: boolean) { |
|
|
|
|
|
|
|
// 初始化表单
|
|
|
|
|
|
|
|
this.editMenuTitle = '添加菜单'; |
|
|
|
|
|
|
|
this.editMenuForm.reset(); |
|
|
|
|
|
|
|
let menu = { |
|
|
|
|
|
|
|
menuPSid: "", |
|
|
|
|
|
|
|
menuType: '1' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.menuDetail != null) { |
|
|
|
|
|
|
|
if (edit) { |
|
|
|
|
|
|
|
// 增加
|
|
|
|
|
|
|
|
menu = { |
|
|
|
|
|
|
|
menuPSid: ""+this.menuDetail.id, |
|
|
|
|
|
|
|
menuType: '1' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 修改
|
|
|
|
|
|
|
|
this.editMenuTitle = '修改菜单'; |
|
|
|
|
|
|
|
menu = this.menuDetail; |
|
|
|
|
|
|
|
menu['menuPSid'] = ""+menu['menuPSid'] |
|
|
|
|
|
|
|
menu['menuType'] = ""+menu['menuType'] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.editMenuForm.patchValue(menu); |
|
|
|
this.editMenuVisible = true; |
|
|
|
this.editMenuVisible = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
submitEditMenuForm() { |
|
|
|
submitEditMenuForm() { |
|
|
|
|
|
|
|
if (this.editMenuForm.valid) { |
|
|
|
|
|
|
|
console.log('submit', this.editMenuForm.value); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Object.values(this.editMenuForm.controls).forEach(control => { |
|
|
|
|
|
|
|
if (control.invalid) { |
|
|
|
|
|
|
|
control.markAsDirty(); |
|
|
|
|
|
|
|
control.updateValueAndValidity({ onlySelf: true }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|