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

279 lines
8.8 KiB

6 months ago
import {AfterViewInit, Component, TemplateRef, ViewChild} 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";
6 months ago
import {NzModalComponent, NzModalContentDirective, NzModalModule, NzModalService} from "ng-zorro-antd/modal";
7 months ago
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";
7 months ago
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzBadgeComponent} from "ng-zorro-antd/badge";
6 months ago
import {NzNotificationComponent, NzNotificationService} from "ng-zorro-antd/notification";
import {OrderGoodsService} from "../../../services/trade/order-goods.service";
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,
7 months ago
StatusPipe,
NzPopconfirmDirective,
NzButtonComponent,
NzBadgeComponent
11 months ago
],
templateUrl: './index.component.html',
6 months ago
styleUrl: './index.component.less'
11 months ago
})
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;
7 months ago
showComponent = false;
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 fileService: FileService,
11 months ago
private message: NzMessageService,
6 months ago
private orderGoodsService: OrderGoodsService,
private modal: NzModalService,
11 months ago
private router: Router, // 路由
private login: LoginService
) {
7 months ago
6 months ago
this.orderGoodsService.goodsOrderCount((data: any) => {
if (data['return_code'] == '000000') {
if (data['return_data'] > 0) {
this.modal.warning({
nzTitle: '物流信息通知',
nzContent: '当前存在' + data['return_data'] + '条未发货订单,请尽快千万发货!',
nzOkText: '去发货',
nzOkType: 'primary',
nzOkDanger: true,
nzOnOk: () => {
this.router.navigateByUrl('/admin/trade/goods-logistics-list?title=物流订单').then(r => console.log("返回内容" ,r));
},
nzCancelText: '暂不处理',
nzOnCancel: () => console.log('Cancel')
});
}
}
});
7 months ago
this.communicationService.currentMessage.subscribe(message => {
7 months ago
this.showComponent = true;
7 months ago
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);
4 months ago
location.reload();
11 months ago
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') {
7 months ago
if (data['return_data'].status == 1 || data['return_data'].status == 3) {
this.showComponent = false;
7 months ago
clearTimeout(this.interval);
this.downloadType = 1;
this.fileRecords();
}
}else {
7 months ago
this.showComponent = false;
7 months ago
clearTimeout(this.interval);
this.fileRecords();
this.downloadType = 1;
}
}), 1000);
}
// 下载
public getDownLoad(id: number) {
this.fileService.getDownLoad(id, (data: any) => {
if (data['return_code'] == '000000') {
7 months ago
this.fileRecords();
window.open(data['return_data']);
7 months ago
}else {
this.message.error(data['return_msg']);
}
})
}
7 months ago
11 months ago
}