import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { STComponent, STColumn, STChange, STRequestOptions } from '@delon/abc/st'; import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form'; import { NzModalService } from 'ng-zorro-antd/modal'; import { FreightAccountService } from '../../../services/freight-account.service'; @Component({ selector: 'app-driver-account-detail', templateUrl: './driver-account-detail.component.html', styleUrls: ['../../../../commom/less/box.less', '../../../../commom/less/expend-but.less'] }) export class DriverAccountDetailComponent implements OnInit { @ViewChild('st', { static: true }) st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; columns: STColumn[] = this.initST(); searchSchema: SFSchema = this.initSF(); _$expand = false; info: any = {}; params: any = {}; constructor(public service: FreightAccountService, private route: ActivatedRoute) { this.params = route.snapshot.queryParams; } ngOnInit(): void { this.loadInfo(); } beforeReq = (requestOptions: STRequestOptions) => { Object.assign(requestOptions.body, { ltdId: this.params.ltdId, projectId: this.params.projectId, enterpriseId: this.params.enterpriseId, roleId: this.params.roleId }); if (this.sf) { Object.assign(requestOptions.body, { ...this.sf.value, createTime: { start: this.sf.value?.createTime?.[0] || '', end: this.sf.value?.createTime?.[1] || '' } }); } return requestOptions; }; loadInfo() { this.service .request(this.service.$api_get_driver_account_balance_detail, { ...this.sf?.value, ltdId: this.params.ltdId, projectId: this.params.projectId, enterpriseId: this.params.enterpriseId, roleId: this.params.roleId, pageIndex: this.st.pi, pageSize: this.st.ps, createTime: { start: this.sf?.value?.createTime?.[0] || '', end: this.sf?.value?.createTime?.[1] || '' } }) .subscribe(res => { if (res) { this.info = res; } }); } stChange(e: STChange): void {} exportList() { this.service.downloadFile(this.service.$mock_url, { ...this.sf.value, pageIndex: this.st.pi, pageSize: this.st.ps }); } goBack() { history.go(-1); } /** * 重置表单 */ resetSF() { this.sf.reset(); this._$expand = false; } /** * 伸缩查询条件 */ expandToggle() { this._$expand = !this._$expand; this.sf?.setValue('/expand', this._$expand); } private initSF(): SFSchema { return { properties: { expand: { type: 'boolean', ui: { hidden: true } }, createTime: { title: '交易时间', type: 'string', ui: { widget: 'sl-from-to-search', format: 'yyyy-MM-dd', placeholder: '请选择', nzShowTime: true } as SFDateWidgetSchema }, transactionNumber: { type: 'string', title: '流水号', ui: { placeholder: '请输入' } }, businessNumber: { type: 'string', title: '关联单号', ui: { placeholder: '请输入' } }, tradeType: { type: 'string', title: '交易类型', ui: { widget: 'dict-select', params: { dictKey: 'trade:type' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } }, default: '' }, incomeType: { type: 'string', title: '收支类型', ui: { widget: 'dict-select', params: { dictKey: 'income:type' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } }, default: '' } } }; } private initST(): STColumn[] { return [ { title: '交易时间', index: 'createTime', type: 'date' }, { title: '流水号', index: 'channelPaySn' }, { title: '交易类型', index: 'tradeTypeLabel', className: 'text-center' }, { title: '关联单号', index: 'businessNumber' }, { title: '收支类型', index: 'incomeTypeLabel', className: 'text-center' }, { title: '交易金额', index: 'amount', width: 150, type: 'widget', className: 'text-right', widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.amount }) } }, { title: '账户余额', index: 'accountBalance', width: 150, type: 'widget', className: 'text-right', widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.accountBalance }) } } ]; } }