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.
 
 
 
 
pocketcommunityweb/src/app/account/score/score.component.ts

86 lines
2.1 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';
@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;
}
}