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.
83 lines
2.3 KiB
83 lines
2.3 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';
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
|
import {Commons} from '../../commons';
|
|
|
|
@Component({
|
|
selector: 'app-visitor',
|
|
templateUrl: './visitor.component.html',
|
|
styleUrls: ['./visitor.component.scss']
|
|
})
|
|
export class VisitorComponent extends Commons implements OnInit, MessageInterface {
|
|
|
|
constructor(private visitorService: VisitorService,
|
|
private messageUtil: MessageUtil,
|
|
private cookieService: CookieService,
|
|
private abstractRoute: AbstractRoute,
|
|
private router: Router,
|
|
private fb: FormBuilder,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
// 查询表单
|
|
queryForm = this.fb.group({
|
|
// 查询预约人
|
|
appointment: this.fb.control('', [Validators.required]),
|
|
});
|
|
|
|
// 访客信息
|
|
visitors: Page<Visitor>;
|
|
// 审核状态
|
|
uncheck = 'uncheck';
|
|
ok = 'ok';
|
|
fail = 'fail';
|
|
// 当前页数
|
|
currentPage = 1;
|
|
|
|
// 加载访客信息
|
|
loadAll(page) {
|
|
this.currentPage = page;
|
|
this.visitorService.loadAll(Object.assign(this.queryForm.value, {currentPage: 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');
|
|
}
|
|
}
|
|
|
|
form(): FormGroup {
|
|
return this.queryForm;
|
|
}
|
|
|
|
}
|
|
|