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.
173 lines
4.4 KiB
173 lines
4.4 KiB
import { Component } from '@angular/core';
|
|
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule} from "@angular/forms";
|
|
import {NzMessageService} from "ng-zorro-antd/message";
|
|
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal";
|
|
import {UserService} from "../../../servies/account/user.service";
|
|
import {DatePipe, NgForOf, NgIf} from "@angular/common";
|
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
|
import {
|
|
NzTableCellDirective,
|
|
NzTableComponent,
|
|
NzTbodyComponent,
|
|
NzTheadComponent,
|
|
NzThMeasureDirective, NzTrDirective
|
|
} from "ng-zorro-antd/table";
|
|
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
|
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
|
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
|
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
|
|
|
|
@Component({
|
|
selector: 'app-user',
|
|
standalone: true,
|
|
imports: [
|
|
DatePipe,
|
|
NgForOf,
|
|
NzButtonComponent,
|
|
NzColDirective,
|
|
NzDividerComponent,
|
|
NzFormControlComponent,
|
|
NzFormDirective,
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzInputDirective,
|
|
NzRowDirective,
|
|
NzTableCellDirective,
|
|
NzTableComponent,
|
|
NzTbodyComponent,
|
|
NzThMeasureDirective,
|
|
NzTheadComponent,
|
|
NzTrDirective,
|
|
ReactiveFormsModule,
|
|
DictionaryPipe,
|
|
NzSelectComponent,
|
|
NzOptionComponent,
|
|
NzModalModule,
|
|
NgIf,
|
|
NzDropDownADirective,
|
|
NzDropDownDirective,
|
|
NzDropdownMenuComponent,
|
|
NzIconDirective,
|
|
NzMenuDirective,
|
|
NzMenuItemComponent,
|
|
],
|
|
templateUrl: './user.component.html',
|
|
styleUrl: './user.component.less'
|
|
})
|
|
export class UserComponent {
|
|
// 表单页数
|
|
tablePageNum = 1;
|
|
// 表单数据
|
|
tableData: any = {
|
|
total: 0,
|
|
list: [],
|
|
};
|
|
// 搜索表单
|
|
searchForm: FormGroup;
|
|
|
|
// 用户状态
|
|
userStatusArray = new DictionaryPipe().getDictionaryList("USER_STATUS");
|
|
constructor(private fb: NonNullableFormBuilder,
|
|
private userService: UserService,
|
|
private message: NzMessageService,
|
|
private modal: NzModalService) {
|
|
// 初始化搜索框
|
|
this.searchForm = this.fb.group({
|
|
name: [''],
|
|
phone: [''],
|
|
status: [''],
|
|
});
|
|
|
|
|
|
this.queryData();
|
|
}
|
|
|
|
queryData() {
|
|
this.searchForm.value.pageNum = this.tablePageNum;
|
|
this.searchForm.value.pageSize = 10;
|
|
this.searchForm.value.time = new Date().getTime();
|
|
this.userService.queryUserList(this.searchForm.value, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
this.tableData = data['return_data'];
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 搜索表单提交
|
|
*/
|
|
searchFormSubmit(): void {
|
|
this.tablePageNum = 1;
|
|
this.queryData();
|
|
}
|
|
|
|
/**
|
|
* 搜索表单重置
|
|
*/
|
|
searchFormReset(): void {
|
|
this.searchForm.reset();
|
|
}
|
|
|
|
/**
|
|
* 打开恢复账户确认框
|
|
*/
|
|
showRestore(dataId: number) {
|
|
this.modal.confirm({
|
|
nzTitle: '提示',
|
|
nzContent: '确定恢复账户状态?',
|
|
nzOnOk: () => this.restore(dataId)
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 恢复
|
|
*/
|
|
restore(dataId: number) {
|
|
const param = {
|
|
userId: dataId
|
|
}
|
|
this.userService.restore(param, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
// 刷新数据
|
|
this.queryData();
|
|
this.message.success("操作成功");
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 打开禁用账户确认框
|
|
*/
|
|
showDisable(dataId: number) {
|
|
this.modal.confirm({
|
|
nzTitle: '提示',
|
|
nzContent: '确定禁用账户吗?禁用后无法登录、交易!',
|
|
nzOnOk: () => this.disable(dataId)
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 禁用
|
|
*/
|
|
disable(dataId: number) {
|
|
const param = {
|
|
userId: dataId
|
|
}
|
|
this.userService.disable(param, (data: any) => {
|
|
if (data['return_code'] == '000000') {
|
|
// 刷新数据
|
|
this.queryData();
|
|
this.message.success("操作成功");
|
|
} else {
|
|
this.message.create('error', data['return_msg']);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|