Files
bbq/src/app/routes/ticket-management/components/invoice-requested/requested-invoice-modal/requested-invoice-modal.component.ts
TaricXin 8a80a1de3c edit
2022-03-14 16:14:31 +08:00

136 lines
4.3 KiB
TypeScript

/*
* @Author: your name
* @Date: 2021-12-23 16:50:17
* @LastEditTime : 2022-01-26 10:36:10
* @LastEditors : Shiming
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath : \\tms-obc-web\\src\\app\\routes\\ticket-management\\components\\invoice-requested\\requested-invoice-modal\\requested-invoice-modal.component.ts
*/
import { Component, ViewChild } from '@angular/core';
import { STChange, STColumn, STComponent, STRequestOptions } from '@delon/abc/st';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { TicketService } from '../../../services/ticket.service';
@Component({
selector: 'app-requested-invoice-modal',
templateUrl: './requested-invoice-modal.component.html',
styleUrls: ['./requested-invoice-modal.component.less']
})
export class RequestedInvoiceModalComponent {
@ViewChild('st1', { static: false })
st1!: STComponent;
columns: STColumn[] = this.initST();
id: any;
selectedRows: any[] = [];
constructor(public service: TicketService, private nzModalService: NzModalService, private modal: NzModalRef) {}
beforeReq = (requestOptions: STRequestOptions) => {
Object.assign(requestOptions.body, { vatappHId: this.id });
return requestOptions;
};
/**
* 移除订单
*
* @returns
*/
removeOrder(item: any[]) {
console.log(item);
this.nzModalService.warning({
nzTitle: '确定从当前批次中移除所有订单?',
nzContent: '移除后相关订单可以重新提交开票申请',
nzOnOk: () => {
const ids = this.selectedRows.map(order => order.billHId);
this.service.request(this.service.$api_remove_bill, ids).subscribe(res => {
if (res) {
this.service.msgSrv.success('移除成功');
this.modal.destroy(true);
}
});
}
});
}
stChange(e: STChange): void {
switch (e.type) {
case 'checkbox':
this.selectedRows = e.checkbox!;
break;
case 'filter':
this.st1.load();
break;
}
}
private initST(): STColumn[] {
return [
{ title: '', index: 'key', type: 'checkbox' },
{ title: '订单号', index: 'billHCode', width: 150 },
{ title: '订单完成日期', index: 'billTime', type: 'date', width: 150 },
{ title: '所属项目', index: 'projectIdName', width: 250 },
{ title: '订单类型', index: 'billTypeName', width: 90 },
{ title: '装货地', index: 'loadingfrom', width: 250 },
{ title: '卸货地', index: 'loadingto', width: 250 },
{ title: '货物信息', index: 'goodsinfo', width: 170 },
{ title: '承运司机', index: 'driverinfo', width: 280 },
{
title: '总费用',
index: 'billkpmoney',
width: 90,
type: 'widget',
className: 'text-right',
widget: { type: 'currency-chy', params: ({ record }: any) => ({ value: record.billkpmoney }) }
},
{
title: '运输费',
index: 'fjfmoney2',
width: 90,
type: 'widget',
className: 'text-right',
widget: { type: 'currency-chy', params: ({ record }: any) => ({ value: record.fjfmoney2 }) }
},
{
title: '附加费',
index: 'fjfmoney',
width: 90,
type: 'widget',
className: 'text-right',
widget: { type: 'currency-chy', params: ({ record }: any) => ({ value: record.fjfmoney }) }
},
{
title: '操作',
width: 80,
fixed: 'right',
className: 'text-center',
buttons: [
{
text: '移除',
click: (item: any) => this.removeOrder([item])
}
]
}
];
}
saveManage() {
if (this.selectedRows?.length <= 0) {
this.service.msgSrv.warning('请选择订单');
return;
}
const selectedRows = this.selectedRows.map(item => {
return { ...item };
});
const params = {
ficoVatappBillVOList: selectedRows.map(item => {
delete item._values;
return item;
}),
id: this.id
};
this.service.request(this.service.$api_get_applyFicoVatinv, params).subscribe((res: any) => {
if (res) {
this.service.msgSrv.success('开票成功');
this.modal.destroy(true);
}
});
}
}