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.
376 lines
12 KiB
376 lines
12 KiB
import {AfterViewInit, Component, OnDestroy, OnInit, TemplateRef, ViewChild} 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 {DatePipe, NgClass, NgForOf, NgIf} 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 {Dictionary, dictionaryData} from "../../../data/common/dictionary.namespace";
|
|
import {CommonService} from "../../../services/common/common.service";
|
|
import {LoginService} from "../../../services/login/login.service";
|
|
import {NzConfigService} from "ng-zorro-antd/core/config";
|
|
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, takeUntil} from "rxjs";
|
|
import {CommunicationService} from "../../../services/common/communication.service";
|
|
import {NzModalComponent, NzModalContentDirective, NzModalModule, NzModalService} 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";
|
|
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm";
|
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
|
import {NzBadgeComponent} from "ng-zorro-antd/badge";
|
|
import {NzNotificationComponent, NzNotificationService} from "ng-zorro-antd/notification";
|
|
import {OrderGoodsService} from "../../../services/trade/order-goods.service";
|
|
import {NzDrawerComponent, NzDrawerContentDirective} from "ng-zorro-antd/drawer";
|
|
import {
|
|
AbstractControl, FormControl,
|
|
FormGroup,
|
|
FormsModule,
|
|
NonNullableFormBuilder,
|
|
ReactiveFormsModule, ValidationErrors, ValidatorFn,
|
|
Validators
|
|
} from "@angular/forms";
|
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
import {
|
|
NzFormControlComponent,
|
|
NzFormDirective,
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzFormTooltipIcon
|
|
} from "ng-zorro-antd/form";
|
|
import {NzInputDirective, NzInputGroupComponent} from "ng-zorro-antd/input";
|
|
import {MyValidators} from "../../../services/common/validators.service";
|
|
|
|
@Component({
|
|
selector: 'app-index',
|
|
standalone: true,
|
|
imports: [
|
|
RouterOutlet,
|
|
NzLayoutComponent,
|
|
NzHeaderComponent,
|
|
NzBreadCrumbComponent,
|
|
NzBreadCrumbItemComponent,
|
|
NzContentComponent,
|
|
NzFooterComponent,
|
|
NzRowDirective,
|
|
NzColDirective,
|
|
NzMenuItemComponent,
|
|
NzModalModule,
|
|
NzMenuDirective,
|
|
RouterLink,
|
|
NzSubMenuComponent,
|
|
NgForOf,
|
|
NgClass,
|
|
NzIconDirective,
|
|
NzTabComponent,
|
|
NzListModule,
|
|
NzTabSetComponent,
|
|
TabComponent,
|
|
NzSiderComponent,
|
|
NzMenuGroupComponent,
|
|
NzDropDownDirective,
|
|
NzDropdownMenuComponent,
|
|
NgIf,
|
|
NzPopoverDirective,
|
|
NzListItemComponent,
|
|
NzListItemMetaComponent,
|
|
NzTypographyComponent,
|
|
NzTableModule,
|
|
DataUtilsPipe,
|
|
GoodsListComponent,
|
|
DatePipe,
|
|
NzModalComponent,
|
|
NzResultComponent,
|
|
NzSpinComponent,
|
|
NzTimelineComponent,
|
|
NzTimelineItemComponent,
|
|
NzTableComponent,
|
|
NzModalContentDirective,
|
|
BusinessTypePipe,
|
|
StatusPipe,
|
|
NzPopconfirmDirective,
|
|
NzButtonComponent,
|
|
NzBadgeComponent,
|
|
NzDrawerComponent,
|
|
NzDrawerContentDirective,
|
|
FormsModule,
|
|
NzFlexDirective,
|
|
NzFormControlComponent,
|
|
NzFormDirective,
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzInputDirective,
|
|
ReactiveFormsModule,
|
|
NzInputGroupComponent
|
|
],
|
|
templateUrl: './index.component.html',
|
|
styleUrl: './index.component.less'
|
|
})
|
|
export class IndexComponent {
|
|
// 菜单数据
|
|
menuData: any = [{
|
|
'menuName' : '首页',
|
|
'selected' : true,
|
|
}];
|
|
// 表单页数
|
|
tablePageNum = 1;
|
|
// 表单数据
|
|
tableData: any;
|
|
userInfo: any;
|
|
// 左侧菜单栏数据
|
|
leftMenuData: any = [];
|
|
// 侧边菜单展示开关
|
|
isCollapse = true;
|
|
loading = false;
|
|
isVisible = false;
|
|
visibleUpdatePwd = false;
|
|
// 当前顶级菜单
|
|
currentParentMenu: any = {};
|
|
downloadType = 1;
|
|
interval: any;
|
|
showComponent = false;
|
|
|
|
validateForm: FormGroup<{
|
|
oldPassword: FormControl<string>;
|
|
newPassword: FormControl<string>;
|
|
checkPassword: FormControl<string>;
|
|
}>
|
|
|
|
constructor(
|
|
private commonService: CommonService,
|
|
private storage: BrowserStorageService,
|
|
private communicationService: CommunicationService,
|
|
private fb: NonNullableFormBuilder,
|
|
private nzConfigService: NzConfigService,
|
|
private fileService: FileService,
|
|
private message: NzMessageService,
|
|
private orderGoodsService: OrderGoodsService,
|
|
private modal: NzModalService,
|
|
private router: Router, // 路由
|
|
private login: LoginService
|
|
) {
|
|
this.validateForm = this.fb.group({
|
|
oldPassword: ['', [Validators.required]],
|
|
newPassword: ['', [Validators.required]],
|
|
checkPassword: ['', [Validators.required, this.confirmationValidator]],
|
|
});
|
|
|
|
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')
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
this.communicationService.currentMessage.subscribe(message => {
|
|
this.showComponent = true;
|
|
this.fileRecords();
|
|
this.findFileRecords(message.id);
|
|
this.downloadType = 2;
|
|
});
|
|
|
|
this.nzConfigService.set('button', { nzSize: 'large' })
|
|
this.nzConfigService.set('treeSelect', { nzSize: 'large' })
|
|
// 缓存数据字典
|
|
this.commonService.queryDictionary('','',(data: any) => {
|
|
dictionaryData.length = 0;
|
|
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'];
|
|
this.fileRecords();
|
|
}
|
|
|
|
|
|
submitForm(): void {
|
|
if (this.validateForm.valid) {
|
|
if (this.validateForm.value.newPassword != null) {
|
|
const isWeak = /(?=.*[0-9])(?=.*[a-zA-Z])([^]{8,})/.test(this.validateForm.value.newPassword );
|
|
console.log("是否弱密码!" , this.validateForm.value.newPassword)
|
|
console.log("是否弱密码!" , isWeak)
|
|
if (!isWeak) {
|
|
this.message.error('密码强度太弱,请重新输入');
|
|
return;
|
|
}
|
|
}
|
|
this.login.sendUserPass( this.validateForm.value , (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);
|
|
location.reload();
|
|
this.message.success("修改成功");
|
|
this.router.navigateByUrl('/login').then();
|
|
} else {
|
|
this.message.error(data['return_msg']);
|
|
}
|
|
});
|
|
} else {
|
|
Object.values(this.validateForm.controls).forEach(control => {
|
|
if (control.invalid) {
|
|
control.markAsDirty();
|
|
control.updateValueAndValidity({ onlySelf: true });
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
updateConfirmValidator(): void {
|
|
/** wait for refresh value */
|
|
Promise.resolve().then(() => this.validateForm.controls.checkPassword.updateValueAndValidity());
|
|
}
|
|
|
|
confirmationValidator: ValidatorFn = (control: AbstractControl): { [s: string]: boolean } => {
|
|
if (!control.value) {
|
|
return { required: true };
|
|
} else if (control.value !== this.validateForm.controls.newPassword.value) {
|
|
return { confirm: true, error: true };
|
|
}
|
|
return {};
|
|
};
|
|
|
|
// 选择操作
|
|
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);
|
|
location.reload();
|
|
|
|
this.router.navigateByUrl('/login').then();
|
|
} else {
|
|
this.message.error(data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 弹出下载记录
|
|
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 || data['return_data'].status == 3) {
|
|
this.showComponent = false;
|
|
clearTimeout(this.interval);
|
|
this.downloadType = 1;
|
|
this.fileRecords();
|
|
}
|
|
}else {
|
|
this.showComponent = false;
|
|
clearTimeout(this.interval);
|
|
this.fileRecords();
|
|
this.downloadType = 1;
|
|
}
|
|
}), 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
// 下载
|
|
public getDownLoad(id: number) {
|
|
this.fileService.getDownLoad(id, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.fileRecords();
|
|
window.open(data['return_data']);
|
|
}else {
|
|
this.message.error(data['return_msg']);
|
|
}
|
|
})
|
|
}
|
|
|
|
// 打开抽屉
|
|
openUpdatePwd(): void {
|
|
this.visibleUpdatePwd = true;
|
|
}
|
|
|
|
}
|
|
|