import { CurrencyPipe } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { STData, STColumn, STRequestOptions } from '@delon/abc/st';
import { FreightAccountService } from '../../../services/freight-account.service';

@Component({
  selector: 'app-voucher-detail',
  templateUrl: './voucher-detail.component.html'
})
export class VoucherDetailComponent implements OnInit {
  columns: STColumn[] = [
    { title: '摘要', index: 'remarks' },
    { title: '会计科目', index: 'subname' },
    { title: '辅助核算', render: 'auxVOList' },
    { title: '币种', index: 'currency', className: 'text-center' },
    {
      title: '借方金额',
      index: 'drlocalmoney',
      width: 150,
      type: 'widget',
      className: 'text-right',
      widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.drlocalmoney }) }
    },
    {
      title: '贷方金额',
      index: 'crlocalmoney',
      width: 150,
      type: 'widget',
      className: 'text-right',
      widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.crlocalmoney }) }
    }
  ];
  id!: string;

  info: any = { faShowVOList: [] };

  constructor(public service: FreightAccountService, private route: ActivatedRoute) {
    this.id = route.snapshot.params.id;
  }

  ngOnInit(): void {
    this.loadDetail(this.id);
  }

  loadDetail(id: string) {
    this.service.request(this.service.$api_get_fico_vch__detail, { id }).subscribe(res => {
      if (res) {
        this.info = res;
      }
    });
  }

  goBack() {
    history.go(-1);
  }
}
