增加信用分管理界面

change
panqihua 5 years ago
parent a66ed99ed8
commit e83754d8dc
  1. 22
      src/app/AbstractRoute.ts
  2. 9
      src/app/account/account/account.module.ts
  3. 16
      src/app/account/login/login.component.ts
  4. 7
      src/app/account/register/register.component.ts
  5. 8
      src/app/account/resetpwd/resetpwd.component.ts
  6. 110
      src/app/account/score/score.component.html
  7. 0
      src/app/account/score/score.component.scss
  8. 25
      src/app/account/score/score.component.spec.ts
  9. 86
      src/app/account/score/score.component.ts
  10. 16
      src/app/account/score/score.service.spec.ts
  11. 36
      src/app/account/score/score.service.ts
  12. 3
      src/app/app-routing.module.ts
  13. 39
      src/app/app.component.html
  14. 7
      src/app/app.component.ts
  15. 11
      src/app/app.module.ts
  16. 1
      src/app/commons.ts
  17. 7
      src/app/forum/forum.module.ts
  18. 42
      src/app/forum/forum/forum.component.html
  19. 1
      src/app/forum/forum/forum.component.scss
  20. 12
      src/app/forum/forum/forum.component.ts
  21. 18
      src/app/forum/notice/notice.component.ts
  22. 10
      src/app/interface/ForumType.ts
  23. 6
      src/app/interface/HttpInterface.ts
  24. 6
      src/app/interface/Response.ts
  25. 25
      src/app/page/page.component.html
  26. 0
      src/app/page/page.component.scss
  27. 25
      src/app/page/page.component.spec.ts
  28. 38
      src/app/page/page.component.ts
  29. 20
      src/app/page/page/page.module.ts
  30. 4
      src/app/visitor/visitor.module.ts
  31. 37
      src/assets/i18n/en-US.json
  32. 31
      src/assets/i18n/zh-CN.json

@ -1,6 +1,6 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {NavigationStart, Router} from '@angular/router'; import {NavigationEnd, Router} from '@angular/router';
import {filter} from 'rxjs/operators'; import {filter} from 'rxjs/operators';
import {environment} from '../environments/environment'; import {environment} from '../environments/environment';
import {CookieService} from 'ngx-cookie-service'; import {CookieService} from 'ngx-cookie-service';
@ -14,26 +14,22 @@ import {RouteInterface} from './RouteInterface';
}) })
export class AbstractRoute { export class AbstractRoute {
// 登陆状态 navStart: Observable<NavigationEnd>;
isLogin = false;
// 当前登陆账户
managerName = null;
navStart: Observable<NavigationStart>;
constructor( constructor(
private router: Router, private router: Router,
private cookieService: CookieService private cookieService: CookieService
) { ) {
this.navStart = router.events.pipe( this.navStart = router.events.pipe(
filter(evt => evt instanceof NavigationStart) filter(evt => evt instanceof NavigationEnd)
) as Observable<NavigationStart>; ) as Observable<NavigationEnd>;
} }
checkUser(routeInterface: RouteInterface): void { isLogin(): boolean {
this.isLogin = this.cookieService.check(environment.tokenKey); return this.cookieService.check(environment.tokenKey);
this.managerName = this.cookieService.get(environment.managerKey); }
this.navStart.subscribe(evt => routeInterface.doNavigationStart(evt, this.isLogin, this.managerName)); checkUser(routeInterface: RouteInterface): void {
this.navStart.subscribe(evt => routeInterface.doNavigationStart(evt, this.isLogin(), this.cookieService.get(environment.managerKey)));
} }
} }

