입금신청 진행중

This commit is contained in:
Park Byung Eun 2022-08-26 09:44:37 +00:00
parent 4d75fff2d7
commit 2da99fbd15
4 changed files with 146 additions and 110 deletions

View File

@ -7,6 +7,7 @@ import { MatTabsModule } from '@angular/material/tabs';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { MatDialogModule } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { FuseCardModule } from '@fuse/components/card'; import { FuseCardModule } from '@fuse/components/card';
import { SharedModule } from 'app/shared/shared.module'; import { SharedModule } from 'app/shared/shared.module';
@ -26,6 +27,8 @@ import { COMPOSE } from './compose';
MatInputModule, MatInputModule,
MatDialogModule, MatDialogModule,
MatSelectModule, MatSelectModule,
MatButtonToggleModule,
FuseCardModule, FuseCardModule,
SharedModule, SharedModule,

View File

@ -3,7 +3,7 @@
<div <div
class="flex flex-0 items-center justify-between h-16 pr-3 sm:pr-5 pl-6 sm:pl-8 bg-primary text-on-primary" class="flex flex-0 items-center justify-between h-16 pr-3 sm:pr-5 pl-6 sm:pl-8 bg-primary text-on-primary"
> >
<div class="text-lg font-medium">deposit</div> <div class="text-lg font-medium">입금신청</div>
<button mat-icon-button (click)="saveAndClose()" [tabIndex]="-1"> <button mat-icon-button (click)="saveAndClose()" [tabIndex]="-1">
<mat-icon <mat-icon
class="text-current" class="text-current"
@ -11,6 +11,16 @@
></mat-icon> ></mat-icon>
</button> </button>
</div> </div>
<fuse-alert
class="mt-8 -mb-4"
*ngIf="showAlert"
[appearance]="'outline'"
[showIcon]="false"
[type]="alert.type"
[@shake]="alert.type === 'error'"
>
{{ alert.message }}
</fuse-alert>
<!-- Compose form --> <!-- Compose form -->
<form <form
@ -19,94 +29,84 @@
> >
<!-- To --> <!-- To -->
<mat-form-field> <mat-form-field>
<mat-label>To</mat-label> <mat-label>입금자명</mat-label>
<input matInput [formControlName]="'to'" /> <input matInput [formControlName]="'accountHolder'" />
<div class="copy-fields-toggles" matSuffix>
<span
class="text-sm font-medium cursor-pointer select-none hover:underline"
*ngIf="!copyFields.cc"
(click)="showCopyField('cc')"
>
Cc
</span>
<span
class="ml-2 text-sm font-medium cursor-pointer select-none hover:underline"
*ngIf="!copyFields.bcc"
(click)="showCopyField('bcc')"
>
Bcc
</span>
</div>
</mat-form-field>
<!-- Cc -->
<mat-form-field *ngIf="copyFields.cc">
<mat-label>Cc</mat-label>
<input matInput [formControlName]="'cc'" />
</mat-form-field>
<!-- Bcc -->
<mat-form-field *ngIf="copyFields.bcc">
<mat-label>Bcc</mat-label>
<input matInput [formControlName]="'bcc'" />
</mat-form-field> </mat-form-field>
<mat-error *ngIf="composeForm.get('accountHolder')?.hasError('required')">
입금자명은 필수 입력입니다.
</mat-error>
<!-- Subject --> <!-- Subject -->
<mat-form-field> <mat-form-field>
<mat-label>Subject</mat-label> <mat-label>입금금액</mat-label>
<input matInput [formControlName]="'subject'" /> <input #inputAmount matInput [formControlName]="'amount'" value="" />
<mat-error *ngIf="composeForm.get('amount')?.hasError('required')">
입금금액은 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<!-- Body -->
<!-- <quill-editor
class="mt-2"
[formControlName]="'body'"
[modules]="quillModules"
></quill-editor> -->
<!-- Actions --> <!-- Actions -->
<div <div
class="flex flex-col sm:flex-row sm:items-center justify-between mt-4 sm:mt-6" class="flex flex-col sm:flex-row sm:items-center justify-between mt-4 sm:mt-6"
> >
<div class="-ml-2"> <div class="flex flex-wrap w-full -m-2">
<!-- Attach file --> <button
<button mat-icon-button> class="m-2"
<mat-icon mat-stroked-button
class="icon-size-5" [color]="'primary'"
[svgIcon]="'heroicons_solid:paper-clip'" (click)="__changeAmount('30000')"
></mat-icon> >
3만
</button> </button>
<!-- Insert link -->
<button mat-icon-button> <button
<mat-icon class="m-2"
class="icon-size-5" mat-stroked-button
[svgIcon]="'heroicons_solid:link'" [color]="'primary'"
></mat-icon> (click)="__changeAmount('50000')"
>
5만
</button> </button>
<!-- Insert emoji -->
<button mat-icon-button> <button
<mat-icon class="m-2"
class="icon-size-5" mat-stroked-button
[svgIcon]="'heroicons_solid:emoji-happy'" [color]="'primary'"
></mat-icon> (click)="__changeAmount('100000')"
>
10만
</button> </button>
<!-- Insert image --> <button
<button mat-icon-button> class="m-2"
<mat-icon mat-stroked-button
class="icon-size-5" [color]="'primary'"
[svgIcon]="'heroicons_solid:photograph'" (click)="__changeAmount('500000')"
></mat-icon> >
50만
</button>
<button
class="m-2"
mat-stroked-button
[color]="'primary'"
(click)="__changeAmount('1000000')"
>
100만
</button>
<button
class="m-2"
mat-stroked-button
[color]="'primary'"
(click)="__changeAmount('0')"
>
정정하기
</button> </button>
</div> </div>
</div>
<div class="flex items-center mt-4 sm:mt-0"> <div class="flex flex-col sm:flex-row sm:items-center mt-4 sm:mt-6">
<!-- Discard --> <div class="flex mt-4 sm:mt-0">
<button class="ml-auto sm:ml-0" mat-stroked-button (click)="discard()">
Discard
</button>
<!-- Save as draft --> <!-- Save as draft -->
<button class="sm:mx-3" mat-stroked-button (click)="saveAsDraft()"> <button class="sm:mx-3" mat-stroked-button (click)="__contactDeposit()">
<span>Save as draft</span> <span>입금계좌문의</span>
</button> </button>
<!-- Send --> <!-- Send -->
<button <button
@ -115,7 +115,7 @@
[color]="'primary'" [color]="'primary'"
(click)="send()" (click)="send()"
> >
Send 입금하기
</button> </button>
</div> </div>
</div> </div>

