From beb234c28d0cff69a5e0074b656bf5e56e716afe Mon Sep 17 00:00:00 2001 From: yuanye Date: Fri, 12 Mar 2021 17:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/merchant/merchant-routing.module.ts | 11 ++ src/app/admin/merchant/merchant.module.ts | 14 ++ .../user/user-list/user-list.component.html | 22 +++- .../user/user-list/user-list.component.ts | 123 ++++++++++-------- src/app/services/icon.service.ts | 2 +- src/app/services/user.service.ts | 12 ++ 6 files changed, 128 insertions(+), 56 deletions(-) create mode 100644 src/app/admin/merchant/merchant-routing.module.ts create mode 100644 src/app/admin/merchant/merchant.module.ts diff --git a/src/app/admin/merchant/merchant-routing.module.ts b/src/app/admin/merchant/merchant-routing.module.ts new file mode 100644 index 0000000..fb80d06 --- /dev/null +++ b/src/app/admin/merchant/merchant-routing.module.ts @@ -0,0 +1,11 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + + +const routes: Routes = []; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class MerchantRoutingModule { } diff --git a/src/app/admin/merchant/merchant.module.ts b/src/app/admin/merchant/merchant.module.ts new file mode 100644 index 0000000..0502df4 --- /dev/null +++ b/src/app/admin/merchant/merchant.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { MerchantRoutingModule } from './merchant-routing.module'; + + +@NgModule({ + declarations: [], + imports: [ + CommonModule, + MerchantRoutingModule + ] +}) +export class MerchantModule { } diff --git a/src/app/admin/user/user-list/user-list.component.html b/src/app/admin/user/user-list/user-list.component.html index 314710d..e6f9e9c 100644 --- a/src/app/admin/user/user-list/user-list.component.html +++ b/src/app/admin/user/user-list/user-list.component.html @@ -22,6 +22,17 @@ +
+ + 用户状态 + + + + + + + +
注册时间 @@ -65,7 +76,7 @@ 性别 金币数量 注册时间 - 状态 + 状态 操作 @@ -82,12 +93,15 @@ {{data.regTime | date: 'yyyy-MM-dd HH:mm'}} {{data.status ===1 ? '正常' : '禁用'}} - + + - + -
+ + + diff --git a/src/app/admin/user/user-list/user-list.component.ts b/src/app/admin/user/user-list/user-list.component.ts index 8008eb1..914625d 100644 --- a/src/app/admin/user/user-list/user-list.component.ts +++ b/src/app/admin/user/user-list/user-list.component.ts @@ -1,68 +1,89 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {FormBuilder, FormGroup} from '@angular/forms'; import {UserService} from '../../../services/user.service'; import {NzMessageService} from 'ng-zorro-antd'; +import {IconService} from '../../../services/icon.service'; +import {CommonsService} from '../../../services/commons.service'; @Component({ - selector: 'app-user-list', - templateUrl: './user-list.component.html', - styleUrls: ['./user-list.component.scss'] + selector: 'app-user-list', + templateUrl: './user-list.component.html', + styleUrls: ['./user-list.component.scss'] }) export class UserListComponent implements OnInit { - searchForm: FormGroup; // 搜索框 - requestData = []; // 列表数据 - total: number; // 页码 - pageNum = 1; // 页码 - pageSize = 10; // 条码 - loading = true; - regTime; - constructor( - private form: FormBuilder, - private user: UserService, - private message: NzMessageService - ) { } + searchForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + regTime; - ngOnInit(): void { - this.init(); - } + constructor( + private form: FormBuilder, + private user: UserService, + private iconService: IconService, + private message: NzMessageService, + private common: CommonsService + ) { + } + + ngOnInit(): void { + this.init(); + } + + public init(): void { + this.searchForm = this.form.group({ + name: [null], + status: [null], + phone: [null], + regTime: [null], + }); + this.getRequest(true, this.searchForm.value); + } - public init(): void { - this.searchForm = this.form.group({ - name: [null], - phone: [null], - regTime: [null], - }); - this.getRequest(true , this.searchForm.value); - } + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { - // 查询列表 - public getRequest(reset: boolean = false , whereObject: object) { + if (whereObject['regTime'] != null && whereObject['regTime'].length !== 0) { + whereObject['regTimeStart'] = whereObject['regTime'][0].getTime(); + whereObject['regTimeEnd'] = whereObject['regTime'][1].getTime(); + } + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.user.getListUser(whereObject, data => { + console.log(data); + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } - if (whereObject['regTime'] != null && whereObject['regTime'].length !== 0) { - whereObject['regTimeStart'] = whereObject['regTime'][0]; - whereObject['regTimeEnd'] = whereObject['regTime'][1]; + // 重置 + public resetForm(): void { + this.searchForm.reset(); } - this.loading = false; - if (reset) { - this.pageNum = 1; + + public getForbiddenUser(id, status: any): void { + const message = (status === 1 ? '是否禁用当前用户' : '是否启用当前用户'); + + this.common.showConfirm(message, data => { + if (data) { + this.user.forbiddenUser(id, dataUser => { + console.log(dataUser); + this.getRequest(false , this.searchForm.value); + }); + } + }); } - whereObject['pageNum'] = this.pageNum; - whereObject['pageSize'] = this.pageSize; - this.user.getListUser( whereObject, data => { - console.log(data); - if (data['return_code'] === '000000') { - this.requestData = data['return_data'].list; - this.total = data['return_data'].total; - } else { - this.message.error(data['return_msg']); - } - }); - } - // 重置 - public resetForm(): void { - this.searchForm.reset(); - } } diff --git a/src/app/services/icon.service.ts b/src/app/services/icon.service.ts index 0ee2b85..d5e0a2d 100644 --- a/src/app/services/icon.service.ts +++ b/src/app/services/icon.service.ts @@ -12,7 +12,7 @@ export class IconService { constructor(private iconService: NzIconService) { this.iconService.fetchFromIconfont({ - scriptUrl: 'https://at.alicdn.com/t/font_2413274_o08racrjdz.js' + scriptUrl: 'https://at.alicdn.com/t/font_2413274_zk7ae4qcrvg.js' }); } } diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index 4901d18..6321d17 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -48,4 +48,16 @@ export class UserService { }); } + /** + * 禁用启用当前用户 + * + * @param userId 用户id + * @param callBack 返回参数 + */ + public forbiddenUser(userId: number, callBack) { + this.http.get(environment.baseUrl + 'highUser/forbiddenUser?userId=' + userId).subscribe(data => { + callBack(data); + }); + } + }