fix bug
This commit is contained in:
@ -30,6 +30,7 @@
|
||||
<div class="d-flex align-items-center">
|
||||
<div>
|
||||
<button nz-button nzType="primary" (click)="menuAction('新增菜单')">新增</button>
|
||||
<button nz-button nzType="primary" (click)="menuSort()">菜单排序</button>
|
||||
<!-- <button nz-button nzType="primary" (click)="menuImport(0)" [disabled]="service.http.loading"
|
||||
*ngIf="selectedPlatform.enName==='tms-smc-web'">
|
||||
导入货主菜单
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { STComponent, STColumn, STRequestOptions, STChange } from '@delon/abc/st';
|
||||
import { SFComponent, SFSchema } from '@delon/form';
|
||||
import { Menu } from '@delon/theme';
|
||||
import { Menu, ModalHelper } from '@delon/theme';
|
||||
import { EAEnvironmentService } from '@shared';
|
||||
import { NzSafeAny } from 'ng-zorro-antd/core/types';
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { SettingRoleEditComponent } from 'src/app/routes/sys-setting/components/role-management/edit/edit.component';
|
||||
import { MenuManagerMenusortComponent } from '../menusort/menusort.component';
|
||||
import { MenuManagerService } from './../../services/menu-manager.service';
|
||||
import { MenuModalComponent } from './menu-modal/menu-modal.component';
|
||||
|
||||
@ -36,7 +37,7 @@ export class MenuManagerComponentsIndexComponent implements OnInit {
|
||||
|
||||
mapOfExpandedData: { [key: string]: any[] } = {};
|
||||
listOfMapData: any[] = [];
|
||||
constructor(private envSrv: EAEnvironmentService, public service: MenuManagerService, private modal: NzModalService) {
|
||||
constructor(private envSrv: EAEnvironmentService, public service: MenuManagerService, private modal: NzModalService, private modalHelper: ModalHelper,) {
|
||||
this.initData();
|
||||
}
|
||||
|
||||
@ -125,4 +126,12 @@ export class MenuManagerComponentsIndexComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
menuSort(){
|
||||
const dialogData = {
|
||||
appId: this.selectedPlatform.appId
|
||||
};
|
||||
this.modalHelper.create(MenuManagerMenusortComponent, { i: dialogData }, { size: 900 }).subscribe((res:any) => {
|
||||
this.initData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
<div class="modal-header">
|
||||
<div class="modal-title">菜单排序</div>
|
||||
</div>
|
||||
<div>
|
||||
<nz-tree
|
||||
#nzTreeComponent
|
||||
[nzData]="menuList"
|
||||
(nzClick)="nzEvent($event)"
|
||||
nzDraggable
|
||||
nzBlockNode
|
||||
(nzOnDragEnd)="dragEnd($event)"
|
||||
>
|
||||
</nz-tree>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button nz-button type="button" (click)="close()">关闭</button>
|
||||
<button nz-button nzType="primary" (click)="sure()">确定</button>
|
||||
</div>
|
||||
@ -0,0 +1,24 @@
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MenuManagerMenusortComponent } from './menusort.component';
|
||||
|
||||
describe('MenuManagerMenusortComponent', () => {
|
||||
let component: MenuManagerMenusortComponent;
|
||||
let fixture: ComponentFixture<MenuManagerMenusortComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MenuManagerMenusortComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MenuManagerMenusortComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,77 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { _HttpClient } from '@delon/theme';
|
||||
import { NzMessageService } from 'ng-zorro-antd/message';
|
||||
import { NzModalRef } from 'ng-zorro-antd/modal';
|
||||
import { NzTreeComponent } from 'ng-zorro-antd/tree';
|
||||
import { MenuManagerService } from '../../services/menu-manager.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu-manager-menusort',
|
||||
templateUrl: './menusort.component.html',
|
||||
})
|
||||
export class MenuManagerMenusortComponent implements OnInit {
|
||||
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
|
||||
record: any = {};
|
||||
i: any;
|
||||
functionList: any[] = [];
|
||||
menuList: any[] = [];
|
||||
|
||||
constructor(
|
||||
private modal: NzModalRef,
|
||||
public service: MenuManagerService,
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getAllFunction()
|
||||
}
|
||||
getAllFunction() {
|
||||
this.service.request(this.service.$api_get_all, { appId: this.i.appId }, 'POST', false).subscribe(res => {
|
||||
this.functionList = res;
|
||||
this.menuList = res[0].children;
|
||||
});
|
||||
}
|
||||
nzEvent(event: any): void {
|
||||
console.log(event)
|
||||
}
|
||||
dragEnd(event: any){
|
||||
const functionId = event.node.key
|
||||
let sortNumber = 0
|
||||
const newMenuList = this.nzTreeComponent.getTreeNodes()
|
||||
newMenuList.forEach((item, index) => {
|
||||
if(event.node.level === 0 && item.children) {
|
||||
|
||||
if(functionId === item.key) {
|
||||
sortNumber = index
|
||||
}
|
||||
} else if(event.node.level === 1 && item.children) {
|
||||
item.children.forEach((subItem: any, subIndex: number) => {
|
||||
if(functionId === subItem.key) {
|
||||
sortNumber = subIndex
|
||||
}
|
||||
})
|
||||
} else if(event.node.level === 2 && item.children) {
|
||||
item.children.forEach((thirdItem: any, thirdIndex: number) => {
|
||||
if(functionId === thirdItem.key) {
|
||||
sortNumber = thirdIndex
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
const params: any = {
|
||||
parentId: event.node.level === 0 ? this.functionList[0].id : event.node.parentNode.key,
|
||||
functionId,
|
||||
sortNumber
|
||||
}
|
||||
this.service.request(this.service.$api_alterFunctionsParent, params).subscribe(res => {
|
||||
if (res) {
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
sure(){
|
||||
this.modal.close(true)
|
||||
}
|
||||
close(): void {
|
||||
this.modal.destroy();
|
||||
}
|
||||
}
|
||||
@ -5,9 +5,10 @@ import { MenuManagerRoutingModule } from './menu-manager-routing.module';
|
||||
import { MenuModalComponent } from './components/index/menu-modal/menu-modal.component';
|
||||
import { ApiAuthComponent } from './components/api-auth/api-auth.component';
|
||||
import { AuthDrawerComponent } from './components/api-auth/auth-drawer/auth-drawer.component';
|
||||
import { MenuManagerMenusortComponent } from './components/menusort/menusort.component';
|
||||
|
||||
const COMPONENTS: Type<void>[] = [MenuManagerComponentsIndexComponent, ApiAuthComponent];
|
||||
const COMPONENTS_NOROUNT: Type<void>[] = [MenuModalComponent, AuthDrawerComponent];
|
||||
const COMPONENTS_NOROUNT: Type<void>[] = [MenuModalComponent, AuthDrawerComponent, MenuManagerMenusortComponent];
|
||||
@NgModule({
|
||||
imports: [SharedModule, MenuManagerRoutingModule],
|
||||
declarations: [...COMPONENTS, ...COMPONENTS_NOROUNT]
|
||||
|
||||
@ -25,6 +25,8 @@ export class MenuManagerService extends BaseService {
|
||||
$api_save_menu_function = `/api/mdc/cuc/functionButton/saveFunctionButton`;
|
||||
// 删除菜单按钮关联表
|
||||
$api_delete_menu_function = `/api/mdc/cuc/functionButton/deletebatch`;
|
||||
// 排序菜单
|
||||
$api_alterFunctionsParent = `/api/mdc/cuc/functionInfo/alterFunctionsParent`;
|
||||
|
||||
constructor(public injector: Injector) {
|
||||
super(injector);
|
||||
|
||||
Reference in New Issue
Block a user