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

@Component({
  selector: 'app-cost-management-detail',
  templateUrl: './cost-management-detail.component.html',
  styleUrls: ['./cost-management-detail.component.less']
})
export class CostManagementDetailComponent implements OnInit {
  @ViewChild('st', { static: true })
  st!: STComponent;
  columns: { [key: string]: STColumn[] } = this.initST();

  data = [];

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

  ngOnInit(): void {}

  loadDetail(id: any) {
    this.service.request(this.service.$api_get_cost_detail, { id }).subscribe(res => {
      console.log(res);

      if (res) {
        this.costInfo = res;
      }
    });
  }

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

  private initST(): { [key: string]: STColumn[] } {
    return {
      cost: [
        { title: '序号', render: 'no', width: 70 },
        { title: '费用明细号', index: 'feeHId' },
        { title: '订单号', index: 'billHId' },
        { title: '订单日期', index: 'callNo' },
        { title: '运单号', index: 'waybillHId' },
        { title: '运单日期', index: 'waybillDate' },
        { title: '结算客户', index: 'callNo' },
        { title: '订单费用类型', index: 'billLType' },
        { title: '费用科目', index: 'feeSubId' },
        { title: '税率', index: 'hrvatrate' },
        { title: '费用金额', index: 'hrvatmoney' },
        { title: '收/付款金额', index: 'armoney' },
        { title: '开/收票金额', index: 'arkpmoney' }
      ],
      requested: [
        { title: '序号', render: 'no', width: 70 },
        { title: '费用明细号', index: 'feeHId' },
        { title: '发票申请', index: 'vatappcode' },
        { title: '发票类型', index: 'vatapptype' },
        { title: '发票号', index: 'vatappcode' },
        { title: '发票日期', index: 'vatappdate' },
        { title: '发票状态', index: 'sts' },
        { title: '应收金额', index: 'vatnotax' },
        { title: '开票金额', index: 'vatmoney' }
      ],
      collection: [
        { title: '序号', index: 'no' },
        { title: '费用明细号', index: 'callNo' },
        { title: '收款单号', index: 'callNo' },
        { title: '收款日期', index: 'callNo' },
        { title: '收款状态', index: 'callNo' },
        { title: '应收金额', index: 'callNo' },
        { title: '收款金额', index: 'callNo' }
      ],
      ticket: [
        { title: '序号', index: 'no' },
        { title: '费用明细号', index: 'callNo' },
        { title: '进项发票号', index: 'callNo' },
        { title: '发票类型', index: 'callNo' },
        { title: '发票日期', index: 'callNo' },
        { title: '认证日期', index: 'callNo' },
        { title: '发票状态', index: 'callNo' },
        { title: '应付金额', index: 'callNo' },
        { title: '收票金额', index: 'callNo' }
      ],
      payment: [
        { title: '序号', index: 'no' },
        { title: '费用明细号', index: 'callNo' },
        { title: '付款单号', index: 'callNo' },
        { title: '要求日期', index: 'callNo' },
        { title: '确认日期', index: 'callNo' },
        { title: '付款状态', index: 'callNo' },
        { title: '应付金额', index: 'callNo' },
        { title: '付款金额', index: 'callNo' }
      ]
    };
  }
}
