import { CurrencyPipe } from '@angular/common'; import { Component, OnInit, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { STComponent, STColumn, STRequestOptions, STChange } from '@delon/abc/st'; import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form'; import { ShipperBaseService } from '@shared'; import { NzModalService } from 'ng-zorro-antd/modal'; import { AddCollectionInvoiceModalComponent } from 'src/app/routes/ticket-management/components/input-invoice/add-collection-invoice-modal/add-collection-invoice-modal.component'; import { FreightAccountService } from '../../services/freight-account.service'; @Component({ selector: 'app-voucher-management', templateUrl: './voucher-management.component.html', styleUrls: ['../../../commom/less/box.less'], providers: [CurrencyPipe] }) export class VoucherManagementComponent implements OnInit { @ViewChild('st', { static: true }) st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; @ViewChild('auditModal', { static: false }) auditModal!: any; columns: STColumn[] = this.initST(); searchSchema: SFSchema = this.initSF(); _$expand = false; selectedRows: any[] = []; constructor( public service: FreightAccountService, private nzModalService: NzModalService, private router: Router, private currencyPipe: CurrencyPipe ) {} ngOnInit(): void {} beforeReq = (requestOptions: STRequestOptions) => { if (this.sf) { Object.assign(requestOptions.body, { ...this.sf.value }); if (this.sf.value.createTime) { Object.assign(requestOptions.body, { createTime: { start: this.sf.value.createTime?.[0] || null, end: this.sf.value.createTime?.[1] || null } }); } if (this.sf.value.vctime) { Object.assign(requestOptions.body, { vctime: { start: this.sf.value.vctime?.[0] || null, end: this.sf.value.vctime?.[1] || null } }); } } return requestOptions; }; stChange(e: STChange): void { switch (e.type) { case 'checkbox': this.selectedRows = e.checkbox!; break; } } /** * 重置表单 */ 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 } }, vccode: { type: 'string', title: '凭证号', ui: { autocomplete: 'off', placeholder: '请输入' } }, cno: { type: 'string', title: '客户', ui: { widget: 'select', placeholder: '请选择', allowClear: true, asyncData: () => this.service.getNetworkFreightForwarder() }, default: '' }, vctime: { title: '凭证时间', type: 'string', ui: { widget: 'sl-from-to-search', format: 'yyyy-MM-dd' } as SFDateWidgetSchema }, sourceCode: { type: 'string', title: '原始单号', ui: { autocomplete: 'off', placeholder: '请输入', visibleIf: { expand: (value: boolean) => value } } }, sourceType: { type: 'string', title: '原始单类型', ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, createTime: { title: '创建时间', type: 'string', ui: { widget: 'sl-from-to-search', format: 'yyyy-MM-dd', visibleIf: { expand: (value: boolean) => value } } as SFDateWidgetSchema }, inpinvcosde: { type: 'string', title: '凭证摘要', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => value } } }, vctype: { type: 'string', title: '凭证类型', ui: { widget: 'dict-select', params: { dictKey: 'credential:type' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } }, default: '' }, subid: { type: 'string', title: '科目', ui: { widget: 'dict-select', params: { dictKey: 'refund:apply:status' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, drmoney: { type: 'string', title: '借方金额', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => value } } }, crmoney: { type: 'string', title: '贷方金额', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => value } } }, vcltdid: { type: 'string', title: '帐套', ui: { widget: 'dict-select', params: { dictKey: 'refund:apply:status' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, sts: { type: 'string', title: '凭证状态', ui: { widget: 'dict-select', params: { dictKey: 'credential:status' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } }, default: '' }, importncnotes: { type: 'string', title: 'NC凭证', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => value } } }, vc2code: { type: 'string', title: '汇总凭证号', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => value } } }, importnc: { type: 'string', title: '导入NC', ui: { widget: 'dict-select', params: { dictKey: 'refund:apply:status' }, placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, isvc2: { type: 'string', title: '是否汇总', enum: [ { value: null, label: '全部' }, { value: 0, label: '否' }, { value: 1, label: '是' } ], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } } } }; } private initST(): STColumn[] { return [ { title: '', index: 'key', type: 'checkbox', width: 60, className: 'text-center', fixed: 'left' }, { title: '凭证号', index: 'id', type: 'link', width: 150 }, { title: '帐套', index: 'vcltdid', width: 150 }, { title: '凭证时间', index: 'vctime', type: 'date', width: 150 }, { title: '凭证类型', index: 'vctype', enum: { WLW: 'WLW', CH: 'CH', YHY: 'YHY', KP: 'KP' }, width: 150 }, { title: '序号', index: 'invmoney', width: 150, format: _ => '1' }, { title: '摘要', index: 'remarks', width: 300 }, { title: '币种', index: 'currency', width: 100 }, { title: '借方金额', index: 'drmoney', width: 120, className: 'text-right', format: item => `${this.currencyPipe.transform(item.armoney || 0)}` }, { title: '贷方金额', index: 'crmoney', width: 120, className: 'text-right', format: item => `${this.currencyPipe.transform(item.armoney || 0)}` }, { title: 'NC凭证', index: 'importncnotes', width: 150 }, { title: '汇总凭证号', index: 'vc2id', width: 150 }, { title: '凭证状态', index: 'sts', enum: { 0: '新建', 1: '待审核', 2: '已通过' }, width: 120 }, { title: '创建时间', index: 'createTime', width: 140 }, { title: '创建人', index: 'createUserId', width: 150 }, { title: '操作', width: '130px', fixed: 'right', buttons: [ { text: '浏览', click: (item: any) => this.router.navigate(['/financial-management/voucher-management/detail/' + item.id]) }, { text: '修改' }, { text: '删除' }, { text: '提交' } ] } ]; } }