import { Component, OnInit, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { STComponent, STColumn, STRequestOptions } from '@delon/abc/st'; import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form'; import { NzModalService } from 'ng-zorro-antd/modal'; import { FreightAccountService } from '../../services/freight-account.service'; @Component({ selector: 'app-cost-management', templateUrl: './cost-management.component.html', styleUrls: ['../../../commom/less/box.less'] }) export class CostManagementComponent implements OnInit { @ViewChild('st', { static: true }) st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; @ViewChild('auditModal', { static: false }) auditModal!: any; searchSchema: SFSchema = this.initSF(); columns: STColumn[] = this.initST(); selectedRows: any[] = []; _$expand = false; constructor(public service: FreightAccountService, private nzModalService: NzModalService, private router: Router) {} ngOnInit(): void {} beforeReq = (requestOptions: STRequestOptions) => { if (this.sf) { Object.assign(requestOptions.body, { ...this.sf.value, feedate: { start: this.sf.value.feedate?.[0] || '', end: this.sf.value.feedate?.[1] || '' }, createTime: { start: this.sf.value.createTime?.[0] || '', end: this.sf.value.createTime?.[1] || '' } }); } return requestOptions; }; auditAction(item: any) { const modal = this.nzModalService.create({ nzTitle: '审核', nzContent: this.auditModal, nzFooter: [ { label: '拒绝', type: 'default', onClick: () => { modal.destroy(); } }, { label: '通过', type: 'primary', onClick: () => { modal.destroy(); } } ] }); modal.afterClose.subscribe(res => { this.st.load(); }); } /** * 重置表单 */ resetSF() { this.sf.reset(); this._$expand = false; } /** * 伸缩查询条件 */ expandToggle() { this._$expand = !this._$expand; this.sf?.setValue('/expand', this._$expand); } exportList() { this.service.downloadFile(this.service.$mock_url, { ...this.sf.value, pageIndex: this.st.pi, pageSize: this.st.ps }); } routeTo(url: string, params?: any,status?: any) { this.router.navigate([url], { queryParams: params }); } private initSF(): SFSchema { return { properties: { expand: { type: 'boolean', ui: { hidden: true } }, feecode: { type: 'string', title: '费用单号', ui: { placeholder: '请输入' } }, billHId: { type: 'string', title: '订单号', ui: { placeholder: '请输入' } }, waybillHId: { type: 'string', title: '运单号', ui: { placeholder: '请输入' } }, feedate: { title: '费用日期', type: 'string', ui: { widget: 'sl-from-to-search', format: 'yyyy-MM-dd', placeholder: '请选择', nzShowTime: true, visibleIf: { expand: (value: boolean) => value } } as SFDateWidgetSchema }, feetype: { type: 'string', title: '费用类型', enum: [ { label: '全部', value: '' }, { label: '应收', value: 1 }, { label: '应付', value: 2 } ], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } }, default: '' }, feeSubId: { 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, asyncData: () => this.service.getNetworkFreightForwarder(), visibleIf: { expand: (value: boolean) => value } } }, hrto: { type: 'string', title: '应付对象', enum: [{ label: '全部', value: '全部' }], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, arto: { type: 'string', title: '应收对象', enum: [{ label: '全部', value: '全部' }], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } }, createTime: { title: '创建时间', type: 'string', ui: { widget: 'sl-from-to-search', format: 'yyyy-MM-dd', placeholder: '请选择', nzShowTime: true, visibleIf: { expand: (value: boolean) => value } } as SFDateWidgetSchema }, ishrhx: { type: 'string', title: '应付核销', enum: [ { label: '全部', value: '' }, { label: '否', value: 0 }, { label: '是', value: 1 } ], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } }, default: '' }, cno: { type: 'string', title: '结算客户', enum: [{ label: '全部', value: '全部' }], ui: { widget: 'select', placeholder: '请选择', visibleIf: { expand: (value: boolean) => value } } } } }; } private initST(): STColumn[] { return [ { title: '费用单号', fixed: 'left', index: 'feecode', width: 200 ,className: 'text-left',}, { title: '网络货运人', index: 'ltdName', width: 220 ,className: 'text-left',}, { title: '订单号', index: 'billHCode', width: 200,className: 'text-left', }, { title: '运单号', index: 'waybillHCode', width: 200 ,className: 'text-left',}, { title: '费用日期', index: 'feedate', width: 200 ,className: 'text-left',}, { title: '费用类型', index: 'feetypeLabel', width: 150,className: 'text-center', }, { title: '应付核销', index: 'ishrhx', width: 200, type: 'enum', enum: { 0: '否', 1: '是' } ,className: 'text-left',}, { title: '结算客户', render: 'artocode', width: 200 ,className: 'text-left',}, { title: '应收对象', index: 'artoname', width: 200 ,className: 'text-left',}, { title: '应付对象', index: 'hrtoname', width: 200 ,className: 'text-left',}, { title: '应收金额', render: 'armoeny', width: 100 ,className: 'text-right',}, { title: '应付金额', render: 'hrmoney', width: 100 ,className: 'text-right',}, { title: '收/付款金额', render: 'hrpaymoney', width: 120 ,className: 'text-right',}, { title: '开/收票金额', render: 'hrvatmoney', width: 120 ,className: 'text-right',}, { title: '创建时间', index: 'auditTime', type: 'date', width: 200 ,className: 'text-center',}, { title: '状态', index: 'stsLabel', width: 90 ,className: 'text-center',}, { title: '操作', fixed: 'right', className: 'text-center', width: '110px', buttons: [ { text: '浏览', click: item => this.routeTo('/financial-management/cost-management/detail/' + item.id , {status : item?.feetypeLabel}) }, { text: '审核', click: item => this.auditAction(item), iif: item => item.sts === 2 }, // { // text: '修改', // click: item => this.router.navigate(['/financial-management/cost-management/expenses-receivable/1'], { queryParams: { id: 1 } }) // } ] } ]; } }