출금신청 수정

This commit is contained in:
이담 정 2022-09-06 12:51:06 +09:00
parent dc22890c85
commit f64f96dced
2 changed files with 155 additions and 105 deletions

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">Withdraw</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,95 +29,110 @@
> >
<!-- To --> <!-- To -->
<mat-form-field> <mat-form-field>
<mat-label>To</mat-label> <mat-label>은행명</mat-label>
<input matInput [formControlName]="'to'" /> <mat-select
<div class="copy-fields-toggles" matSuffix> [formControlName]="'bankName'"
<span placeholder="은행 선택"
class="text-sm font-medium cursor-pointer select-none hover:underline"
*ngIf="!copyFields.cc"
(click)="showCopyField('cc')"
> >
Cc <mat-option
</span>
<span
class="ml-2 text-sm font-medium cursor-pointer select-none hover:underline"
*ngIf="!copyFields.bcc"
(click)="showCopyField('bcc')"
> >
Bcc 국민은행
</span> </mat-option>
</div> </mat-select>
</mat-form-field> </mat-form-field>
<mat-error *ngIf="composeForm.get('bankName')?.hasError('required')">
<!-- Cc --> 은행명은 필수 입력입니다.
<mat-form-field *ngIf="copyFields.cc"> </mat-error>
<mat-label>Cc</mat-label> <mat-form-field>
<input matInput [formControlName]="'cc'" /> <mat-label>예금주</mat-label>
<input matInput [formControlName]="'accountHolder'" />
</mat-form-field> </mat-form-field>
<mat-error *ngIf="composeForm.get('accountHolder')?.hasError('required')">
<!-- Bcc --> 예금주는 필수 입력입니다.
<mat-form-field *ngIf="copyFields.bcc"> </mat-error>
<mat-label>Bcc</mat-label> <mat-form-field>
<input matInput [formControlName]="'bcc'" /> <mat-label>계좌번호</mat-label>
<input matInput [formControlName]="'account'" />
</mat-form-field>
<mat-error *ngIf="composeForm.get('account')?.hasError('required')">
계좌번호는 필수 입력입니다.
</mat-error>
<mat-form-field>
<mat-label>보유금액</mat-label>
<input matInput [formControlName]="'holdingMoney'" />
</mat-form-field> </mat-form-field>
<!-- 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="" placeholder="최소출금 50,000원 부터" />
<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('50000')"
></mat-icon> >
5만
</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('100000')"
>
10만
</button> </button>
<!-- Insert emoji --> <button
<button mat-icon-button> class="m-2"
<mat-icon mat-stroked-button
class="icon-size-5" [color]="'primary'"
[svgIcon]="'heroicons_solid:emoji-happy'" (click)="__changeAmount('500000')"
></mat-icon> >
50만
</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('1000000')"
></mat-icon> >
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"> <mat-form-field>
<!-- Discard --> <mat-label>출금비밀번호</mat-label>
<button class="ml-auto sm:ml-0" mat-stroked-button (click)="discard()"> <input #inputAmount matInput />
Discard <mat-error *ngIf="composeForm.get('amount')?.hasError('required')">
</button> 출금비밀번호는 필수 입력입니다.
</mat-error>
</mat-form-field>
<div class="flex flex-col sm:flex-row sm:items-center mt-4 sm:mt-6">
<div class="flex mt-4 sm:mt-0">
<!-- 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
class="order-first sm:order-last" class="order-first sm:order-last"
@ -115,7 +140,7 @@
[color]="'primary'" [color]="'primary'"
(click)="send()" (click)="send()"
> >
Send 출금하기
</button> </button>
</div> </div>
</div> </div>

View File

@ -1,6 +1,9 @@
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 { FuseAlertType } from '@fuse/components/alert';
import { MemberBankWithdrawService } from 'app/modules/polyglot/member_bank_withdraw/services/member_bank_withdraw.service';
import { CreateMemberBankWithdrawRequest } from 'app/modules/proto/c2se/member_bank_withdraw_pb';
@Component({ @Component({
selector: 'withdraw-compose', selector: 'withdraw-compose',
@ -9,24 +12,18 @@ import { MatDialogRef } from '@angular/material/dialog';
}) })
export class WithdrawComposeComponent implements OnInit { export class WithdrawComposeComponent implements OnInit {
composeForm!: FormGroup; composeForm!: FormGroup;
copyFields: { cc: boolean; bcc: boolean } = { alert: { type: FuseAlertType; message: string } = {
cc: false, type: 'success',
bcc: false, message: '출금신청이 완료 되었습니다.',
}; };
quillModules: any = { showAlert: boolean = false;
toolbar: [
['bold', 'italic', 'underline'],
[{ align: [] }, { list: 'ordered' }, { list: 'bullet' }],
['clean'],
],
};
/** /**
* Constructor * Constructor
*/ */
constructor( constructor(
public matDialogRef: MatDialogRef<WithdrawComposeComponent>, public matDialogRef: MatDialogRef<WithdrawComposeComponent>,
private _formBuilder: FormBuilder private _formBuilder: FormBuilder,
private _memberBankWithdrawService: MemberBankWithdrawService
) {} ) {}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -39,11 +36,8 @@ export class WithdrawComposeComponent 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 +45,6 @@ export class WithdrawComposeComponent 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 +69,51 @@ export class WithdrawComposeComponent implements OnInit {
/** /**
* Send the message * Send the message
*/ */
send(): void {} send(): void {
if (!this.composeForm.valid) {
return;
}
this.composeForm?.disable();
const req = new CreateMemberBankWithdrawRequest();
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._memberBankWithdrawService
.createMemberBankWithdraw(
// 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
})
.finally(() =>
setTimeout(() => {
this.matDialogRef.close();
}, 2000)
);
// req.set
}
__changeAmount(amount: string): void {
const amountInput = this.composeForm.get('amount');
if (amount === '0') {
amountInput?.setValue('');
return;
}
amountInput?.setValue(amount);
}
} }