Files
bbq/src/app/routes/financial-management/components/driver-account/driver-account.component.ts
Taric Xin 08617ecfa1 edit
2022-01-13 15:49:58 +08:00

221 lines
6.1 KiB
TypeScript

import { CurrencyPipe } from '@angular/common';
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { STComponent, STColumn, STChange, STRequestOptions } from '@delon/abc/st';
import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form';
import { ShipperBaseService } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal';
import { AccountDetailComponent } from 'src/app/shared/components/account-detail/account-detail.component';
import { FreightAccountService } from '../../services/freight-account.service';
@Component({
selector: 'app-driver-account',
templateUrl: './driver-account.component.html',
styleUrls: ['./driver-account.component.less'],
providers: [CurrencyPipe]
})
export class DriverAccountComponent implements OnInit {
@ViewChild('st', { static: true })
st!: STComponent;
@ViewChild('sf', { static: false })
sf!: SFComponent;
searchSchema: SFSchema = this.initSF();
columns: STColumn[] = this.initST();
_$expand = false;
constructor(
public service: FreightAccountService,
private router: Router,
private modal: NzModalService,
private currencyPipe: CurrencyPipe
) {}
ngOnInit(): void {}
beforeReq = (requestOptions: STRequestOptions) => {
Object.assign(requestOptions.body, { accountType: 2 });
if (this.sf) {
Object.assign(requestOptions.body, { ...this.sf.value });
}
return requestOptions;
};
showAccountDetail(item: any) {
this.modal.create({
nzTitle: '账户明细',
nzContent: AccountDetailComponent,
nzWidth: 600,
nzComponentParams: {},
nzFooter: null
});
}
/**
* 重置表单
*/
resetSF() {
this.sf.reset();
this._$expand = false;
}
/**
* 伸缩查询条件
*/
expandToggle() {
this._$expand = !this._$expand;
this.sf?.setValue('/expand', this._$expand);
}
exportList() {
this.service.downloadFile(this.service.$mock_url, { ...this.sf.value, pageIndex: this.st.pi, pageSize: this.st.ps });
}
private initSF(): SFSchema {
return {
properties: {
expand: {
type: 'boolean',
ui: {
hidden: true
}
},
name: {
type: 'string',
title: '司机姓名',
ui: { placeholder: '请输入' }
},
idNo: {
type: 'string',
title: '证件号码',
ui: { placeholder: '请输入' }
},
phone: {
type: 'string',
title: '手机号',
ui: {
placeholder: '请输入'
}
},
ltdId: {
type: 'string',
title: '网络货运人',
ui: {
widget: 'select',
placeholder: '请选择',
visibleIf: {
expand: (value: boolean) => value
},
allowClear: true,
asyncData: () => this.service.getNetworkFreightForwarder()
}
},
bankType: {
type: 'string',
title: '银行类型',
enum: [
{ label: '全部', value: null },
{ label: '平安银行', value: '1' },
{ label: '浦发银行', value: '2' }
],
ui: {
widget: 'select',
placeholder: '请选择',
change: (i: any) => {
this.sf.value.receiveName2 = i;
this.sf?.setValue('/receiveName2', i);
},
visibleIf: {
expand: (value: boolean) => value
}
},
default: null
},
virtualAccount: {
type: 'string',
title: '虚拟账户',
ui: {
placeholder: '请输入',
visibleIf: {
expand: (value: boolean) => value
}
}
},
createTime: {
title: '创建时间',
type: 'string',
ui: {
widget: 'sl-from-to-search',
format: 'yyyy-MM-dd',
placeholder: '请选择',
visibleIf: {
expand: (value: boolean) => value
}
} as SFDateWidgetSchema
}
}
};
}
private initST(): STColumn[] {
return [
{ title: '司机姓名', index: 'name' },
{ title: '证件号码', index: 'idNo' },
{ title: '手机号', index: 'phone' },
{ title: '网络货运人', index: 'ltdName' },
{ title: '银行类型', index: 'bankTypeLabel' },
{ title: '虚拟账户', index: 'virtualAccount' },
{
title: '可用余额',
index: 'availableBalance',
type: 'currency',
format: item => `${this.currencyPipe.transform(item.availableBalance)}`
},
{
title: '冻结余额',
index: 'freezeBalance',
type: 'currency',
format: item => `${this.currencyPipe.transform(item.availableBalance)}`
},
{
title: '本月累计提现金额',
index: 'withdrawBalance',
width: 150,
type: 'currency',
format: item => `${this.currencyPipe.transform(item.availableBalance)}`
},
{
title: '账户总余额',
index: 'availableBalance',
className: 'text-right',
type: 'link',
format: item => `${this.currencyPipe.transform(item.availableBalance)}`,
click: item => this.showAccountDetail(item)
},
{ title: '创建时间', index: 'createTime', type: 'date', width: 150 },
{
title: '操作',
buttons: [
{
text: '查看明细',
click: item =>
this.router.navigate(['/financial-management/driver-account/detail/' + item.id], {
queryParams: {
name: item.name,
phone: item.phone,
ltdName: item.ltdName,
bankType: item.bankType,
projectId: item.projectId,
availableBalance: item.availableBalance,
enterpriseId: item.enterpriseId,
roleId: item.roleId,
ltdId: item.ltdId
}
})
}
]
}
];
}
}