export const requireHeaders = ["itemId", "code", "num", "total_amount", "companyNo"];


export const columns = [
  {
    label: '发票信息',
    child: [
      {
        label: '发票明细ID',
        width: '110px',
        prop: 'itemId',
        required: true
      },
      {
        label: '对账回票编号',
        width: '160px',
        prop: 'hpNo'
      },
      {
        label: '发票类型',
        width: '120px',
        prop: 'invoiceType'
      },
      {
        label: '发票号码',
        width: '120px',
        prop: 'invoiceNumber'
      },
      {
        label: '开票日期',
        width: '100px',
        prop: 'openDate'
      },
      {
        label: '购买方名称',
        width: '160px',
        prop: 'buyerName'
      },
      {
        label: '购买方纳税人识别号',
        width: '160px',
        prop: 'buyerId'
      },
      {
        label: '销售方名称',
        width: '160px',
        prop: 'sellerName'
      },
      {
        label: '销售方纳税人识别号',
        width: '160px',
        prop: 'sellerId'
      },
      {
        label: '类目编号',
        width: '120px',
        prop: 'catCode'
      },
      {
        label: '货物或应税劳务、服务名称',
        width: '170px',
        prop: 'hw_name'
      },
      {
        label: '单位',
        width: '80px',
        prop: 'name'
      },
      {
        label: '数量',
        width: '80px',
        prop: 'num'
      },
      {
        label: '单价',
        width: '80px',
        prop: 'before_good_price'
      },
      {
        label: '金额',
        width: '80px',
        prop: 'amount'
      },
      {
        label: '税率',
        width: '80px',
        prop: 'tax'
      },
      {
        label: '税额',
        width: '80px',
        prop: 'tax_amount'
      },
      {
        label: '税后单价',
        width: '80px',
        prop: 'good_price'
      },      
      {
        label: '税后金额',
        width: '80px',
        prop: 'after_tax_amount'
      },   
    ],
  },
  {
    label: '采购单关联金额',
    prop: 'total_amount',
    width: '110px',
    required: true
  },
  {
    label: '订单信息',
    child: [
      {
        label: '对账单号',
        prop: 'payNo',
        width: '160px'
      },
      {
        label: '采购单编号',
        prop: 'code',
        width: '160px',
        required: true
      },
      {
        label: '销售单编号',
        prop: 'code_1',
        width: '120px'
      },
      {
        label: '供货商',
        prop: 'supplierName',
        width: '120px'
      },      
      {
        label: '业务公司',
        prop: 'companyName',
        width: '120px'
      },
      {
        label: '订单单位',
        prop: 'orderUnit',
        width: '90px'
      },
      {
        label: '商品数量',
        prop: 'goodNum',
        width: '90px'
      },
      {
        label: '商品单价',
        prop: 'goodPrice',
        width: '90px'
      },
      {
        label: '总货款',
        prop: 'totalAmount',
        width: '90px'
      },
      {
        label: '销售主单号',
        prop: 'goodPrice',
        width: '120px'
      },
      {
        label: '商品编码',
        prop: 'goodCode',
        width: '120px'
      },
      {
        label: '商品名称',
        prop: 'goodName',
        width: '120px'
      },      
      {
        label: '货物和劳务名称',
        prop: 'orderCatCode',
        width: '120px'
      },
      {
        label: '商品开票类目',
        prop: 'goodOpenCatCode',
        width: '120px'
      },
      {
        label: '商品和服务分类简称',
        prop: 'goodShortName',
        width: '140px'
      },
      {
        label: '开票税率',
        prop: 'orderTax',
        width: '100px'
      },
      {
        label: '开票商品名称',
        prop: 'openGoodName',
        width: '120px'
      },
      {
        label: '开票类型',
        prop: 'openGoodName',
        width: '100px'
      },
      {
        label: '采购单可关联金额',
        prop: 'balance_amount',
        width: '120px'
      }
    ]
  }

]





export function getHeaders(){
  const initHeader:string[] = []
  const mapLabelToProp:Map<string,string> = new Map()
  const requireFields: Record<string, string>[] = []


  columns.forEach(({ prop, label, child, required }) => {
    if(prop) {
      initHeader.push(label)
      mapLabelToProp.set(label, prop)
      if(required) requireFields.push({ prop, label })
    }

    if(child) {
      child.forEach(children => {
        initHeader.push(children.label)
        mapLabelToProp.set(children.label, children.prop)
        if(children.required) requireFields.push({ prop: children.prop, label: children.label })
      })
    }
  })

  return {
    initHeader,
    mapLabelToProp,
    requireFields
  }
}
