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 { NzModalService } from 'ng-zorro-antd/modal'; import { TicketService } from '../../services/ticket.service'; @Component({ selector: 'app-invoiced-list', templateUrl: './invoiced-list.component.html', styleUrls: ['./invoiced-list.component.less'] }) export class InvoicedListComponent implements OnInit { @ViewChild('st', { static: true }) st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; @ViewChild('logosticsModal', { static: false }) logosticsModal!: any; @ViewChild('logosticsLogsModal', { static: false }) logosticsLogsModal!: any; columns: STColumn[] = this.initST(); searchSchema: SFSchema = this.initSF(); _$expand = false; selectedRows: any[] = []; totalCallNo = 0; constructor(public service: TicketService, private nzModalService: NzModalService, private router: Router) {} ngOnInit(): void {} beforeReq = (requestOptions: STRequestOptions) => { 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; }; stChange(e: STChange): void { switch (e.type) { case 'checkbox': this.selectedRows = e.checkbox!; this.totalCallNo = this.selectedRows.reduce((total, cv) => total + cv.vatnotax, 0); break; } } approval(): void {} add(): void {} deletedInvoice() { if (this.selectedRows?.length <= 0) { this.service.msgSrv.warning('请选择发票'); return; } this.nzModalService.warning({ nzTitle: '确定将所选发票作废?', nzCancelText: '取消', nzOnOk: () => {} }); } invoiceHongChong() { if (this.selectedRows?.length <= 0) { this.service.msgSrv.warning('请选择发票'); return; } this.nzModalService.warning({ nzTitle: '确定将所选发票红冲?', nzCancelText: '取消', nzOnOk: () => {} }); } showlogosticsLogs(item: any) { this.nzModalService.create({ nzTitle: '查看物流', nzWidth: 600, nzContent: this.logosticsLogsModal, nzFooter: [] }); } /** * 重置表单 */ 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 } }, invoiceno: { type: 'string', title: '发票号码', ui: { autocomplete: 'off' } }, vatinvcode: { type: 'string', title: '申请编号', ui: { autocomplete: 'off' } }, createTime: { title: '开票日期', type: 'string', ui: { widget: 'sl-from-to-search', format: 'yyyy-MM-dd', placeholder: '请选择', nzShowTime: true } as SFDateWidgetSchema }, arto: { type: 'string', title: '购买人', enum: [{ label: '全部', value: '全部' }], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, ltdId: { type: 'string', title: '网络货运人', ui: { widget: 'select', placeholder: '请选择', allowClear: true, visibleIf: { expand: (value: boolean) => value }, asyncData: () => this.service.getNetworkFreightForwarder() }, default: '' } } }; } private initST(): STColumn[] { return [ { title: '', index: 'key', type: 'checkbox' }, { title: '发票号码', index: 'invoiceno', width: 150 }, { title: '申请编号', index: 'vatinvcode', width: 150 }, { title: '申请时间', index: 'createTime', type: 'date', width: 150 }, { title: '发票类型', index: 'invoicetype', width: 100 }, { title: '网络货运人', index: 'ltdId', width: 120 }, { title: '购买人', index: 'artoname', width: 90 }, { title: '订单数', index: 'ordlines', width: 90 }, { title: '价税合计', index: 'vatmoney', width: 100 }, { title: '金额', index: 'vatnotax', width: 90 }, { title: '税率', index: 'vatrate', width: 90 }, { title: '税额', index: 'disvattax', width: 90 }, { title: '开票日期', index: 'invoicedate', type: 'date', width: 150 }, { title: '快递信息', render: 'expresscompany', width: 120 }, { title: '状态', index: 'sts', width: 90 }, { title: '操作', fixed: 'right', className: 'text-center', width: 110, buttons: [ { text: '查看明细', click: item => this.router.navigate(['/ticket/invoice-list/detail/' + item.id]) }, { text: '查看物流', click: item => this.showlogosticsLogs(item) } ] } ]; } }