From c5ac9eff0035edab934394bff10c9ccf1eb3ea88 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 25 Apr 2024 10:22:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.routes.ts | 5 + .../merchant/mer-add/mer-add.component.html | 79 ++++++++++++ .../merchant/mer-add/mer-add.component.less | 7 + .../merchant/mer-add/mer-add.component.ts | 122 ++++++++++++++++++ .../merchant/mer-list/mer-list.component.html | 1 + .../merchant/mer-list/mer-list.component.less | 0 .../merchant/mer-list/mer-list.component.ts | 12 ++ src/app/pages/merchant/merchant.module.ts | 12 ++ src/app/pages/merchant/merchant.routes.ts | 8 ++ src/app/servies/merchant/mer.service.ts | 56 ++++++++ 10 files changed, 302 insertions(+) create mode 100644 src/app/pages/merchant/mer-add/mer-add.component.html create mode 100644 src/app/pages/merchant/mer-add/mer-add.component.less create mode 100644 src/app/pages/merchant/mer-add/mer-add.component.ts create mode 100644 src/app/pages/merchant/mer-list/mer-list.component.html create mode 100644 src/app/pages/merchant/mer-list/mer-list.component.less create mode 100644 src/app/pages/merchant/mer-list/mer-list.component.ts create mode 100644 src/app/pages/merchant/merchant.module.ts create mode 100644 src/app/pages/merchant/merchant.routes.ts create mode 100644 src/app/servies/merchant/mer.service.ts diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 7e0a3cf..b08136e 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -24,6 +24,11 @@ export const routes: Routes = [ loadChildren: () => import('./pages/account/account.routes').then(m => m.ACCOUNT_ROUTES), canActivate: [InitGuardService] }, + { + path: 'merchant', + loadChildren: () => import('./pages/merchant/merchant.routes').then(m => m.MERCHANT_ROUTES), + canActivate: [InitGuardService] + }, { path: 'goods', loadChildren: () => import('./pages/goods/goods.routes').then(m => m.GOODS_ROUTES), diff --git a/src/app/pages/merchant/mer-add/mer-add.component.html b/src/app/pages/merchant/mer-add/mer-add.component.html new file mode 100644 index 0000000..61f052b --- /dev/null +++ b/src/app/pages/merchant/mer-add/mer-add.component.html @@ -0,0 +1,79 @@ +
diff --git a/src/app/pages/merchant/mer-add/mer-add.component.less b/src/app/pages/merchant/mer-add/mer-add.component.less new file mode 100644 index 0000000..8ad44a1 --- /dev/null +++ b/src/app/pages/merchant/mer-add/mer-add.component.less @@ -0,0 +1,7 @@ +form { + text-align: center; + width: 500px; +} +.logo-uploader { + text-align: left; +} diff --git a/src/app/pages/merchant/mer-add/mer-add.component.ts b/src/app/pages/merchant/mer-add/mer-add.component.ts new file mode 100644 index 0000000..991a48c --- /dev/null +++ b/src/app/pages/merchant/mer-add/mer-add.component.ts @@ -0,0 +1,122 @@ +import { Component } from '@angular/core'; +import {MerService} from "../../../servies/merchant/mer.service"; +import {NzModalModule, NzModalService} from "ng-zorro-antd/modal"; +import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; +import {NgForOf, NgIf} from "@angular/common"; +import {NzButtonComponent} from "ng-zorro-antd/button"; +import {NzColDirective} from "ng-zorro-antd/grid"; +import {NzFlexDirective} from "ng-zorro-antd/flex"; +import { + NzFormControlComponent, + NzFormDirective, + NzFormItemComponent, + NzFormLabelComponent, + NzFormModule +} from "ng-zorro-antd/form"; +import {NzInputDirective} from "ng-zorro-antd/input"; +import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; +import {NzUploadFile, NzUploadModule} from "ng-zorro-antd/upload"; +import {NzIconDirective} from "ng-zorro-antd/icon"; +import {Observable, Observer} from "rxjs"; +import {NzMessageService} from "ng-zorro-antd/message"; + +@Component({ + selector: 'app-mer-add', + standalone: true, + imports: [ + FormsModule, + NgForOf, + NzButtonComponent, + NzColDirective, + NzFlexDirective, + NzFormControlComponent, + NzFormDirective, + ReactiveFormsModule, + NzFormItemComponent, + NzFormLabelComponent, + NzInputDirective, + NzSelectComponent, + NzOptionComponent, + NzModalModule, + NzFormModule, + NzUploadModule, + NzIconDirective, + NgIf + ], + templateUrl: './mer-add.component.html', + styleUrl: './mer-add.component.less' +}) +export class MerAddComponent { + + loading = false; + logoUrl?: string; + + form: FormGroup; + // 角色数据 + roleData: any = []; + + constructor(private fb: NonNullableFormBuilder, + private merService: MerService, + private message: NzMessageService, + private modal: NzModalService) { + // 初始化表单 + this.form = this.fb.group({ + loginName: ['', [Validators.required]], + roleId: ['', [Validators.required]], + merLogo: [''], + merName: [''], + directorName: [''], + directorTel: [''], + customerServiceTel: [''], + address: [''], + }); + } + + submitForm() { + + } + + private getBase64(img: File, callback: (img: string) => void): void { + const reader = new FileReader(); + reader.addEventListener('load', () => callback(reader.result!.toString())); + reader.readAsDataURL(img); + } + + handleChange(info: { file: NzUploadFile }): void { + switch (info.file.status) { + case 'uploading': + this.loading = true; + break; + case 'done': + // Get this url from response in real world. + this.getBase64(info.file!.originFileObj!, (img: string) => { + this.loading = false; + this.logoUrl = img; + }); + break; + case 'error': + this.message.error('Network error'); + this.loading = false; + break; + } + } + + beforeUpload = (file: NzUploadFile, _fileList: NzUploadFile[]) => { + return new Observable((observer: Observermer-list works!
diff --git a/src/app/pages/merchant/mer-list/mer-list.component.less b/src/app/pages/merchant/mer-list/mer-list.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/merchant/mer-list/mer-list.component.ts b/src/app/pages/merchant/mer-list/mer-list.component.ts new file mode 100644 index 0000000..9d7a95f --- /dev/null +++ b/src/app/pages/merchant/mer-list/mer-list.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-mer-list', + standalone: true, + imports: [], + templateUrl: './mer-list.component.html', + styleUrl: './mer-list.component.less' +}) +export class MerListComponent { + +} diff --git a/src/app/pages/merchant/merchant.module.ts b/src/app/pages/merchant/merchant.module.ts new file mode 100644 index 0000000..4874d2e --- /dev/null +++ b/src/app/pages/merchant/merchant.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + + + +@NgModule({ + declarations: [], + imports: [ + CommonModule + ] +}) +export class MerchantModule { } diff --git a/src/app/pages/merchant/merchant.routes.ts b/src/app/pages/merchant/merchant.routes.ts new file mode 100644 index 0000000..b2228b5 --- /dev/null +++ b/src/app/pages/merchant/merchant.routes.ts @@ -0,0 +1,8 @@ +import { Routes } from '@angular/router'; +import {MerAddComponent} from "./mer-add/mer-add.component"; +import {MerListComponent} from "./mer-list/mer-list.component"; + +export const MERCHANT_ROUTES: Routes = [ + { path: 'mer-list', component: MerListComponent }, + { path: 'mer-add', component: MerAddComponent } +]; diff --git a/src/app/servies/merchant/mer.service.ts b/src/app/servies/merchant/mer.service.ts new file mode 100644 index 0000000..51d2800 --- /dev/null +++ b/src/app/servies/merchant/mer.service.ts @@ -0,0 +1,56 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../../../environments/environment"; +import {ObjectData} from "../../utils/objectData.service"; + +@Injectable({ + providedIn: 'root' +}) +export class MerService { + + constructor(private http: HttpClient) { } + + /** + * 创建商户 + * @param params + * @param callBack + */ + public create(params: object, callBack:any) { + this.http.post(environment.baseUrl + 'mer/create', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 修改商户 + * @param params + * @param callBack + */ + public update(params: object, callBack:any) { + this.http.post(environment.baseUrl + 'mer/update', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 查询商户 + * @param merNo + * @param callBack + */ + public queryMer(merNo: string, callBack:any) { + this.http.get(environment.baseUrl + 'mer/queryMer?merNo=' + merNo).subscribe(data => { + callBack(data); + }); + } + + /** + * 查询商户列表 + * @param params + * @param callBack + */ + public queryList(params: object, callBack:any) { + this.http.get(environment.baseUrl + 'mer/queryList?' + ObjectData.objectByString(params)).subscribe(data => { + callBack(data); + }); + } +}