View File

@ -1,32 +1,32 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog'; import { MatDialogRef } from '@angular/material/dialog';
import { fuseAnimations } from '@fuse/animations';
import { FuseAlertType } from '@fuse/components/alert';
import { MemberBankDepositService } from 'app/modules/polyglot/member_bank_deposit/services/member_bank_deposit.service';
import { CreateMemberBankDepositRequest } from 'app/modules/proto/c2se/member_bank_deposit_pb';
@Component({ @Component({
selector: 'deposit-compose', selector: 'deposit-compose',
templateUrl: './deposit-compose.component.html', templateUrl: './deposit-compose.component.html',
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
animations: fuseAnimations,
}) })
export class DepositComposeComponent implements OnInit { export class DepositComposeComponent implements OnInit {
composeForm!: FormGroup; composeForm!: FormGroup;
copyFields: { cc: boolean; bcc: boolean } = {
cc: false,
bcc: false,
};
quillModules: any = {
toolbar: [
['bold', 'italic', 'underline'],
[{ align: [] }, { list: 'ordered' }, { list: 'bullet' }],
['clean'],
],
};
alert: { type: FuseAlertType; message: string } = {
type: 'success',
message: '입금신청이 완료 되었습니다.',
};
showAlert: boolean = false;
/** /**
* Constructor * Constructor
*/ */
constructor( constructor(
public matDialogRef: MatDialogRef<DepositComposeComponent>, public matDialogRef: MatDialogRef<DepositComposeComponent>,
private _formBuilder: FormBuilder private _formBuilder: FormBuilder,
private _memberBankDepositService: MemberBankDepositService
) {} ) {}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -39,11 +39,8 @@ export class DepositComposeComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
// Create the form // Create the form
this.composeForm = this._formBuilder.group({ this.composeForm = this._formBuilder.group({
to: ['', [Validators.required, Validators.email]], accountHolder: ['', [Validators.required]],
cc: ['', [Validators.email]], amount: ['', [Validators.required]],
bcc: ['', [Validators.email]],
subject: [''],
body: ['', [Validators.required]],
}); });
} }
@ -51,21 +48,6 @@ export class DepositComposeComponent implements OnInit {
// @ Public methods // @ Public methods
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
/**
* Show the copy field with the given field name
*
* @param name
*/
showCopyField(name: string): void {
// Return if the name is not one of the available names
if (name !== 'cc' && name !== 'bcc') {
return;
}
// Show the field
this.copyFields[name] = true;
}
/** /**
* Save and close * Save and close
*/ */
@ -90,5 +72,56 @@ export class DepositComposeComponent implements OnInit {
/** /**
* Send the message * Send the message
*/ */
send(): void {} send(): void {
if (!this.composeForm.valid) {
return;
}
this.composeForm?.disable();
const req = new CreateMemberBankDepositRequest();
const amount = this.composeForm.get('amount')?.value as number;
const holder = this.composeForm.get('accountHolder')?.value as string;
req.setAmount(amount);
req.setName(holder);
req.setMemo('test');
this._memberBankDepositService
.createMemberBankDeposit(req)
.then(() => {
console.log();
this.showAlert = true;
})
.catch((e) => {
this.showAlert = true;
this.alert = { type: 'error', message: '입금신청이 실패 하였습니다.' };
// Re-enable the form
this.composeForm?.enable();
// Reset the form
});
// req.set
}
__changeAmount(amount: string): void {
const amountInput = this.composeForm.get('amount');
if (amount === '0') {
amountInput?.setValue('');
return;
}
amountInput?.setValue(amount);
}
__contactDeposit(): void {
this.showAlert = true;
this.alert = {
type: 'success',
message: '입금 계좌문의가 전달되었습니다!',
};
setTimeout(() => {
this.showAlert = false;
}, 5000);
}
} }

View File

@ -43,11 +43,11 @@ export class MemberBankDepositService {
// @ Public methods // @ Public methods
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
createMemberBankDeposit(): Promise<CreateMemberBankDepositResponse.Result> { createMemberBankDeposit(
req: CreateMemberBankDepositRequest
): Promise<CreateMemberBankDepositResponse.Result> {
return new Promise<CreateMemberBankDepositResponse.Result>( return new Promise<CreateMemberBankDepositResponse.Result>(
(resolve, reject) => { (resolve, reject) => {
let req = new CreateMemberBankDepositRequest();
this.__natsService this.__natsService
.request<CreateMemberBankDepositResponse.Result>( .request<CreateMemberBankDepositResponse.Result>(
SUBJECT_CREATE_MEMBER_BANK_DEPOSIT, SUBJECT_CREATE_MEMBER_BANK_DEPOSIT,