@ -8,9 +8,12 @@ import {RegisterComponent} from '../register/register.component';
import {ResetpwdComponent} from '../resetpwd/resetpwd.component'; import {ResetpwdComponent} from '../resetpwd/resetpwd.component';
import {TranslateModule} from '@ngx-translate/core'; import {TranslateModule} from '@ngx-translate/core';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {ReactiveFormsModule} from '@angular/forms'; import {FormsModule, ReactiveFormsModule} from '@angular/forms';
// 提示框组件 // 提示框组件
import {MessageComponent} from '../../message/message.component'; import {MessageComponent} from '../../message/message.component';
import {ScoreComponent} from '../score/score.component';
import {PageModule} from '../../page/page/page.module';
// import {InputComponent} from '../../input/input.component'; // import {InputComponent} from '../../input/input.component';
@ -18,12 +21,14 @@ import {MessageComponent} from '../../message/message.component';
* *
*/ */
@NgModule({ @NgModule({
declarations: [LoginComponent, RegisterComponent, ResetpwdComponent, MessageComponent], declarations: [LoginComponent, RegisterComponent, ResetpwdComponent, ScoreComponent, MessageComponent],
imports: [ imports: [
CommonModule, CommonModule,
TranslateModule, TranslateModule,
RouterModule, RouterModule,
ReactiveFormsModule, ReactiveFormsModule,
FormsModule,
PageModule
] ]
}) })
export class AccountModule { export class AccountModule {

@ -7,6 +7,7 @@ import {Result} from '../../interface/Result';
import {environment} from '../../../environments/environment'; import {environment} from '../../../environments/environment';
import {CookieService} from 'ngx-cookie-service'; import {CookieService} from 'ngx-cookie-service';
import {MessageInterface, MessageUtil} from '../../message/message.service'; import {MessageInterface, MessageUtil} from '../../message/message.service';
import {AbstractRoute} from '../../AbstractRoute';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
@ -28,14 +29,12 @@ export class LoginComponent extends Commons implements OnInit, MessageInterface
private router: Router, private router: Router,
private loginService: LoginService, private loginService: LoginService,
private cookieService: CookieService, private cookieService: CookieService,
private messageUtil: MessageUtil private messageUtil: MessageUtil,
private abstractRoute: AbstractRoute
) { ) {
super(); super();
} }
ngOnInit(): void {
}
// 登陆方法 // 登陆方法
login() { login() {
@ -49,7 +48,7 @@ export class LoginComponent extends Commons implements OnInit, MessageInterface
time.setTime(r.managerToken.useTime); time.setTime(r.managerToken.useTime);
this.cookieService.set(environment.managerKey, r.managerToken.managerName, time); this.cookieService.set(environment.managerKey, r.managerToken.managerName, time);
this.cookieService.set(environment.tokenKey, r.managerToken.token, time); this.cookieService.set(environment.tokenKey, r.managerToken.token, time);
location.href = '/forum'; this.router.navigateByUrl('/forum');
} else { } else {
this.messageUtil.danger(this.prefix(r.message)); this.messageUtil.danger(this.prefix(r.message));
} }
@ -57,6 +56,13 @@ export class LoginComponent extends Commons implements OnInit, MessageInterface
} }
ngOnInit(): void {
if (this.abstractRoute.isLogin()) {
this.router.navigateByUrl('/forum');
}
}
form(): FormGroup { form(): FormGroup {
return this.loginForm; return this.loginForm;
} }

@ -77,14 +77,9 @@ export class RegisterComponent extends Commons implements OnInit, MessageInterfa
} }
ngOnInit(): void { ngOnInit(): void {
this.validForm = {};
for (const key of Object.keys(this.registerForm.value)) {
this.validForm[key] = {
flag: false
};
}
} }
form(): FormGroup { form(): FormGroup {
return this.registerForm; return this.registerForm;
} }

@ -49,11 +49,6 @@ export class ResetpwdComponent extends Commons implements OnInit, MessageInterfa
super(); super();
} }
//
ngOnInit(): void {
}
// 检查邮箱 // 检查邮箱
checkEmail() { checkEmail() {
@ -154,4 +149,7 @@ export class ResetpwdComponent extends Commons implements OnInit, MessageInterfa
prefix(key: string): string { prefix(key: string): string {
return 'server.resetpwd.' + key; return 'server.resetpwd.' + key;
} }
ngOnInit(): void {
}
} }

