const initheaders = [
  "业务公司编码",
  "业务公司名称",
  "收款方公司编码",
  "收款方公司名称",
  "收款方账户",
  "交易时间",
  "客户机构名称",
  "客户付款银行户名",
  "客户PO",
  "ND编号",
  "平台采购PO",
  "泰e购SKU",
  "平台物料名称",
  "产品数量",
  "平台公司收入单价",
  "平台公司收入总价",
  "税率(%)",
  "税收编码",
  "业务公司收入单价",
  "业务公司收入总价",
  "交易用途",
  "创建人",
  "创建时间"
];

export const requireHeaders = [
  "收款方公司编码",
  "收款方账户",
  "交易时间",
  "收入金额",
  "交易行名",
  "对方账号",
  "对方户名"
];

const getValueName = (label: string) => 'value' + initheaders.findIndex(item => item === label)
console.log(getValueName)

export const requsetHeaderIdxs = [
  getValueName('收款方公司编码'),
  getValueName('收款方账户'),
  getValueName('交易时间'),
  getValueName('收入金额'),
  getValueName('交易行名'),
  getValueName('对方账号'),
  getValueName('对方户名'),
];


export const initialColumns = [
  {
    label: '业务公司编码',
    width: '130px',
    prop: 'companyNo',
    required: true
  },
  {
    label: '业务公司名称',
    width: '130px',
    prop: 'companyName',
    required: true
  },
  {
    label: '收款方公司编码',
    width: '160px',
    prop: 'trade_in_code',
    required: true
  },
  {
    label: '收款方公司名称',
    width: '160px',
    prop: 'trade_in',
    required: true
  },
  {
    label: '收款方账户',
    width: '140px',
    prop: 'trade_in_account',
    required: true
  },
  {
    label: '平台采购PO',
    width: '120px',
    prop: 'palt_po',
    required: true
  },
  {
    label: '客户PO',
    width: '140px',
    prop: 'poCode',
    required: true
  },
  {
    label: '平台物料名称',
    width: '140px',
    prop: 'goodName',
    required: true
  },
  {
    label: '单位',
    width: '80px',
    prop: 'unit',
    required: true
  },
  {
    label: '产品数量',
    width: '120px',
    prop: 'goodNum',
    required: true
  },
  {
    label: '业务公司收入单价',
    width: '160px',
    prop: 'comPrice',
    required: true
  },
  {
    label: '业务公司收入总价',
    width: '160px',
    prop: 'com_total',
    required: true
  },

  {
    label: '税率(%)',
    width: '120px',
    prop: 'tax',
    required: true
  },
  {
    label: '税收编码',
    width: '120px',
    prop: 'cat_code',
    required: true
  },
  {
    label: '税收编码名称',
    width: '120px',
    prop: 'cat_name',
    required: true
  },
  {
    label: '客户DN',
    width: '120px',
    prop: 'NdCode',
    required: true
  },
  {
    label: '客户机构名称',
    width: '140px',
    prop: 'customerName',
    required: true
  },
  {
    label: '客户付款银行户名',
    width: '160px',
    prop: 'trade_out',
    required: true
  },

  {
    label: '平台公司收入单价',
    width: '140px',
    prop: 'platPrice',
    required: true
  },
  {
    label: '平台公司收入总价',
    width: '140px',
    prop: 'plat_total',
    required: true
  },
  {
    label: '交易时间',
    width: '120px',
    prop: 'tradeTime',
    required: true
  },
  {
    label: '泰e购SKU',
    width: '120px',
    prop: 'skuCode',
    required: true
  },

  {
    label: '商品唯一编号(采销365商品编号)',
    width: '200px',
    prop: 'goodNo',
    // required: true
  },
  {
    label: '客户付款银行账号',
    width: '160px',
    prop: 'trade_account',
    required: true
  },
  {
    label: '客户付款行名',
    width: '160px',
    prop: 'trade_bank',
    required: true
  },
  {
    label: '交易用途',
    width: '120px',
    prop: 'trade_used',
    required: true
  }
  // {
  //   label: '创建人',
  //   width: '100px',
  //   prop: 'TODO20',
  // },
  // {
  //   label: '创建时间',
  //   width: '100px',
  //   prop: 'TODO21',
  // }
]

const columns = () => {
  const list: any[] = [
    {
      type: "index",
      width: "50",
      fixed: "left",
      label: "序号"
    },
    ...initialColumns
  ];
  return list;
};

export const getPropertyAsLabel = (label: string) =>  initialColumns.find((column) => column.label === label.replace('*', ''))?.prop

export { initheaders  ,columns };
