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.
98 lines
2.5 KiB
98 lines
2.5 KiB
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';
|
|
import {AbstractRoute} from '../../AbstractRoute';
|
|
import {Router} from '@angular/router';
|
|
|
|
@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(''),
|
|
// 是否模糊查询
|
|
like: this.fb.control(true),
|
|
// 是否按照信用分排行
|
|
orderScore: this.fb.control(true),
|
|
// 是否降序
|
|
desc: this.fb.control(true)
|
|
});
|
|
|
|
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,
|
|
private abstractRoute: AbstractRoute,
|
|
private router: Router,
|
|
) {
|
|
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 {
|
|
if (this.abstractRoute.isLogin()) {
|
|
this.loadAll(this.currentPage);
|
|
} else {
|
|
this.router.navigateByUrl('/login');
|
|
}
|
|
}
|
|
|
|
prefix(key: string): string {
|
|
return 'score.' + key;
|
|
}
|
|
|
|
changePage() {
|
|
if (this.currentPage > this.users.totalPage) {
|
|
this.currentPage = this.users.currentPage;
|
|
}
|
|
}
|
|
|
|
form(): FormGroup {
|
|
return this.scoreFrom;
|
|
}
|
|
|
|
}
|
|
|