@ -0,0 +1,110 @@
<!--设置高度,添加bootstrap样式类d-flex align-items-center 使表单垂直居中,justify-content-center水平居中-->
<div class="">
<form [formGroup]="scoreFrom">
<!-- 用户名-->
<div class="input-group mb-3 mx-auto col-4">
<div class="input-group-prepend">
<span class="input-group-text">{{ prefix('username') | translate }}</span>
</div>
<input type="text" class="form-control text-center" [class.is-invalid]="getValue('username').invalid"
[placeholder]="'tip.input' | translate:{value:prefix('username')|translate}"
formControlName="username" aria-label="username"/>
<select class="custom-select" formControlName="like" aria-label="like">
<option value="true">{{prefix('search_is_like')|translate}}</option>
<option value="false">{{prefix('search_is_not_like')|translate}}</option>
</select>
<div class="input-group-prepend">
<button class="btn btn-outline-secondary" type="button" [disabled]="form().invalid"
(click)="loadAll(1)">{{'button.search'|translate}}</button>
</div>
</div>
</form>
<app-page [pageData]="users" [currentPage]="currentPage" (voted)="loadAll($event)"></app-page>
<table class="table">
<thead>
<tr>
<th scope="col" class="text-center">{{prefix('username')|translate}}</th>
<th scope="col" class="text-center">{{prefix('score')|translate}}</th>
<th scope="col" class="text-center">{{prefix('action')|translate}}</th>
</tr>
</thead>
<tbody>
<ng-container *ngIf="users">
<tr *ngFor="let user of users.list">
<td class="text-center">{{user.username}}</td>
<td class="text-center">{{user.creditScore}}</td>
<td class="text-center">
<div class="text-center">
<button class="btn btn-outline-info mr-3" data-toggle="modal" data-target="#exampleModal"
(click)="editForm.get('username').setValue(user.username);editForm.get('beforeScore').setValue(user.creditScore)">{{prefix('changeScore')|translate}}</button>
</div>
</td>
</tr>
</ng-container>
</tbody>
</table>
<app-page [pageData]="users" [currentPage]="currentPage" (voted)="loadAll($event)"></app-page>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{prefix('changeScore')|translate}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form [formGroup]="editForm">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">{{ prefix('username') | translate }}</span>
</div>
<input type="text" class="form-control" readonly="readonly" formControlName="username">
</div>
<div class="input-group mb-3">
<span class="input-group-text">{{ prefix('targetScore') | translate }}</span>
<input type="number" class="form-control"
[placeholder]="'tip.input' | translate:{value:prefix('changeScore')|translate}"
formControlName="score"
[class.is-invalid]="editForm.get('score').invalid">
<span class="input-group-text text-danger bg-transparent">{{ prefix('tip') | translate }}</span>
<div class="invalid-feedback font-weight-bold text-center">
{{'tip.notnull' | translate:{value: prefix('changeScore')|translate} }}
</div>
</div>
<span>{{prefix('score_tip')|translate:{
beforeScore: editForm.get('beforeScore').value,
afterScore: editForm.get('beforeScore').value + editForm.get('score').value
} }}</span>
<div class="input-group mb-3">
<span class="input-group-text">{{ prefix('notes') | translate }}</span>
<input type="text" class="form-control"
[placeholder]="'tip.input' | translate:{value:prefix('notes')|translate}" formControlName="notes"
[class.is-invalid]="editForm.get('notes').invalid">
<div class="invalid-feedback font-weight-bold text-center">
{{'tip.notnull' | translate:{value: prefix('notes')|translate} }}
</div>
</div>
</form>
</div>
<div class="modal-footer mx-auto">
<button type="button" class="btn btn-secondary" data-dismiss="modal"
(click)="editForm.reset()">{{'button.back'|translate}}</button>
<button type="button" class="btn btn-primary" data-dismiss="modal"
(click)="editScore()">{{'button.submit'|translate}}</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,25 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {ScoreComponent} from './score.component';
describe('ScoreComponent', () => {
let component: ScoreComponent;
let fixture: ComponentFixture<ScoreComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ScoreComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ScoreComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,86 @@
import {Component, OnInit} from '@angular/core';
import {Commons} from '../../commons';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {ScoreService} from './score.service';
import {MessageInterface, MessageUtil} from '../../message/message.service';
import {Page} from '../../interface/Page';
import {Info} from '../../interface/Info';
@Component({
selector: 'app-score',
templateUrl: './score.component.html',
styleUrls: ['./score.component.scss']
})
export class ScoreComponent extends Commons implements OnInit, MessageInterface {
scoreFrom = this.fb.group({
// 用户名
username: this.fb.control('', [Validators.required]),
// 是否模糊查询
like: this.fb.control(true, [Validators.required]),
});
editForm = this.fb.group({
// 用户名
username: this.fb.control('', [Validators.required]),
// 修改分数
score: this.fb.control('', [Validators.required]),
// 用户分数
beforeScore: this.fb.control('', [Validators.required]),
// 备注信息
notes: this.fb.control('', [Validators.required]),
});
currentPage = 1;
constructor(
private fb: FormBuilder,
private scoreService: ScoreService,
private messageUtil: MessageUtil
) {
super();
}
// 用户信息
users: Page<Info>;
// 加载用户信息
loadAll($currentPage) {
this.currentPage = $currentPage;
this.scoreService.loadAll(Object.assign(this.scoreFrom.value, {currentPage: $currentPage}))
.subscribe(res => {
// this.messageUtil.alert(this.prefix(res.message));
this.users = res.myInfos;
});
}
// 修改信用分
editScore() {
this.scoreService.editScore(this.editForm.value).subscribe(
res => {
this.editForm.reset();
this.messageUtil.alert(this.prefix(res.message));
this.loadAll(1);
}
);
}
ngOnInit(): void {
this.loadAll(this.currentPage);
}
prefix(key: string): string {
return 'score.' + key;
}
changePage() {
if (this.currentPage > this.users.totalPage) {
this.currentPage = this.users.currentPage;
}
}
form(): FormGroup {
return this.scoreFrom;
}
}

@ -0,0 +1,16 @@
import {TestBed} from '@angular/core/testing';
import {ScoreService} from './score.service';
describe('ScoreService', () => {
let service: ScoreService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ScoreService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

@ -0,0 +1,36 @@
import {Injectable} from '@angular/core';
import {JSONRequest} from '../../interface/JSONRequest';
import {Observable} from 'rxjs';
import {UserResponse} from '../../interface/Response';
import {HttpClient} from '@angular/common/http';
import {HttpInterface} from '../../interface/HttpInterface';
import {catchError} from 'rxjs/operators';
/**
*
*/
@Injectable({
providedIn: 'root'
})
export class ScoreService extends JSONRequest {
constructor(private http: HttpClient) {
super();
}
// 加载所有用户
loadAll(body): Observable<UserResponse> {
return this.http.get(HttpInterface.user, Object.assign(this.httpOptions, {
params: body
})).pipe(
catchError(this.handleError<any>('加载访客信息'))
);
}
// 修改信用分
editScore(body): Observable<UserResponse> {
return this.http.post(HttpInterface.score, body, this.httpOptions).pipe(
catchError(this.handleError<any>('修改信用分'))
);
}
}

@ -6,6 +6,7 @@ import {ResetpwdComponent} from './account/resetpwd/resetpwd.component';
import {ForumComponent} from './forum/forum/forum.component'; import {ForumComponent} from './forum/forum/forum.component';
import {NoticeComponent} from './forum/notice/notice.component'; import {NoticeComponent} from './forum/notice/notice.component';
import {VisitorComponent} from './visitor/visitor/visitor.component'; import {VisitorComponent} from './visitor/visitor/visitor.component';
import {ScoreComponent} from './account/score/score.component';
// 路由配置 // 路由配置
export const routes: Routes = [ export const routes: Routes = [
@ -21,6 +22,8 @@ export const routes: Routes = [
{path: 'notice', component: NoticeComponent}, {path: 'notice', component: NoticeComponent},
// 访客管理 // 访客管理
{path: 'visitor', component: VisitorComponent}, {path: 'visitor', component: VisitorComponent},
// 信用分管理
{path: 'score', component: ScoreComponent},
// 自动重定向到登陆 // 自动重定向到登陆
{path: '', redirectTo: 'login', pathMatch: 'full'} {path: '', redirectTo: 'login', pathMatch: 'full'}
]; ];

@ -1,25 +1,36 @@
<nav class="navbar navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<span class="navbar-text"> <span class="navbar-text">
{{ 'APP_TITLE' | translate }} {{ 'APP_TITLE' | translate }}
</span> </span>
<ng-container *ngIf="isLogin">
<a [routerLink]="['/forum']">{{ 'forum.name' | translate }}</a>
<a [routerLink]="['/visitor']">{{ 'visitor.name' | translate }}</a>
</ng-container>
<div class="dropdown"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" <ng-container *ngIf="isLogin">
aria-haspopup="true" aria-expanded="false"> <ul class="navbar-nav mx-auto">
{{ 'language' | translate }} <li class="nav-item" routerLinkActive="active">
</a> <a class="nav-link" [routerLink]="['/forum']">{{ 'forum.name' | translate }}</a>
</li>
<li class="nav-item" routerLinkActive="active">
<a class="nav-link" [routerLink]="['/visitor']">{{ 'visitor.name' | translate }}</a>
</li>
<li class="nav-item" routerLinkActive="active">
<a class="nav-link" [routerLink]="['/score']">{{ 'score.name' | translate }}</a>
</li>
</ul>
</ng-container>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <div class="dropdown">
<a class="dropdown-item" (click)="translate.use('zh-CN')">{{ 'chinese' | translate }}</a> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
<a class="dropdown-item" (click)="translate.use('en-US')">{{ 'english' | translate }}</a> aria-haspopup="true" aria-expanded="false">
{{ 'language' | translate }}
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" (click)="translate.use('zh-CN')">{{ 'chinese' | translate }}</a>
<a class="dropdown-item" (click)="translate.use('en-US')">{{ 'english' | translate }}</a>
</div>
</div> </div>
</div> </div>
</nav> </nav>
<nav class="navbar navbar-light bg-light justify-content-end"> <nav class="navbar navbar-light bg-light justify-content-end">

@ -51,7 +51,7 @@ export class AppComponent implements OnInit, MessageInterface {
this.loginService.logout({managerName: this.managerName}).subscribe(r => { this.loginService.logout({managerName: this.managerName}).subscribe(r => {
if (r.result === Result.OK) { if (r.result === Result.OK) {
this.cookieService.deleteAll(); this.cookieService.deleteAll();
location.href = '/login'; this.router.navigateByUrl('/login');
this.messageUtil.info(this.prefix(r.message)); this.messageUtil.info(this.prefix(r.message));
} else { } else {
this.messageUtil.danger(this.prefix(r.message)); this.messageUtil.danger(this.prefix(r.message));
@ -67,11 +67,6 @@ export class AppComponent implements OnInit, MessageInterface {
doNavigationStart(evt: RouterEvent, isLogin: boolean, managerName: string) { doNavigationStart(evt: RouterEvent, isLogin: boolean, managerName: string) {
that.isLogin = isLogin; that.isLogin = isLogin;
that.managerName = managerName; that.managerName = managerName;
if (isLogin && evt.url === '/login') {
that.router.navigateByUrl('/forum');
} else if (!isLogin && evt.url === '/forum') {
that.router.navigateByUrl('/login');
}
} }
}); });

@ -4,8 +4,6 @@ import {NgModule} from '@angular/core';
import {AppRoutingModule} from './app-routing.module'; import {AppRoutingModule} from './app-routing.module';
// 主框架 // 主框架
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
// 响应式表单
import {ReactiveFormsModule} from '@angular/forms';
// 国际化支持 // 国际化支持
import {TranslateLoader, TranslateModule} from '@ngx-translate/core'; import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader'; import {TranslateHttpLoader} from '@ngx-translate/http-loader';
@ -22,7 +20,8 @@ import {VisitorModule} from './visitor/visitor.module';
// Http请求模块 // Http请求模块
import {HttpClient, HttpClientModule} from '@angular/common/http'; import {HttpClient, HttpClientModule} from '@angular/common/http';
import {HtmlPipe} from './html.pipe'; import {HtmlPipe} from './html.pipe';
import {NoticeComponent} from './forum/notice/notice.component'; import {FormsModule} from '@angular/forms';
import {PageModule} from './page/page/page.module';
export function HttpLoaderFactory(http: HttpClient) { export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http); return new TranslateHttpLoader(http);
@ -36,15 +35,14 @@ export function HttpLoaderFactory(http: HttpClient) {
AppComponent, AppComponent,
ErrorComponent, ErrorComponent,
HtmlPipe, HtmlPipe,
NoticeComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule, AppRoutingModule,
ReactiveFormsModule,
AccountModule, AccountModule,
ForumModule, ForumModule,
VisitorModule, VisitorModule,
PageModule,
HttpClientModule, HttpClientModule,
TranslateModule.forRoot({ TranslateModule.forRoot({
loader: { loader: {
@ -52,7 +50,8 @@ export function HttpLoaderFactory(http: HttpClient) {
useFactory: HttpLoaderFactory, useFactory: HttpLoaderFactory,
deps: [HttpClient] deps: [HttpClient]
} }
}) }),
FormsModule
], ],
providers: [CookieService], providers: [CookieService],
bootstrap: [AppComponent] bootstrap: [AppComponent]

@ -5,7 +5,6 @@ export abstract class Commons {
// 页面高度=屏幕的高度/2 // 页面高度=屏幕的高度/2
height = 'height:' + screen.height / 2 + 'px'; height = 'height:' + screen.height / 2 + 'px';
validForm;
/** /**
* *

@ -4,20 +4,23 @@ import {CommonModule} from '@angular/common';
import {ForumComponent} from './forum/forum.component'; import {ForumComponent} from './forum/forum.component';
import {TranslateModule} from '@ngx-translate/core'; import {TranslateModule} from '@ngx-translate/core';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {NoticeComponent} from './notice/notice.component';
import {ReactiveFormsModule} from '@angular/forms';
/** /**
* *
*/ */
@NgModule({ @NgModule({
declarations: [ForumComponent], declarations: [ForumComponent, NoticeComponent],
exports: [ exports: [
ForumComponent ForumComponent
], ],
imports: [ imports: [
CommonModule, CommonModule,
TranslateModule, TranslateModule,
RouterModule RouterModule,
ReactiveFormsModule
] ]
}) })
export class ForumModule { export class ForumModule {

@ -140,9 +140,11 @@
</div> </div>
<!-- 帖子底部--> <!-- 帖子底部-->
<div class="forum-footer border-info p-3 mb-3"> <div class="forum-footer border-info p-3 mb-3">
<h3
class="text-center">{{'forum.deadline'|translate:{date: getActive().registrationDeadline|date:dateFormat} }}</h3>
<h3 class="text-center">{{ 'forum.active_date' | translate:{ <h3 class="text-center">{{ 'forum.active_date' | translate:{
startDate: getActive().activeStartTime|date:'yyyy-MM-dd', startDate: getActive().activeStartTime|date:dateFormat,
endDate: getActive().activeEndTime|date:'yyyy-MM-dd' endDate: getActive().activeEndTime|date:dateFormat
} }}</h3> } }}</h3>
<h3 <h3
class="text-center">{{ 'forum.active_score' | translate:{score: getActive().activeScore} }}</h3> class="text-center">{{ 'forum.active_score' | translate:{score: getActive().activeScore} }}</h3>
@ -191,7 +193,7 @@
</div> </div>
<!-- 投诉时间--> <!-- 投诉时间-->
<h1 <h1
class="text-center">{{ 'forum.complaint_time' | translate:{time: getForum().time|date:'yyyy-MM-dd'} }}</h1> class="text-center">{{ 'forum.complaint_time' | translate:{time: getForum().time|date:dateFormat} }}</h1>
</div> </div>
</div> </div>
</ng-container> </ng-container>
@ -222,6 +224,40 @@
</div> </div>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="scoreType">
<!-- 发件人信息-->
<div class="position-absolute sender">
<!-- 发帖人头像-->
<img [src]="getForum().info.headImg" alt="headimg" class="headimg mb-3"/>
<!-- 发帖人-->
<div class="forum-label border-info mb-3 text-center">
{{getForum().username}}
</div>
<!--信用分-->
<div class="forum-label border-info mb-3 text-center">
{{getForum().info.creditScore}}
</div>
</div>
<!-- 帖子框架-->
<div>
<!-- 标题-->
<h1 class="text-info col-12 text-center mb-3 forum-title">{{getForum().title}}</h1>
<!-- 帖子正文-->
<div class="forum-content border-info overflow-auto col-9 offset-2 mb-3">
{{getForum().content}}
</div>
</div>
<!-- 帖子底部-->
<div class="forum-footer border-info p-3 mb-3">
<h3
class="text-center">{{ 'forum.active_score' | translate:{score: getScore().activeScore} }}</h3>
</div>
</ng-container>
</ng-container> </ng-container>
<!--帖子审核按钮--> <!--帖子审核按钮-->
<div class="col-12 text-center"> <div class="col-12 text-center">

@ -80,7 +80,6 @@
.forum-footer { .forum-footer {
border-style: solid; border-style: solid;
border-width: 3px; border-width: 3px;
height: 100px;
} }
//活动贴end //活动贴end

@ -2,7 +2,7 @@ import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {ForumService} from '../forum.service'; import {ForumService} from '../forum.service';
import {Result} from '../../interface/Result'; import {Result} from '../../interface/Result';
import {Active, Complaint, Forum} from '../../interface/ForumType'; import {Active, Complaint, Forum, Score} from '../../interface/ForumType';
import {Notice} from '../../interface/Notice'; import {Notice} from '../../interface/Notice';
import {MessageInterface, MessageUtil} from '../../message/message.service'; import {MessageInterface, MessageUtil} from '../../message/message.service';
import {NoticeService} from '../notice/notice.service'; import {NoticeService} from '../notice/notice.service';
@ -36,10 +36,14 @@ export class ForumComponent implements OnInit, MessageInterface {
// 帖子提示信息 // 帖子提示信息
loadPostsStatus = 'load_posts'; loadPostsStatus = 'load_posts';
// 日期格式
dateFormat = 'yyyy-MM-dd';
// 帖子类型 // 帖子类型
activeType = 'active'; activeType = 'active';
complanType = 'complan'; complanType = 'complan';
topicType = 'topic'; topicType = 'topic';
scoreType = 'score';
// 审核状态 // 审核状态
okType = 'ok'; okType = 'ok';
@ -69,6 +73,10 @@ export class ForumComponent implements OnInit, MessageInterface {
return this.getForum().complainDto; return this.getForum().complainDto;
} }
getScore(): Score {
return this.getForum().score;
}
/** /**
* *
*/ */
@ -102,7 +110,7 @@ export class ForumComponent implements OnInit, MessageInterface {
if (confirm(r)) { if (confirm(r)) {
this.noticeService.deleteNotice({id: noticeId}).subscribe(res => { this.noticeService.deleteNotice({id: noticeId}).subscribe(res => {
this.messageUtil.alert(this.prefix('notice.' + res.message)); this.messageUtil.alert(this.prefix('notice.' + res.message));
location.href = '/forum'; location.reload();
}); });
} }
}); });

@ -6,6 +6,7 @@ import {Result} from '../../interface/Result';
import {MessageInterface, MessageUtil} from '../../message/message.service'; import {MessageInterface, MessageUtil} from '../../message/message.service';
import {CookieService} from 'ngx-cookie-service'; import {CookieService} from 'ngx-cookie-service';
import {environment} from '../../../environments/environment'; import {environment} from '../../../environments/environment';
import {Router} from '@angular/router';
@Component({ @Component({
selector: 'app-notice', selector: 'app-notice',
@ -28,7 +29,8 @@ export class NoticeComponent extends Commons implements OnInit, MessageInterface
private fb: FormBuilder, private fb: FormBuilder,
private noticeService: NoticeService, private noticeService: NoticeService,
private messageUtil: MessageUtil, private messageUtil: MessageUtil,
private cookieService: CookieService private cookieService: CookieService,
private router: Router,
) { ) {
super(); super();
} }
@ -40,20 +42,11 @@ export class NoticeComponent extends Commons implements OnInit, MessageInterface
)).subscribe(res => { )).subscribe(res => {
this.messageUtil.alert(this.prefix(res.message)); this.messageUtil.alert(this.prefix(res.message));
if (res.result === Result.OK) { if (res.result === Result.OK) {
location.href = '/forum'; this.router.navigateByUrl('/login');
} }
}); });
} }
ngOnInit(): void {
this.validForm = {};
for (const key of Object.keys(this.noticeForm.value)) {
this.validForm[key] = {
flag: false
};
}
}
form(): FormGroup { form(): FormGroup {
return this.noticeForm; return this.noticeForm;
} }
@ -62,5 +55,8 @@ export class NoticeComponent extends Commons implements OnInit, MessageInterface
return 'server.forum.notice.' + key; return 'server.forum.notice.' + key;
} }
ngOnInit(): void {
}
} }

@ -32,6 +32,8 @@ export interface Forum {
activeDto: Active; activeDto: Active;
// 投诉贴信息 // 投诉贴信息
complainDto: Complaint; complainDto: Complaint;
// 结算信息
score: Score;
// 发帖人详情信息 // 发帖人详情信息
info: Info; info: Info;
} }
@ -45,6 +47,14 @@ export interface Active {
activeEndTime: number; activeEndTime: number;
// 活动奖励分 // 活动奖励分
activeScore: number; activeScore: number;
// 报名截止日期
registrationDeadline: number;
}
// 结算贴
export interface Score {
// 结算分数
activeScore: number;
} }
// 投诉帖 // 投诉帖

