Files
bbq/src/app/routes/financial-management/components/freight-account/freight-account-detail/freight-account-detail.component.ts
Taric Xin 1454acc726 edit
2021-12-27 21:00:35 +08:00

175 lines
4.9 KiB
TypeScript

import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { STComponent, STColumn, STChange, STRequestOptions } from '@delon/abc/st';
import { SFComponent, SFDateWidgetSchema, SFSchema, SFSelectWidgetSchema } from '@delon/form';
import { NzModalService } from 'ng-zorro-antd/modal';
import { FreightAccountService } from '../../../services/freight-account.service';
@Component({
selector: 'app-freight-account-detail',
templateUrl: './freight-account-detail.component.html',
styleUrls: ['./freight-account-detail.component.less']
})
export class FreightAccountDetailComponent implements OnInit {
@ViewChild('st', { static: true })
st!: STComponent;
@ViewChild('sf', { static: false })
sf!: SFComponent;
columns: STColumn[] = this.initST();
searchSchema: SFSchema = this.initSF();
info: any = {};
_$expand = false;
constructor(public service: FreightAccountService, private nzModalService: NzModalService, private route: ActivatedRoute) {}
ngOnInit(): void {}
beforeReq = (requestOptions: STRequestOptions) => {
Object.assign(requestOptions.body, { transactionNumber: this.route.snapshot.params.id });
if (this.sf) {
Object.assign(requestOptions.body, { ...this.sf.value });
}
return requestOptions;
};
afterReq = (data: any[], rawData?: any) => {
console.log(data, rawData);
if (rawData?.success) {
this.info = {
incomeAmount: rawData.data.rawData,
payAmount: rawData.data.payAmount
};
}
return data;
};
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: 'date',
mode: 'range',
format: 'yyyy-MM-dd'
} as SFDateWidgetSchema
},
transactionNumber: {
type: 'string',
title: '流水号',
ui: {
placeholder: '请输入'
}
},
businessNumber: {
type: 'string',
title: '关联单号',
ui: {
placeholder: '请输入'
}
},
tradeType: {
type: 'string',
title: '交易类型',
enum: [
{ label: '全部', value: '' },
{ label: '整车订单退款', value: '1' },
{ label: '整车订单支付', value: '2' },
{ label: '提现失败退回', value: '3' },
{ label: '提现', value: '4' },
{ label: '充值', value: '5' },
{ label: '运货订单结算F', value: '5' }
],
ui: {
widget: 'select',
placeholder: '请选择',
visibleIf: {
expand: (value: boolean) => value
}
},
default: ''
},
incomeType: {
type: 'string',
title: '收支类型',
enum: [
{ label: '全部', value: '' },
{ label: '收入', value: '1' },
{ label: '支出', value: '2' }
],
ui: {
widget: 'select',
placeholder: '请选择',
visibleIf: {
expand: (value: boolean) => value
}
},
default: ''
},
projectId: {
title: '项目',
type: 'string',
default: '',
ui: {
widget: 'select',
visibleIf: {
expand: (value: boolean) => value
},
asyncData: () => this.service.getEnterpriseProject()
} as SFSelectWidgetSchema
}
}
};
}
private initST(): STColumn[] {
return [
{ title: '交易时间', index: 'updatedAt', type: 'date' },
{ title: '流水号', index: 'transactionNumber' },
{
title: '交易类型',
index: 'tradeType',
type: 'enum',
enum: { 1: '整车订单退款', 2: '整车订单支付', 3: '提现失败退回', 4: '提现', 5: '充值', 6: '运货订单结算' }
},
{ title: '关联单号', index: 'businessNumber' },
{ title: '所属项目', index: 'projectId' },
{ title: '收支类型', index: 'incomeType', type: 'enum', enum: { 1: '收入', 2: '支出' } },
{ title: '交易金额', index: 'amount' },
{ title: '账户余额', index: 'accountBalance' }
];
}
}