|
|
|
import { Component } from '@angular/core';
|
|
|
|
import {Router, RouterLink, RouterOutlet} from "@angular/router";
|
|
|
|
import {
|
|
|
|
NzContentComponent,
|
|
|
|
NzFooterComponent,
|
|
|
|
NzHeaderComponent,
|
|
|
|
NzLayoutComponent,
|
|
|
|
NzSiderComponent
|
|
|
|
} from "ng-zorro-antd/layout";
|
|
|
|
import {NzBreadCrumbComponent, NzBreadCrumbItemComponent} from "ng-zorro-antd/breadcrumb";
|
|
|
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
|
|
|
import {NzMenuDirective, NzMenuGroupComponent, NzMenuItemComponent, NzSubMenuComponent} from "ng-zorro-antd/menu";
|
|
|
|
import {NgClass, NgForOf} from "@angular/common";
|
|
|
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
|
|
import {NzTabComponent, NzTabSetComponent} from "ng-zorro-antd/tabs";
|
|
|
|
import {TabComponent} from "../tab/tab.component";
|
|
|
|
import {BrowserStorageService} from "../../../utils/localStorage.service";
|
|
|
|
import {DATA, INIT_FLAG, LOGIN_DATA, USER_TOKEN} from "../../../data/login/localStorage.namespace";
|
|
|
|
import {NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
|
|
|
|
import {NzMessageService} from "ng-zorro-antd/message";
|
|
|
|
import {dictionaryData} from "../../../data/common/dictionary.namespace";
|
|
|
|
import {CommonService} from "../../../services/common/common.service";
|
|
|
|
import {LoginService} from "../../../services/login/login.service";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-index',
|
|
|
|
standalone: true,
|
|
|
|
imports: [
|
|
|
|
RouterOutlet,
|
|
|
|
NzLayoutComponent,
|
|
|
|
NzHeaderComponent,
|
|
|
|
NzBreadCrumbComponent,
|
|
|
|
NzBreadCrumbItemComponent,
|
|
|
|
NzContentComponent,
|
|
|
|
NzFooterComponent,
|
|
|
|
NzRowDirective,
|
|
|
|
NzColDirective,
|
|
|
|
NzMenuItemComponent,
|
|
|
|
NzMenuDirective,
|
|
|
|
RouterLink,
|
|
|
|
NzSubMenuComponent,
|
|
|
|
NgForOf,
|
|
|
|
NgClass,
|
|
|
|
NzIconDirective,
|
|
|
|
NzTabComponent,
|
|
|
|
NzTabSetComponent,
|
|
|
|
TabComponent,
|
|
|
|
NzSiderComponent,
|
|
|
|
NzMenuGroupComponent,
|
|
|
|
NzDropDownDirective,
|
|
|
|
NzDropdownMenuComponent
|
|
|
|
],
|
|
|
|
templateUrl: './index.component.html',
|
|
|
|
styleUrl: './index.component.less',
|
|
|
|
})
|
|
|
|
export class IndexComponent {
|
|
|
|
// 菜单数据
|
|
|
|
menuData: any = [{
|
|
|
|
'menuName' : '首页',
|
|
|
|
'selected' : true,
|
|
|
|
}];
|
|
|
|
userInfo: any;
|
|
|
|
// 左侧菜单栏数据
|
|
|
|
leftMenuData: any = [];
|
|
|
|
// 侧边菜单展示开关
|
|
|
|
isCollapse = true;
|
|
|
|
// 当前顶级菜单
|
|
|
|
currentParentMenu: any = {};
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private commonService: CommonService,
|
|
|
|
private storage: BrowserStorageService,
|
|
|
|
private message: NzMessageService,
|
|
|
|
private router: Router, // 路由
|
|
|
|
private login: LoginService
|
|
|
|
) {
|
|
|
|
// 缓存数据字典
|
|
|
|
this.commonService.queryDictionary('','',(data: any) => {
|
|
|
|
for (let item of data['return_data']) {
|
|
|
|
dictionaryData.push(
|
|
|
|
{
|
|
|
|
codeType: item.codeType,
|
|
|
|
codeValue: item.codeValue,
|
|
|
|
codeName: item.codeName,
|
|
|
|
codeDesc: item.codeDesc,
|
|
|
|
sortId: item.sortId,
|
|
|
|
ext1: item.ext1,
|
|
|
|
ext2: item.ext2,
|
|
|
|
ext3: item.ext3
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.menuData = this.menuData.concat(this.storage.get(DATA)['menuTree']);
|
|
|
|
this.userInfo = this.storage.get(DATA)['account'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// 选择操作
|
|
|
|
isSelected(item: any) {
|
|
|
|
this.menuData.map((data: any) => {
|
|
|
|
data.selected = data.menuName === item.menuName;
|
|
|
|
});
|
|
|
|
if (item.menuName === '首页') {
|
|
|
|
// 激活首页路由
|
|
|
|
this.router.navigateByUrl('/admin/index').finally();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentParentMenu = item;
|
|
|
|
this.leftMenuData = item['childMenuList'];
|
|
|
|
this.isCollapse = item['menuName'] === '首页';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 退出登录
|
|
|
|
public loginOut(): void {
|
|
|
|
this.login.loginOut( (data: any) => {
|
|
|
|
if (data['return_code'] === '000000') {
|
|
|
|
this.storage.remove(LOGIN_DATA);
|
|
|
|
this.storage.remove(DATA);
|
|
|
|
this.storage.remove(USER_TOKEN);
|
|
|
|
this.storage.remove(INIT_FLAG);
|
|
|
|
this.router.navigateByUrl('/login').then();
|
|
|
|
} else {
|
|
|
|
this.message.error(data['return_msg']);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|