@ -29,7 +29,11 @@ const HttpInterface = {
// 删除公告 // 删除公告
deleteNotice: '/api/forum/notice/delete', deleteNotice: '/api/forum/notice/delete',
// 访客管理 // 访客管理
visitor: '/api/visitor' visitor: '/api/visitor',
// 用户管理
user: '/api/users',
// 编辑信用分
score: '/api/users/score'
}; };
for (const key of Object.keys(HttpInterface)) { for (const key of Object.keys(HttpInterface)) {

@ -5,6 +5,7 @@ import {Notice} from './Notice';
import {Forum} from './ForumType'; import {Forum} from './ForumType';
import {Page} from './Page'; import {Page} from './Page';
import {Visitor} from './Visitor'; import {Visitor} from './Visitor';
import {Info} from './Info';
export interface Response { export interface Response {
// 响应结果 // 响应结果
@ -59,3 +60,8 @@ export interface ForumNewResponse extends Response {
export interface VisitorResponse extends Response { export interface VisitorResponse extends Response {
visitorList: Page<Visitor>; visitorList: Page<Visitor>;
} }
// 用户信息响应
export interface UserResponse extends Response {
myInfos: Page<Info>;
}

@ -0,0 +1,25 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light justify-content-center" *ngIf="pageData">
<ul class="pagination mt-3">
<li class="page-item" [class.disabled]="pageData.currentPage==1">
<button class="page-link" (click)="loadAll(1)">{{'button.first_page'|translate}}</button>
</li>
<li class="page-item" [class.disabled]="pageData.currentPage==1">
<button class="page-link" (click)="loadAll(pageData.currentPage-1)">{{'button.prev_page'|translate}}</button>
</li>
<li class="page-item disabled"><a class="page-link" href="#">{{pageData.currentPage}}</a></li>
<li class="page-item" [class.disabled]="pageData.currentPage==pageData.totalPage">
<button class="page-link" (click)="loadAll(pageData.currentPage+1)">{{'button.next_page'|translate}}</button>
</li>
<li class="page-item" [class.disabled]="pageData.currentPage==pageData.totalPage">
<button class="page-link" (click)="loadAll(pageData.totalPage)">{{'button.last_page'|translate}}</button>
</li>
</ul>
<span class="navbar-text ml-3">
{{'button.total_page'|translate:{totalPage: pageData.totalPage, count: pageData.count} }}
</span>
<div class="collapse navbar-collapse col-2">
<input class="form-control" type="number" [attr.aria-label]="'button.jump'|translate" [(ngModel)]="currentPage"
(keyup)="changePage()"/>
<button class="btn btn-outline-success w-50" (click)="loadAll(currentPage)">{{'button.jump'|translate}}</button>
</div>
</nav>

@ -0,0 +1,25 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {PageComponent} from './page.component';
describe('PageComponent', () => {
let component: PageComponent;
let fixture: ComponentFixture<PageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [PageComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,38 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Page} from '../interface/Page';
@Component({
selector: 'app-page',
templateUrl: './page.component.html',
styleUrls: ['./page.component.scss']
})
export class PageComponent implements OnInit {
// 数据源
@Input()
pageData: Page<any>;
// 触发翻页事件
@Output()
voted = new EventEmitter<number>();
// 记录数
@Input()
currentPage: number;
constructor() {
}
ngOnInit(): void {
}
loadAll(page: number) {
this.voted.emit(page);
}
changePage() {
if (this.currentPage > this.pageData.totalPage) {
this.currentPage = this.pageData.currentPage;
}
}
}

@ -0,0 +1,20 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {PageComponent} from '../page.component';
import {FormsModule} from '@angular/forms';
import {TranslateModule} from '@ngx-translate/core';
@NgModule({
declarations: [PageComponent],
imports: [
CommonModule,
TranslateModule,
FormsModule,
],
exports: [
PageComponent
]
})
export class PageModule {
}

@ -3,6 +3,7 @@ import {CommonModule} from '@angular/common';
import {TranslateModule} from '@ngx-translate/core'; import {TranslateModule} from '@ngx-translate/core';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {VisitorComponent} from './visitor/visitor.component'; import {VisitorComponent} from './visitor/visitor.component';
import {ReactiveFormsModule} from '@angular/forms';
/** /**
@ -13,7 +14,8 @@ import {VisitorComponent} from './visitor/visitor.component';
imports: [ imports: [
CommonModule, CommonModule,
TranslateModule, TranslateModule,
RouterModule RouterModule,
ReactiveFormsModule
] ]
}) })
export class VisitorModule { export class VisitorModule {

@ -32,7 +32,8 @@
"plaintiff": "plaintiff", "plaintiff": "plaintiff",
"defendant": "defendant", "defendant": "defendant",
"notice_title": "notice title", "notice_title": "notice title",
"notice_content": "notice content" "notice_content": "notice content",
"deadline": "报名截止日期:{{date}}"
}, },
"visitor": { "visitor": {
"name": "访客预约管理", "name": "访客预约管理",
@ -67,9 +68,33 @@
"prev": "prev", "prev": "prev",
"next_page": "Next", "next_page": "Next",
"prev_page": "Previous", "prev_page": "Previous",
"first_page": "first page",
"last_page": "last page",
"check_code": "check_code", "check_code": "check_code",
"notice": "submit", "notice": "submit",
"back": "back" "back": "back",
"search": "search",
"jump": "jump",
"submit": "submit",
"total_page": "总页数:{{totalPage}},总记录数:{{count}}"
},
"score": {
"name": "信用分管理",
"username": "用户名",
"score": "信用分",
"action": "操作",
"search_is_like": "模糊搜索",
"search_is_not_like": "精确搜索",
"ok": "加载用户信息成功",
"fail": "加载用户信息失败",
"changeScore": "修改信用分",
"error_page": "非法页数",
"targetScore": "加减信用分",
"tip": "减分请输入负数",
"notes": "备注信息",
"edit_ok": "修改成功",
"edit_fail": "修改失败",
"score_tip": "当前用户信用分{{beforeScore}},预计变为{{afterScore}}分"
}, },
"server": { "server": {
"login": { "login": {
@ -120,11 +145,11 @@
"fail": "获取失败", "fail": "获取失败",
"check_ok": "审核成功", "check_ok": "审核成功",
"check_fail": "审核失败" "check_fail": "审核失败"
},
"visitor": {
"check_ok": "审核成功",
"check_fail": "审核失败"
} }
},
"visitor": {
"check_ok": "审核成功",
"check_fail": "审核失败"
} }
} }
} }

@ -24,7 +24,7 @@
"check": "待审核帖子", "check": "待审核帖子",
"sender": "公告管理员", "sender": "公告管理员",
"time": "公告时间", "time": "公告时间",
"active_date": "活动起止时间:{{startDate}}到{{endDate}}", "active_date": "活动起止日期:{{startDate}}到{{endDate}}",
"active_score": "参与活动奖励信用分:{{score}}", "active_score": "参与活动奖励信用分:{{score}}",
"approve": "审核通过", "approve": "审核通过",
"reject": "审核不通过", "reject": "审核不通过",
@ -32,7 +32,8 @@
"plaintiff": "投诉人", "plaintiff": "投诉人",
"defendant": "被投诉人", "defendant": "被投诉人",
"notice_title": "公告标题", "notice_title": "公告标题",
"notice_content": "公告内容" "notice_content": "公告内容",
"deadline": "报名截止日期:{{date}}"
}, },
"visitor": { "visitor": {
"name": "访客预约管理", "name": "访客预约管理",
@ -67,9 +68,33 @@
"prev": "上一步", "prev": "上一步",
"next_page": "下一页", "next_page": "下一页",
"prev_page": "上一页", "prev_page": "上一页",
"first_page": "首页",
"last_page": "尾页",
"check_code": "检查验证码", "check_code": "检查验证码",
"notice": "添加公告", "notice": "添加公告",
"back": "返回" "back": "返回",
"search": "检索",
"jump": "跳转",
"submit": "提交",
"total_page": "总页数:{{totalPage}},总记录数:{{count}}"
},
"score": {
"name": "信用分管理",
"username": "用户名",
"score": "信用分",
"action": "操作",
"search_is_like": "模糊搜索",
"search_is_not_like": "精确搜索",
"ok": "加载用户信息成功",
"fail": "加载用户信息失败",
"changeScore": "修改信用分",
"error_page": "非法页数",
"targetScore": "加减信用分",
"tip": "减分请输入负数",
"notes": "备注信息",
"edit_ok": "修改成功",
"edit_fail": "修改失败",
"score_tip": "当前用户信用分{{beforeScore}},预计变为{{afterScore}}分"
}, },
"server": { "server": {
"login": { "login": {

Loading…
Cancel
Save