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.
69 lines
1.9 KiB
69 lines
1.9 KiB
import {Component, OnInit} from '@angular/core';
|
|
import {VisitorService} from './visitor.service';
|
|
import {Result} from '../../interface/Result';
|
|
import {MessageInterface, MessageUtil} from '../../message/message.service';
|
|
import {Visitor} from '../../interface/Visitor';
|
|
import {Page} from '../../interface/Page';
|
|
import {environment} from '../../../environments/environment';
|
|
import {CookieService} from 'ngx-cookie-service';
|
|
import {AbstractRoute} from '../../AbstractRoute';
|
|
import {Router} from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'app-visitor',
|
|
templateUrl: './visitor.component.html',
|
|
styleUrls: ['./visitor.component.scss']
|
|
})
|
|
export class VisitorComponent implements OnInit, MessageInterface {
|
|
|
|
constructor(private visitorService: VisitorService,
|
|
private messageUtil: MessageUtil,
|
|
private cookieService: CookieService,
|
|
private abstractRoute: AbstractRoute,
|
|
private router: Router,
|
|
) {
|
|
}
|
|
|
|
// 访客信息
|
|
visitors: Page<Visitor>;
|
|
// 审核状态
|
|
uncheck = 'uncheck';
|
|
ok = 'ok';
|
|
fail = 'fail';
|
|
// 当前页数
|
|
currentPage = 1;
|
|
|
|
// 加载访客信息
|
|
loadAll(page) {
|
|
this.currentPage = page;
|
|
this.visitorService.loadAll(page).subscribe(r => {
|
|
if (r.result === Result.OK) {
|
|
this.visitors = r.visitorList;
|
|
} else {
|
|
this.messageUtil.alert(r.message);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 审核访客信息
|
|
check(id, status) {
|
|
this.visitorService.check(id, status, this.cookieService.get(environment.managerKey))
|
|
.subscribe(res => {
|
|
this.messageUtil.alert(this.prefix(res.message));
|
|
this.loadAll(this.currentPage);
|
|
});
|
|
}
|
|
|
|
prefix(key: string): string {
|
|
return 'server.visitor.' + key;
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
if (this.abstractRoute.isLogin()) {
|
|
this.loadAll(this.currentPage);
|
|
} else {
|
|
this.router.navigateByUrl('/login');
|
|
}
|
|
}
|
|
|
|
}
|
|
|