diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.html b/src/app/admin/merchant/merchant-detail/merchant-detail.component.html new file mode 100644 index 0000000..62ffba3 --- /dev/null +++ b/src/app/admin/merchant/merchant-detail/merchant-detail.component.html @@ -0,0 +1 @@ +

merchant-detail works!

diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.scss b/src/app/admin/merchant/merchant-detail/merchant-detail.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.spec.ts b/src/app/admin/merchant/merchant-detail/merchant-detail.component.spec.ts new file mode 100644 index 0000000..51c0eb3 --- /dev/null +++ b/src/app/admin/merchant/merchant-detail/merchant-detail.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MerchantDetailComponent } from './merchant-detail.component'; + +describe('MerchantDetailComponent', () => { + let component: MerchantDetailComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MerchantDetailComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MerchantDetailComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts b/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts new file mode 100644 index 0000000..e5f7006 --- /dev/null +++ b/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-merchant-detail', + templateUrl: './merchant-detail.component.html', + styleUrls: ['./merchant-detail.component.scss'] +}) +export class MerchantDetailComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/admin/merchant/merchant-edit/merchant-edit.component.html b/src/app/admin/merchant/merchant-edit/merchant-edit.component.html new file mode 100644 index 0000000..f641d58 --- /dev/null +++ b/src/app/admin/merchant/merchant-edit/merchant-edit.component.html @@ -0,0 +1,132 @@ + + + + 商户管理 + + + 编辑商户 + + + + + + +
+
+
+ + 登录手机号 + + + + +
+
+ + 登录密码 + + + + + + + + + +
+
+ + 商户编号 + + + + +
+
+ + 商户名称 + + + + +
+
+ + 联系电话 + + + + +
+
+ + 商户地址 + + + + +
+
+ + 银行名称 + + + + +
+
+ + 银行账号 + + + + +
+
+ + 开户人 + + + + +
+
+ + 商户LOGO + + + +
上传LOGO
+
+ + + + + +
+
+
+
+ + 商户简介 + + + + +
+
+
+
+ + +
+
+
+ +
diff --git a/src/app/admin/merchant/merchant-edit/merchant-edit.component.scss b/src/app/admin/merchant/merchant-edit/merchant-edit.component.scss new file mode 100644 index 0000000..ac60fb8 --- /dev/null +++ b/src/app/admin/merchant/merchant-edit/merchant-edit.component.scss @@ -0,0 +1,6 @@ +button { + margin-left: 8px; +} +:host ::ng-deep .ant-upload { + background-color: #ffffff; +} diff --git a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts new file mode 100644 index 0000000..f085f81 --- /dev/null +++ b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts @@ -0,0 +1,133 @@ +import { Component, OnInit } from '@angular/core'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {MerchantService} from '../../../services/merchant.service'; +import {NzMessageService, NzUploadFile} from 'ng-zorro-antd'; +import {ActivatedRoute} from '@angular/router'; +import {ValidatorsService} from '../../../services/validators.service'; +import {environment} from '../../../../environments/environment'; + +function getBase64(file: File): Promise { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); +} + +@Component({ + selector: 'app-merchant-edit', + templateUrl: './merchant-edit.component.html', + styleUrls: ['./merchant-edit.component.scss'] +}) +export class MerchantEditComponent implements OnInit { + + validateForm!: FormGroup; + data: any; + editFlag = false; + id: number; + passwordVisible = false; + logoFile = []; + WEB_SERVE_URL = environment.baseUrl; + previewImage: string | undefined = ''; + previewVisible = false; + constructor( + private fb: FormBuilder, + private merchant: MerchantService, + private message: NzMessageService, // 信息提示 + private activatedRoute: ActivatedRoute, + ) { } + + ngOnInit(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + this.editFlag = true; + if (queryParams.merchantId != null ) { + this.id = queryParams.merchantId; + this.getDetails(queryParams.merchantId); + } + }); + this.validateForm = this.fb.group({ + loginTelephone: [null, [Validators.required, ValidatorsService.mobile]], + password: [null, [Validators.required, ValidatorsService.pwdLength(6 , 12)]], + merchantKey: [null, [Validators.required, ValidatorsService.maxLength(10)]], + merchantName: [null, [Validators.required, ValidatorsService.pwdLength(2 , 12)]], + telephone: [null, [Validators.required]], + address: [null, [Validators.required]], + bankName: [null], + bankAccount: [null], + bankHolder: [null], + merchantDesc: [null], + secUser: {}, + }); + } + + // 返回 + getBack() { + history.back(); + } + + // 重置 + public resetForm(): void { + this.validateForm.reset(); + } + + // 课程保存 + public getSave(): void { + // tslint:disable-next-line:forin + for (const i in this.validateForm.controls) { + this.validateForm.controls[i].markAsDirty(); + this.validateForm.controls[i].updateValueAndValidity(); + // if (this.validateForm.controls[i].errors != null) { + // this.message.error('必填项不能为空'); + // return; + // } + } + + this.validateForm.value['secUser']['telephone'] = this.validateForm.value.loginTelephone; + this.validateForm.value['secUser']['password'] = this.validateForm.value.password; + if (this.logoFile.length !== 0) { + this.validateForm.value.merchantLogo = this.logoFile[0]['response']['return_data'][0]; + } + if (this.editFlag) { + + // this.lessonsService.getUpDataLesson(this.lessonData, data => { + // if (data['return_code'] === '000000') { + // this.returnData.emit(this.lessonData); + // } else { + // this.message.create('error', '修改失败'); + // } + // }); + } else { + + this.merchant.insertMerchant(this.validateForm.value, data => { + console.log(data); + if (data['return_code'] === '000000') { + this.getBack(); + this.message.success('添加成功'); + } else { + this.message.create('error', '保存失败'); + } + }); + } + } + + // 图片查看 + handlePreview = async (file: NzUploadFile) => { + if (!file.url && !file.preview) { + // tslint:disable-next-line:no-non-null-assertion + file.preview = await getBase64(file.originFileObj!); + } + this.previewImage = file.url || file.preview; + this.previewVisible = true; + } + + public getDetails(id) { + this.merchant.getMerchantById(id, data => { + if (data['return_code'] === '000000') { + console.log(data); + } else { + this.message.create('error', data['return_msg']); + } + }); + } +} diff --git a/src/app/admin/merchant/merchant-list/merchant-list.component.html b/src/app/admin/merchant/merchant-list/merchant-list.component.html new file mode 100644 index 0000000..76e2f5d --- /dev/null +++ b/src/app/admin/merchant/merchant-list/merchant-list.component.html @@ -0,0 +1,109 @@ + + + + + +
+
+
+
+ + 商户编号 + + + + +
+
+ + 商户名称 + + + + +
+
+ + 商户电话 + + + + +
+
+ + 商户状态 + + + + + + + +
+
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 编号 + 商户编号 + 商户名称 + 商户LOGO + 商户电话 + 创建时间 + 状态 + 操作 + + + + + {{i+1}} + {{data.merchantKey}} + {{data.merchantName}} + + + + {{data.telephone}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.status ===1 ? '正常' : '禁用'}} + + + + + + + + + +
+ + + diff --git a/src/app/admin/merchant/merchant-list/merchant-list.component.scss b/src/app/admin/merchant/merchant-list/merchant-list.component.scss new file mode 100644 index 0000000..8bee3fb --- /dev/null +++ b/src/app/admin/merchant/merchant-list/merchant-list.component.scss @@ -0,0 +1,4 @@ +.head_img { + height: 60px; + width: 60px; +} diff --git a/src/app/admin/merchant/merchant-list/merchant-list.component.ts b/src/app/admin/merchant/merchant-list/merchant-list.component.ts new file mode 100644 index 0000000..83c7176 --- /dev/null +++ b/src/app/admin/merchant/merchant-list/merchant-list.component.ts @@ -0,0 +1,94 @@ +import { Component, OnInit } from '@angular/core'; +import {FormBuilder, FormGroup} from '@angular/forms'; +import {UserService} from '../../../services/user.service'; +import {IconService} from '../../../services/icon.service'; +import {NzMessageService} from 'ng-zorro-antd'; +import {CommonsService} from '../../../services/commons.service'; +import {MerchantService} from '../../../services/merchant.service'; +import {Router} from '@angular/router'; + +@Component({ + selector: 'app-merchant-list', + templateUrl: './merchant-list.component.html', + styleUrls: ['./merchant-list.component.scss'] +}) +export class MerchantListComponent implements OnInit { + + searchForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + + constructor( + private form: FormBuilder, + private merchant: MerchantService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + private common: CommonsService + ) { + } + + ngOnInit(): void { + this.init(); + } + + public init(): void { + this.searchForm = this.form.group({ + merchantKey: [null], + merchantName: [null], + telephone: [null], + status: [null], + }); + this.getRequest(true, this.searchForm.value); + } + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.merchant.getMerchantList(whereObject, 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(); + } + + public getForbiddenUser(id, status: any): void { + const message = (status === 1 ? '是否禁用当前用户' : '是否启用当前用户'); + + this.common.showConfirm(message, data => { + if (data) { + // this.user.forbiddenUser(id, dataUser => { + // this.getRequest(false , this.searchForm.value); + // }); + } + }); + } + + + // 修改 + public getEdit(id: number): void { + this.router.navigate(['/admin/merchant/merchant-list'], { + queryParams: { + merchantId: id + } + }).then(r => console.log(r)); + } + +} diff --git a/src/app/admin/merchant/merchant-routing.module.ts b/src/app/admin/merchant/merchant-routing.module.ts index fb80d06..a7f6174 100644 --- a/src/app/admin/merchant/merchant-routing.module.ts +++ b/src/app/admin/merchant/merchant-routing.module.ts @@ -1,8 +1,13 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import {MerchantListComponent} from './merchant-list/merchant-list.component'; +import {MerchantEditComponent} from './merchant-edit/merchant-edit.component'; -const routes: Routes = []; +const routes: Routes = [ + { path: 'merchant-list', component: MerchantListComponent }, + { path: 'merchant-edit', component: MerchantEditComponent }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/src/app/admin/merchant/merchant.module.ts b/src/app/admin/merchant/merchant.module.ts index 0502df4..ab5731c 100644 --- a/src/app/admin/merchant/merchant.module.ts +++ b/src/app/admin/merchant/merchant.module.ts @@ -2,13 +2,25 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { MerchantRoutingModule } from './merchant-routing.module'; +import { MerchantListComponent } from './merchant-list/merchant-list.component'; +import {NgZorroAntdModule} from 'ng-zorro-antd'; +import {SeparateModule} from '../../common/separate/separate.module'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; +import { MerchantEditComponent } from './merchant-edit/merchant-edit.component'; +import { MerchantDetailComponent } from './merchant-detail/merchant-detail.component'; @NgModule({ - declarations: [], + declarations: [MerchantListComponent, MerchantEditComponent, MerchantDetailComponent], imports: [ CommonModule, - MerchantRoutingModule + MerchantRoutingModule, + NgZorroAntdModule, + SeparateModule, + ReactiveFormsModule, + FormsModule, + BreadcrumbModule ] }) 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 e6f9e9c..e39aa44 100644 --- a/src/app/admin/user/user-list/user-list.component.html +++ b/src/app/admin/user/user-list/user-list.component.html @@ -6,7 +6,7 @@
-
+
用户名称 @@ -14,7 +14,7 @@
-
+
电话 @@ -22,7 +22,7 @@
-
+
用户状态 @@ -33,7 +33,7 @@
-
+
注册时间 @@ -56,6 +56,7 @@
共计 {{total}} 条数据 性别 金币数量 注册时间 - 状态 + 状态 操作 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 914625d..740ebba 100644 --- a/src/app/admin/user/user-list/user-list.component.ts +++ b/src/app/admin/user/user-list/user-list.component.ts @@ -50,6 +50,7 @@ export class UserListComponent implements OnInit { whereObject['regTimeStart'] = whereObject['regTime'][0].getTime(); whereObject['regTimeEnd'] = whereObject['regTime'][1].getTime(); } + this.loading = false; if (reset) { this.pageNum = 1; @@ -57,7 +58,6 @@ export class UserListComponent implements OnInit { 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; @@ -78,7 +78,6 @@ export class UserListComponent implements OnInit { this.common.showConfirm(message, data => { if (data) { this.user.forbiddenUser(id, dataUser => { - console.log(dataUser); this.getRequest(false , this.searchForm.value); }); } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 4370925..a362f3a 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -26,6 +26,11 @@ const routes: Routes = [ loadChildren: () => import('./admin/user/user.module').then(m => m.UserModule), canActivate: [InitGuardService] }, + { + path: 'merchant', + loadChildren: () => import('./admin/merchant/merchant.module').then(m => m.MerchantModule), + canActivate: [InitGuardService] + }, { path: 'system', loadChildren: () => import('./admin/system/system.module').then(m => m.SystemModule), diff --git a/src/app/services/merchant.service.ts b/src/app/services/merchant.service.ts new file mode 100644 index 0000000..67cb29c --- /dev/null +++ b/src/app/services/merchant.service.ts @@ -0,0 +1,53 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from '@angular/common/http'; +import {CommonsService} from './commons.service'; +import {environment} from '../../environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class MerchantService { + + constructor( + private http: HttpClient, + private common: CommonsService + ) { } + + /** + * 查询商户列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getMerchantList(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'highMerchant/getMerchantList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + /** + * 新增商户 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public insertMerchant(params: object, callBack) { + this.http.post(environment.baseUrl + 'highMerchant/insertMerchant', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 根据id查询详情 + * + * @param merchantId 职位id + * @param callBack 回调 + */ + public getMerchantById(merchantId: number, callBack) { + this.http.get(environment.baseUrl + 'highMerchant/getMerchantById?id=' + merchantId).subscribe(data => { + callBack(data); + }); + } + +} diff --git a/src/styles.scss b/src/styles.scss index 17ddbc8..263d7f5 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -40,3 +40,16 @@ .operating-button button { margin-bottom: 15px; } +.table { + margin-top: 20px; +} + +.search-area { + text-align: center; +} +.ant-advanced-search-form { + padding: 24px; + background: #fbfbfb; + border: 1px solid #d9d9d9; + border-radius: 6px; +}