From dc90b140745699a700f3f09d5485f95e9fa689f4 Mon Sep 17 00:00:00 2001
From: panqihua <1029559041@qq.com>
Date: Fri, 17 Apr 2020 18:44:18 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BF=E5=AE=A2=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/visitor/visitor.module.ts | 20 ++++++
.../visitor/visitor/visitor.component.html | 29 +++++++++
.../visitor/visitor/visitor.component.scss | 0
.../visitor/visitor/visitor.component.spec.ts | 25 ++++++++
src/app/visitor/visitor/visitor.component.ts | 61 +++++++++++++++++++
.../visitor/visitor/visitor.service.spec.ts | 16 +++++
src/app/visitor/visitor/visitor.service.ts | 36 +++++++++++
7 files changed, 187 insertions(+)
create mode 100644 src/app/visitor/visitor.module.ts
create mode 100644 src/app/visitor/visitor/visitor.component.html
create mode 100644 src/app/visitor/visitor/visitor.component.scss
create mode 100644 src/app/visitor/visitor/visitor.component.spec.ts
create mode 100644 src/app/visitor/visitor/visitor.component.ts
create mode 100644 src/app/visitor/visitor/visitor.service.spec.ts
create mode 100644 src/app/visitor/visitor/visitor.service.ts
diff --git a/src/app/visitor/visitor.module.ts b/src/app/visitor/visitor.module.ts
new file mode 100644
index 0000000..747398f
--- /dev/null
+++ b/src/app/visitor/visitor.module.ts
@@ -0,0 +1,20 @@
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {TranslateModule} from '@ngx-translate/core';
+import {RouterModule} from '@angular/router';
+import {VisitorComponent} from './visitor/visitor.component';
+
+
+/**
+ * 访客预约模块
+ */
+@NgModule({
+ declarations: [VisitorComponent],
+ imports: [
+ CommonModule,
+ TranslateModule,
+ RouterModule
+ ]
+})
+export class VisitorModule {
+}
diff --git a/src/app/visitor/visitor/visitor.component.html b/src/app/visitor/visitor/visitor.component.html
new file mode 100644
index 0000000..3448d52
--- /dev/null
+++ b/src/app/visitor/visitor/visitor.component.html
@@ -0,0 +1,29 @@
+
+
+
+ {{'visitor.username'|translate}} |
+ {{'visitor.time'|translate}} |
+ {{'visitor.notes'|translate}} |
+ {{'visitor.admin'|translate}} |
+ {{'visitor.status'|translate}} |
+ {{'visitor.action'|translate}} |
+
+
+
+
+
+ {{visitor.appointment}} |
+ {{visitor.time|date:'yyyy-MM-dd HH:mm'}} |
+ {{visitor.notes}} |
+ {{visitor.managerName}} |
+ {{'visitor.' + visitor.status|translate}} |
+
+
+
+
+
+ |
+
+
+
+
diff --git a/src/app/visitor/visitor/visitor.component.scss b/src/app/visitor/visitor/visitor.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/visitor/visitor/visitor.component.spec.ts b/src/app/visitor/visitor/visitor.component.spec.ts
new file mode 100644
index 0000000..ce50bf4
--- /dev/null
+++ b/src/app/visitor/visitor/visitor.component.spec.ts
@@ -0,0 +1,25 @@
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+
+import {VisitorComponent} from './visitor.component';
+
+describe('VisitorComponent', () => {
+ let component: VisitorComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [VisitorComponent]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(VisitorComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/visitor/visitor/visitor.component.ts b/src/app/visitor/visitor/visitor.component.ts
new file mode 100644
index 0000000..029500f
--- /dev/null
+++ b/src/app/visitor/visitor/visitor.component.ts
@@ -0,0 +1,61 @@
+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';
+
+@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
+ ) {
+ }
+
+ // 访客信息
+ visitors: Page;
+ // 审核状态
+ 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 {
+ this.loadAll(this.currentPage);
+ }
+
+}
diff --git a/src/app/visitor/visitor/visitor.service.spec.ts b/src/app/visitor/visitor/visitor.service.spec.ts
new file mode 100644
index 0000000..69d535c
--- /dev/null
+++ b/src/app/visitor/visitor/visitor.service.spec.ts
@@ -0,0 +1,16 @@
+import {TestBed} from '@angular/core/testing';
+
+import {VisitorService} from './visitor.service';
+
+describe('VisitorService', () => {
+ let service: VisitorService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(VisitorService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/visitor/visitor/visitor.service.ts b/src/app/visitor/visitor/visitor.service.ts
new file mode 100644
index 0000000..a76692c
--- /dev/null
+++ b/src/app/visitor/visitor/visitor.service.ts
@@ -0,0 +1,36 @@
+import {Injectable} from '@angular/core';
+import {JSONRequest} from '../../interface/JSONRequest';
+import {HttpClient} from '@angular/common/http';
+import {Observable} from 'rxjs';
+import {VisitorResponse} from '../../interface/Response';
+import {HttpInterface} from '../../interface/HttpInterface';
+import {catchError} from 'rxjs/operators';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class VisitorService extends JSONRequest {
+
+ constructor(private http: HttpClient) {
+ super();
+ }
+
+ // 加载访客信息
+ loadAll(page: number): Observable {
+ return this.http.get(HttpInterface.visitor, Object.assign(this.httpOptions, {
+ params: {
+ currentPage: page,
+ }
+ })).pipe(
+ catchError(this.handleError('加载访客信息'))
+ );
+ }
+
+ // 审核访客信息
+ check($id: string, $status: string, $managerName: string): Observable {
+ return this.http.post(HttpInterface.visitor, {id: $id, status: $status, managerName: $managerName}, this.httpOptions)
+ .pipe(
+ catchError(this.handleError('审核访客信息'))
+ );
+ }
+}