From cbbdd6b069fcbb4deb3dec6449b746a043056104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E6=99=93=E4=BA=91?= Date: Fri, 22 Apr 2022 18:11:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform-account.component.ts | 34 ++- .../withdraw-deposit.component.html | 39 +++ .../withdraw-deposit.component.less | 37 +++ .../withdraw-deposit.component.spec.ts | 24 ++ .../withdraw-deposit.component.ts | 288 ++++++++++++++++++ .../financial-management.module.ts | 4 +- .../services/bank-card-management.service.ts | 2 + src/assets/images/wallet.svg | 6 + 8 files changed, 430 insertions(+), 4 deletions(-) create mode 100644 src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.html create mode 100644 src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.less create mode 100644 src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.spec.ts create mode 100644 src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.ts create mode 100644 src/assets/images/wallet.svg diff --git a/src/app/routes/financial-management/components/platform-account/platform-account.component.ts b/src/app/routes/financial-management/components/platform-account/platform-account.component.ts index f54f0046..1cfb6a07 100644 --- a/src/app/routes/financial-management/components/platform-account/platform-account.component.ts +++ b/src/app/routes/financial-management/components/platform-account/platform-account.component.ts @@ -5,6 +5,7 @@ import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form'; import { NzModalService } from 'ng-zorro-antd/modal'; import { FreightAccountService } from '../../services/freight-account.service'; import { CwcBankCardManagementBindComponent } from '../bank-card-management/bind/bind.component'; +import { CwcAccountManagementWithdrawDepositComponent } from './withdraw-deposit/withdraw-deposit.component'; @Component({ selector: 'app-platform-account', @@ -192,12 +193,18 @@ export class PlatformAccountComponent implements OnInit { }) }, { - text: '绑定银行卡', - click: item => this.bindBankcard(item) + text: '提现', + click: item => this.withdraw(item), + iif: (_record) => _record.bankType !== '1' }, + // { + // text: '绑定银行卡', + // click: item => this.bindBankcard(item) + // }, { text: '查看银行卡', - click: item => this.viewBankcard(item) + click: item => this.viewBankcard(item), + iif: (_record) => _record.bankType !== '1' }, ] } @@ -239,4 +246,25 @@ export class PlatformAccountComponent implements OnInit { exportList() { this.service.exportStart({ ...this.sf.value, pageSize: -1 }, this.service.$api_get_exportPlatformAccountBalanceByOperator,); } + + // 提现 + withdraw(record: any) { + const modalRef = this.modal.create({ + nzTitle: '提现', + nzWidth: '35%', + nzContent: CwcAccountManagementWithdrawDepositComponent, + nzMaskClosable: false, + nzComponentParams: { + record + }, + nzFooter: null + }); + modalRef.afterClose.subscribe(res => { + if (res) { + // this.getSummary(); + // this.withdrawTable.refresh(); + } + }) + } + } diff --git a/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.html b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.html new file mode 100644 index 00000000..79a7a3e2 --- /dev/null +++ b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.html @@ -0,0 +1,39 @@ + + +
-
+
{{me.formProperty.value | currency}}
+
+ + +
+ +
+
+
+添加银行卡
+
+ + + + 全部提现 + + + + 忘记密码? + + + +
diff --git a/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.less b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.less new file mode 100644 index 00000000..d4fad7b5 --- /dev/null +++ b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.less @@ -0,0 +1,37 @@ +:host { + .bank-card-select-content { + padding: 5px; + border: 1px solid #ccc; + + .band-card-row { + display: flex; + align-items: center; + } + } + + .pay-way-group { + width: 100%; + margin-bottom: 5px; + + .bank-card-row { + display: flex; + align-items: center; + } + + .band-card { + border: 1px solid #e8e8e8; + + .pay-way-label { + width: 100%; + padding: 6px 10px; + } + } + + } + + .input-row { + width: 70%; + margin-right: 8px; + } + +} diff --git a/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.spec.ts b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.spec.ts new file mode 100644 index 00000000..2d1f933a --- /dev/null +++ b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.spec.ts @@ -0,0 +1,24 @@ +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { CwcAccountManagementWithdrawDepositComponent } from './withdraw-deposit.component'; + +describe('CwcAccountManagementWithdrawDepositComponent', () => { + let component: CwcAccountManagementWithdrawDepositComponent; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [CwcAccountManagementWithdrawDepositComponent] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CwcAccountManagementWithdrawDepositComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.ts b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.ts new file mode 100644 index 00000000..ca2cb877 --- /dev/null +++ b/src/app/routes/financial-management/components/platform-account/withdraw-deposit/withdraw-deposit.component.ts @@ -0,0 +1,288 @@ +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +import { Router } from '@angular/router'; +import { cacheConf } from '@conf/cache.conf'; +import { STColumn, STComponent } from '@delon/abc/st'; +import { SFComponent, SFSchema, SFSelectWidgetSchema, SFUISchema } from '@delon/form'; +import { EACacheService, EAEnvironmentService, ShipperBaseService } from '@shared'; +import { NzModalRef } from 'ng-zorro-antd/modal'; +import { BankCardManagementService } from '../../../services/bank-card-management.service'; + +@Component({ + selector: 'app-cwc-withdraw-deposit', + templateUrl: './withdraw-deposit.component.html', + styleUrls: ['./withdraw-deposit.component.less'] +}) +export class CwcAccountManagementWithdrawDepositComponent implements OnInit { + accountBalance = 0; + minWithdrawAmount = 0; + minWithdrawFee: any = 0; + code = ''; + bankList: Array = []; + bankAccount = ''; + count = 0; + interval$: any; + ui: SFUISchema = {}; + i: any; + schema: SFSchema = {}; + totalGJ: any = 0.0; + cacFee: any = 0; + columns: STColumn[] = []; + totalBalance = 200; + bankCardList: Array = []; + cardNo = ''; + accountDetail: any = {}; + networkTransporterId = ''; + networkTransporterName = ''; + balanceObj: any = { + allBalance: 99999999 + }; + @ViewChild('st', { static: false }) st!: STComponent; + @ViewChild('sf', { static: false }) sf!: SFComponent; + @ViewChild('psd') psd!: ElementRef; + record: any; + bankType = '2'; + + constructor( + public service: BankCardManagementService, + private modal: NzModalRef, + private shipperSrv: ShipperBaseService, + public eaCacheSrv: EACacheService, + public envSrv: EAEnvironmentService, + public router: Router + ) { + this.networkTransporterId = this.eaCacheSrv.get(cacheConf.env)?.networkTransporterId; + } + + ngOnInit() { + this.initSF(); + this.getBankList(); + this.getProjectBalanceDetail(); + } + + + + + /** + * 初始化查询表单 + */ + initSF() { + this.schema = { + properties: { + ltdName: { + title: '网络货运人', + type: 'string', + default: this.record?.ltdName, + ui: { + widget: 'text', + } + }, + bankType: { + title: '银行', + type: 'string', + default: this.bankType, + enum: [ + { label: '浦发银行', value: '2' } + ], + ui: { + widget: 'select', + containsAllLabel: false, + showRequired: true, + change: (value: any) => { + // if (value && this.sf?.value?.ltdId) { + // const parmas = { bankType: value, ltdId: this.sf.getValue('/ltdId') }; + // this.getProjectBalanceDetail(parmas); + // } + } + } as SFSelectWidgetSchema + }, + availableBalance: { title: '可提现余额', type: 'string', ui: { showRequired: false, widget: 'custom' } }, + bankId: { + title: '提现至', + type: 'string', + ui: { + showRequired: true, widget: 'custom' + }, + }, + amount: { + title: '提现金额', + type: 'string', + ui: { + showRequired: true, + widget: 'custom', + validator: (val) => { + if (!val && val !== 0) { + return [{ keyword: 'required', message: '必填项' }]; + } else if (val > this.balanceObj.allBalance) { + return [{ keyword: 'required', message: '提现金额超过可提现余额' }]; + } + return []; + } + }, + + }, + payPsd: { + title: '支付密码', + type: 'string', + minLength: 6, + maxLength: 6, + ui: { widget: 'custom' }, + }, + payPassword: { + title: '', + type: 'string', + ui: { + hidden: true + } + } + }, + autocomplete: 'off', + required: ['bankType', 'payPsd'] + }; + this.ui = { + '*': { spanLabelFixed: 100, grid: { span: 18, gutter: 2 } }, + $addBankCard1: { + grid: { span: 24 } + }, + $addBankCard2: { + grid: { span: 24 } + } + }; + } + + save(value: any) { + if (this.sf.valid) { + const { amount, bankId, bankType, ltdName, payPassword } = value; + if (amount > this.balanceObj?.allBalance) { + this.service.msgSrv.warning('提现金额超过可提现余额!'); + return; + } + const params = { + amount, + bankId, + bankType, + ltdId: this.record.ltdId, + ltdName, + payPassword + }; + this.service.request(this.service.$api_apply_withdraw, { ...params }) + .subscribe(res => { + if (res) { + this.service.msgSrv.success('提现成功!'); + this.close(true); + } + }) + } + } + close(flag: boolean) { + this.modal.destroy(flag); + } + + + toAddBankPage() { + window.open(`/#/financial-management/bank-card-management/index?ltdId=${this.record?.ltdId}<dName=${this.record?.ltdName}`); + } + /** + * 全部提现 + */ + allWithdrawal() { + if (!this.sf.getValue('/availableBalance')) { + this.sf.setValue('/amount', ''); + return; + } + this.sf.setValue('/amount', this.balanceObj?.allBalance); + } + /** + * 跳转至忘记密码页 + */ + toForgetPsdPage() { + window.open('/#/account/edit-paypassword'); + } + + /** + * 切换银行卡 + */ + checkBankCard(e: any) { + this.sf.setValue('/bankId', e); + } + getBankList() { + this.service.request(this.service.$api_bank_card_list, { accountType: '3', roleId: this.record?.ltdId }).subscribe((res) => { + if (res) { + this.bankCardList = res; + } + }); + } + + /** + * 获取项目账户余额 + */ + getProjectBalanceDetail(params = {}) { + this.service.request(this.service.$api_get_account_available_balance, { bankType: this.bankType, ltdId: this.record?.ltdId }).subscribe(res => { + if (res) { + this.balanceObj = res; + this.sf.setValue('/availableBalance', res?.allBalance); + // this.sf.getProperty('/amount')?.updateValueAndValidity(); + } + }) + } + + keydown(e: any) { + if (e.keyCode == 37 || e.keyCode == 39) e.preventDefault(); + if (e.keyCode === 8) { + // const payPswVal = this.sf.getValue('/password'); + // this.sf.setValue('/password', payPswVal.substr(0, payPswVal.length - 1)); + } + + } + clickInput(e: any) { + this.psd.nativeElement.focus(); + } + changePsd(val: any) { + this.sf.setValue('/payPsd', val); + if (val || val !== '') { + const last = val.substr(val.length - 1); + const password = this.sf.getValue('/payPassword'); + const start = this.psd?.nativeElement.selectionStart; + if (last !== '•') { + this.sf.setValue('/payPassword', start !== 1 ? (password + last) : last); + } else { + this.sf.setValue('/payPassword', password.substr(0, val.length)); + } + const payPswVal = this.sf.getValue('/payPsd'); + this.sf.setValue('/payPsd', payPswVal.replace(/./g, "•")); + } else { + this.sf.setValue('/payPassword', ''); + } + + } + + /** + * 设置光标聚焦 + */ + setFocus() { + + const len = this.psd?.nativeElement.value.length; + this.setSelectionRange(this.psd?.nativeElement, len, len); //将光标定位到文本最后 + } + + /** + * 设置光标位置 + * @param input dom元素 + * @param selectionStart 起始位置 + * @param selectionEnd 结束位置 + */ + setSelectionRange(input: ElementRef | any, selectionStart: number, selectionEnd: number) { + if (input?.setSelectionRange) { + input.focus(); + input.setSelectionRange(selectionStart, selectionEnd); + } + else if (input.createTextRange) { + var range = input.createTextRange(); + range.collapse(true); + range.moveEnd('character', selectionEnd); + range.moveStart('character', selectionStart); + range.select(); + } + } + + +} diff --git a/src/app/routes/financial-management/financial-management.module.ts b/src/app/routes/financial-management/financial-management.module.ts index 63b99337..76cafed5 100644 --- a/src/app/routes/financial-management/financial-management.module.ts +++ b/src/app/routes/financial-management/financial-management.module.ts @@ -39,6 +39,7 @@ import { AbnormalGoldDetailComponent } from './components/abnormal-gold/abnormal import { CwcBankCardManagementIndexComponent } from './components/bank-card-management/index/index.component'; import { CwcBankCardManagementBindComponent } from './components/bank-card-management/bind/bind.component'; import { CwcBankCardManagementAddComponent } from './components/bank-card-management/add/add.component'; +import { CwcAccountManagementWithdrawDepositComponent } from './components/platform-account/withdraw-deposit/withdraw-deposit.component'; const ROUTESCOMPONENTS = [ FreightAccountComponent, @@ -74,7 +75,8 @@ const ROUTESCOMPONENTS = [ AbnormalGoldDetailComponent, CwcBankCardManagementIndexComponent, CwcBankCardManagementBindComponent, - CwcBankCardManagementAddComponent + CwcBankCardManagementAddComponent, + CwcAccountManagementWithdrawDepositComponent ]; const NOTROUTECOMPONENTS = [DriverAccountDetailComponent, FreightAccountDetailComponent, ClearingModalComponent]; diff --git a/src/app/routes/financial-management/services/bank-card-management.service.ts b/src/app/routes/financial-management/services/bank-card-management.service.ts index 65db517b..76faf71c 100644 --- a/src/app/routes/financial-management/services/bank-card-management.service.ts +++ b/src/app/routes/financial-management/services/bank-card-management.service.ts @@ -8,6 +8,8 @@ export class BankCardManagementService extends BaseService { $api_bank_card_list = `/api/fcc/bankInfoOBC/list/myBankInfo`; // 获取银行卡列表 $api_bank_card_del = `/api/fcc/bankInfoOBC/delete`; // 删除银行卡 $api_bank_card_add = `/api/fcc/bankInfoOBC/save`;//新增银行卡 + $api_get_account_available_balance = `/api/fcc/accountBalance/getWithdrawalAccountBalanceOperator`; //平台可提现金额查询 + $api_apply_withdraw = `/api/fcc/refundApplicationOBC/addAgreeRefund`; // 提现申请 constructor(public injector: Injector) { super(injector); } diff --git a/src/assets/images/wallet.svg b/src/assets/images/wallet.svg new file mode 100644 index 00000000..d1cc7990 --- /dev/null +++ b/src/assets/images/wallet.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file