You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
puhui-go-web/src/app/pages/body/index/index.component.ts

243 lines
7.4 KiB

7 months ago
import {AfterViewInit, Component} from '@angular/core';
11 months ago
import {Router, RouterLink, RouterOutlet} from "@angular/router";
11 months ago
import {
NzContentComponent,
NzFooterComponent,
NzHeaderComponent,
NzLayoutComponent,
NzSiderComponent
} from "ng-zorro-antd/layout";
11 months ago
import {NzBreadCrumbComponent, NzBreadCrumbItemComponent} from "ng-zorro-antd/breadcrumb";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
11 months ago
import {NzMenuDirective, NzMenuGroupComponent, NzMenuItemComponent, NzSubMenuComponent} from "ng-zorro-antd/menu";
7 months ago
import {DatePipe, NgClass, NgForOf, NgIf} from "@angular/common";
11 months ago
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzTabComponent, NzTabSetComponent} from "ng-zorro-antd/tabs";
import {TabComponent} from "../tab/tab.component";
11 months ago
import {BrowserStorageService} from "../../../utils/localStorage.service";
11 months ago
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";
10 months ago
import {Dictionary, dictionaryData} from "../../../data/common/dictionary.namespace";
11 months ago
import {CommonService} from "../../../services/common/common.service";
import {LoginService} from "../../../services/login/login.service";
10 months ago
import {NzConfigService} from "ng-zorro-antd/core/config";
7 months ago
import {NzPopoverDirective} from "ng-zorro-antd/popover";
import {NzListItemComponent, NzListItemMetaComponent, NzListModule} from "ng-zorro-antd/list";
import {NzTypographyComponent} from "ng-zorro-antd/typography";
import {IconService} from "../../../services/common/icon.service";
import {FileService} from "../../../services/file/file.service";
import {DataUtilsPipe} from "../../../pipes/common/data-utils.pipe";
import {GoodsListComponent} from "../../trade/goods-list/goods-list.component";
import {Subject} from "rxjs";
import {CommunicationService} from "../../../services/common/communication.service";
import {NzModalComponent, NzModalContentDirective, NzModalModule} from "ng-zorro-antd/modal";
import {NzResultComponent} from "ng-zorro-antd/result";
import {NzSpinComponent} from "ng-zorro-antd/spin";
import {NzTimelineComponent, NzTimelineItemComponent} from "ng-zorro-antd/timeline";
import {NzTableComponent, NzTableModule} from "ng-zorro-antd/table";
import {BusinessTypePipe} from "../../../pipes/file/business-type.pipe";
import {StatusPipe} from "../../../pipes/file/status.pipe";
11 months ago
@Component({
selector: 'app-index',
standalone: true,
imports: [
RouterOutlet,
NzLayoutComponent,
NzHeaderComponent,
NzBreadCrumbComponent,
NzBreadCrumbItemComponent,
NzContentComponent,
NzFooterComponent,
NzRowDirective,
NzColDirective,
NzMenuItemComponent,
7 months ago
NzModalModule,
11 months ago
NzMenuDirective,
RouterLink,
NzSubMenuComponent,
NgForOf,
NgClass,
NzIconDirective,
NzTabComponent,
7 months ago
NzListModule,
11 months ago
NzTabSetComponent,
11 months ago
TabComponent,
11 months ago
NzSiderComponent,
11 months ago
NzMenuGroupComponent,
NzDropDownDirective,
7 months ago
NzDropdownMenuComponent,
NgIf,
NzPopoverDirective,
NzListItemComponent,
NzListItemMetaComponent,
NzTypographyComponent,
NzTableModule,
DataUtilsPipe,
GoodsListComponent,
DatePipe,
NzModalComponent,
NzResultComponent,
NzSpinComponent,
NzTimelineComponent,
NzTimelineItemComponent,
NzTableComponent,
NzModalContentDirective,
BusinessTypePipe,
StatusPipe
11 months ago
],
templateUrl: './index.component.html',
styleUrl: './index.component.less',
})
export class IndexComponent {
11 months ago
// 菜单数据
menuData: any = [{
'menuName' : '首页',
'selected' : true,
}];
7 months ago
// 表单页数
tablePageNum = 1;
// 表单数据
tableData: any;
11 months ago
userInfo: any;
11 months ago
// 左侧菜单栏数据
leftMenuData: any = [];
11 months ago
// 侧边菜单展示开关
11 months ago
isCollapse = true;
7 months ago
loading = false;
isVisible = false;
11 months ago
// 当前顶级菜单
currentParentMenu: any = {};
7 months ago
downloadType = 1;
interval: any;
11 months ago
constructor(
11 months ago
private commonService: CommonService,
11 months ago
private storage: BrowserStorageService,
7 months ago
private communicationService: CommunicationService,
10 months ago
private nzConfigService: NzConfigService,
7 months ago
private iconService: IconService,
private fileService: FileService,
11 months ago
private message: NzMessageService,
private router: Router, // 路由
private login: LoginService
) {
7 months ago
this.communicationService.currentMessage.subscribe(message => {
this.fileRecords();
this.findFileRecords(message.id);
this.downloadType = 2;
});
10 months ago
this.nzConfigService.set('button', { nzSize: 'large' })
this.nzConfigService.set('treeSelect', { nzSize: 'large' })
11 months ago
// 缓存数据字典
this.commonService.queryDictionary('','',(data: any) => {
10 months ago
dictionaryData.length = 0;
11 months ago
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
}
);
}
});
11 months ago
this.menuData = this.menuData.concat(this.storage.get(DATA)['menuTree']);
11 months ago
this.userInfo = this.storage.get(DATA)['account'];
7 months ago
this.fileRecords();
11 months ago
}
11 months ago
// 选择操作
isSelected(item: any) {
11 months ago
this.menuData.map((data: any) => {
data.selected = data.menuName === item.menuName;
11 months ago
});
11 months ago
if (item.menuName === '首页') {
// 激活首页路由
this.router.navigateByUrl('/admin/index').finally();
}
11 months ago
this.currentParentMenu = item;
11 months ago
this.leftMenuData = item['childMenuList'];
11 months ago
this.isCollapse = item['menuName'] === '首页';
11 months ago
11 months ago
}
11 months ago
// 退出登录
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']);
}
});
}
7 months ago
// 弹出下载记录
public getFileRecords() {
this.loading = true;
this.isVisible = true;
}
// 查询下载记录
public fileRecords() {
let searchForm = {
time: new Date().getTime()
}
this.fileService.getFileRecordsList(searchForm , (data: any) => {
if (data['return_code'] == '000000') {
this.tableData = data['return_data'];
} else {
this.message.error(data['return_msg']);
}
this.loading = false;
});
}
// 查询详情
public findFileRecords(id: number) {
this.interval = setInterval(() => this.fileService.findFileRecords(id, (data: any) => {
if (data['return_code'] == '000000') {
if (data['return_data'].status == 1) {
clearTimeout(this.interval);
console.log("完成");
this.downloadType = 1;
this.fileRecords();
}
}else {
clearTimeout(this.interval);
this.fileRecords();
this.downloadType = 1;
}
}), 1000);
}
// 下载
public getDownLoad(id: number) {
this.fileService.getDownLoad(id, (data: any) => {
if (data['return_code'] == '000000') {
window.location.href = data['return_data'];
}else {
this.message.error(data['return_msg']);
}
})
}
11 months ago
}