267 lines
7.6 KiB
TypeScript
267 lines
7.6 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, SFSchema } from '@delon/form';
|
|
import { NzModalService } from 'ng-zorro-antd/modal';
|
|
import { TicketService } from '../../services/ticket.service';
|
|
|
|
@Component({
|
|
selector: 'app-invoice-detail',
|
|
templateUrl: './invoice-detail.component.html',
|
|
styleUrls: ['./invoice-detail.component.less']
|
|
})
|
|
export class InvoiceDetailComponent implements OnInit {
|
|
@ViewChild('orderST', { static: true })
|
|
orderST!: STComponent;
|
|
@ViewChild('orderSf', { static: false })
|
|
orderSf!: SFComponent;
|
|
orderColumns: STColumn[] = this.initOrderST();
|
|
orderSchema: SFSchema = this.initOrderSF();
|
|
|
|
@ViewChild('costST', { static: true })
|
|
costST!: STComponent;
|
|
@ViewChild('costSf', { static: false })
|
|
costSf!: SFComponent;
|
|
costColumns: STColumn[] = this.initCostST();
|
|
costSchema: SFSchema = this.initCostSF();
|
|
|
|
@ViewChild('invoiceST', { static: true })
|
|
invoiceST!: STComponent;
|
|
invoiceColumns: STColumn[] = this.initInvoiceST();
|
|
|
|
isCanEdit = false;
|
|
isEdit = false;
|
|
|
|
headerInfo: any = {};
|
|
routesInfo: any = {
|
|
mailNo: '',
|
|
routes: []
|
|
};
|
|
id: any = null;
|
|
type: any = 1;
|
|
constructor(public service: TicketService, private route: ActivatedRoute) {
|
|
this.isCanEdit = !!route.snapshot.queryParams.type;
|
|
const expressno = route.snapshot.queryParams.expressno;
|
|
this.type = route.snapshot.queryParams.type;
|
|
this.id = route.snapshot.params.id;
|
|
this.loadInvoiceHeader(this.id);
|
|
if (expressno) {
|
|
this.loadRoutes(expressno);
|
|
}
|
|
}
|
|
|
|
ngOnInit(): void {}
|
|
|
|
beforeReq = (requestOptions: STRequestOptions) => {
|
|
Object.assign(requestOptions.body, { vatinvHId: this.id });
|
|
if (this.orderSf) {
|
|
Object.assign(requestOptions.body, { ...this.orderSf.value });
|
|
}
|
|
if (this.costSf) {
|
|
Object.assign(requestOptions.body, { ...this.costSf.value });
|
|
}
|
|
return requestOptions;
|
|
};
|
|
|
|
loadInvoiceHeader(id: string) {
|
|
this.service.request(this.service.$api_get_invoice_header_detail, { id }).subscribe(res => {
|
|
if (res) {
|
|
this.headerInfo = res;
|
|
}
|
|
});
|
|
}
|
|
loadRoutes(expressno: string) {
|
|
this.service.request(this.service.$api_get_express_routes, expressno).subscribe(res => {
|
|
if (res) {
|
|
res.routes = res.routes.map((route: any) => ({ time: route.acceptTime, value: route.remark + route.acceptAddress, color: 'gray' }));
|
|
this.routesInfo = res;
|
|
}
|
|
});
|
|
}
|
|
goBack() {
|
|
history.go(-1);
|
|
}
|
|
|
|
saveInvoices() {
|
|
this.isEdit = false;
|
|
}
|
|
|
|
/**
|
|
* 重置表单
|
|
*/
|
|
resetSF(tab: number) {
|
|
switch (tab) {
|
|
case 1:
|
|
this.orderSf.reset();
|
|
break;
|
|
case 2:
|
|
this.costSf.reset();
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
private initOrderSF(): SFSchema {
|
|
return {
|
|
properties: {
|
|
billHCode: {
|
|
type: 'string',
|
|
title: '订单号',
|
|
ui: {
|
|
autocomplete: 'off'
|
|
}
|
|
},
|
|
billType: {
|
|
type: 'string',
|
|
title: '订单类型',
|
|
enum: [
|
|
{ label: '全部', value: '' },
|
|
{ label: '整车', value: 1 },
|
|
{ label: '大宗', value: 2 }
|
|
],
|
|
ui: {
|
|
widget: 'select',
|
|
placeholder: '请选择'
|
|
},
|
|
default: ''
|
|
},
|
|
projectId: {
|
|
type: 'string',
|
|
title: '所属项目',
|
|
ui: {
|
|
widget: 'select',
|
|
placeholder: '请选择',
|
|
allowClear: true,
|
|
asyncData: () => this.service.getEnterpriseProject()
|
|
},
|
|
default: ''
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
private initOrderST(): STColumn[] {
|
|
return [
|
|
{ title: '订单号', index: 'billHCode', width: 180 },
|
|
{ title: '订单完成日期', index: 'billTime', type: 'date', width: 150 },
|
|
{ title: '所属项目', index: 'projectIdName', width: 180 },
|
|
{ title: '订单类型', index: 'billTypeLabel', width: 120 },
|
|
{ title: '装货地', index: 'loadingfrom', width: 200 },
|
|
{ title: '卸货地', index: 'loadingto', width: 220 },
|
|
{ title: '货物信息', index: 'goodsinfo', width: 140 },
|
|
{ title: '承运司机', index: 'driverinfo', width: 280 },
|
|
{
|
|
title: '申请金额',
|
|
index: 'billkpnotax',
|
|
width: 120,
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: this.type ==='2'?record.billkpmoney: record.billkpnotax }) }
|
|
},
|
|
{
|
|
title: '运输费',
|
|
index: 'fjfmoney2',
|
|
width: 120,
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.fjfmoney2 }) }
|
|
},
|
|
{
|
|
title: '附加费',
|
|
index: 'fjfmoney',
|
|
width: 120,
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.fjfmoney }) }
|
|
},
|
|
{
|
|
title: '开票金额',
|
|
index: 'billkpmoney',
|
|
width: 120,
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.billkpmoney }) }
|
|
}
|
|
];
|
|
}
|
|
|
|
private initCostSF(): SFSchema {
|
|
return {
|
|
properties: {
|
|
billHId: {
|
|
type: 'string',
|
|
title: '订单号',
|
|
ui: {
|
|
autocomplete: 'off'
|
|
}
|
|
},
|
|
feeHId: {
|
|
type: 'string',
|
|
title: '费用号',
|
|
ui: {
|
|
autocomplete: 'off'
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
private initCostST(): STColumn[] {
|
|
return [
|
|
{ title: '费用号', index: 'feeHId' },
|
|
{ title: '订单号', index: 'billHCode' },
|
|
{ title: '订单日期', index: 'createTime', type: 'date' },
|
|
{ title: '计费日期', index: 'feeDate', type: 'date' },
|
|
{ title: '税率', index: 'vatrate', format: item => `${item.vatrate ? ((item.vatrate as number) * 100).toFixed(2) : 0}%` },
|
|
{
|
|
title: '申请金额',
|
|
index: 'vatmoney',
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.vatmoney }) }
|
|
},
|
|
{
|
|
title: '开票金额',
|
|
index: 'vatnotax',
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.vatnotax }) }
|
|
}
|
|
];
|
|
}
|
|
|
|
private initInvoiceST(): STColumn[] {
|
|
return [
|
|
{ title: '服务名称', render: 'vatname', width: 350 },
|
|
{ title: '规格型号', render: 'vatmodel' },
|
|
{ title: '单位', render: 'vatunit', width: 100 },
|
|
{ title: '数量', render: 'vatqty', width: 140, className: 'text-right' },
|
|
{
|
|
title: '金额',
|
|
index: 'vatnotax',
|
|
width: 140,
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.vatnotax }) }
|
|
},
|
|
{
|
|
title: '税率',
|
|
index: 'vatrate',
|
|
width: 140,
|
|
className: 'text-right',
|
|
format: item => `${item.vatrate ? ((item.vatrate as number) * 100).toFixed(2) : 0}%`
|
|
},
|
|
{
|
|
title: '税额',
|
|
index: 'vattax',
|
|
width: 140,
|
|
type: 'widget',
|
|
className: 'text-right',
|
|
widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.vattax }) }
|
|
}
|
|
];
|
|
}
|
|
}
|