const columns = [
  {
    type: "index",
    fixed: "left",
    label: "序号",
    width: "50"
  },
  {
    label: '类型',
    prop: 'type',
    minWidth: '100px',
    required: true,
    defaultData: [
      '出库',
      '出库红冲'
    ]
  },
  {
    label: '订单来源',
    prop: 'source',
    minWidth: '100px',
    required: true,
    defaultData: [
      '采销结算',
      '非采销结算'
    ]
  },
  {
    label: '订单购买方纳税号',
    prop: 'buyer_code',
    minWidth: '130px',
    required: true,
    defaultData: [
      '91110113MA008J790J',
      '91110113MA008J790J'
    ]
  },
  {
    label: '订单购买方公司名称',
    prop: 'buyer_name',
    minWidth: '150px',
    required: true,
    defaultData: [
      '北京百辰荣达国际科贸有限公司',
      '北京百辰荣达国际科贸有限公司'
    ]
  },
  {
    label: '订单销售方纳税号',
    prop: 'seller_code',
    minWidth: '160px',
    required: true,
    defaultData: [
      '91110118MACEA1R94G',
      '91110118MACEA1R94G'
    ]
  },
  {
    label: '订单销售方公司名称',
    prop: 'seller_name',
    minWidth: '160px',
    required: true,
    defaultData: [
      '北京锦兴弘昌科技有限公司',
      '北京锦兴弘昌科技有限公司'
    ]
  },
  {
    label: '订单编号',
    prop: 'orderCode',
    minWidth: '120px',
    required: true,
    defaultData: [
      'FQR2408091410078906',
      'FQR2408091408089205'
    ]
  },
  {
    label: '订单主单号',
    prop: 'cxCode',
    minWidth: '120px',
    defaultData: [
      'QR2408091409232833',
      'QR2408091407526489'
    ]
  },
  {
    label: '商品类型',
    prop: 'goodType',
    minWidth: '120px',
    required: true,
    defaultData: [
      '咨询商品',
      '库存商品'
    ]
  },
  {
    label: '商品编号',
    prop: 'goodNo',
    minWidth: '100px',
    required: true,
    defaultData: [
      'SKU2408091355123018',
      'SKU2408091354219149'
    ]
  },
  {
    label: '商品名称',
    prop: 'goodName',
    minWidth: '100px',
    required: true,
    defaultData: [
      '泰康专版金钥匙5g',
      '拉杆箱'
    ]
  },
  {
    label: '订单单位',
    prop: 'unit',
    minWidth: '80px',
    required: true,
    defaultData: [
      '个',
      '个',
    ]
  },
  {
    label: '商品数量',
    prop: 'num',
    minWidth: '110px',
    required: true,
    defaultData: [
      '2',
      '1'
    ]
  },
  {
    label: '商品单价',
    prop: 'goodPrice',
    minWidth: '110px',
    required: true,
    defaultData: [
      '725.2',
      '194.04'
    ]
  },
  {
    label: '订单总金额',
    prop: 'totalPrice',
    minWidth: '110px',
    required: true,
    defaultData: [
      '725.2',
      '194.04'
    ],
  },
  {
    label: '出库时间',
    prop: 'fz_date',
    minWidth: '80px',
    required: true,
    defaultData: [
      '2024-10',
      '2024-10'
    ],
  },
  {
    label: '关联商品ID',
    prop: 'relaGoodNo',
    minWidth: '110px',
    required: true,
    defaultData: [
      '5',
      '10'
    ]
  },
  {
    label: '操作数量',
    prop: 'relaGoodNum',
    minWidth: '100px',
    required: true,
    defaultData: [
      '2',
      '1'
    ]
  }
]

const notOrderTemplate = new Array(3).fill(1).map((_, index) => (columns.slice(1).reduce((prev, current) => {
  const isRequired = index === 0
  let defaultValue = ''

  if (isRequired) {
    defaultValue = current.required ? '必填' : ''
  } else {
    defaultValue = current.defaultData[index - 1]
  }

  return { ...prev, [current.label]: defaultValue }
}, {})))

export const mapLabelToProp = columns.reduce((prev, current) => ({
  ...prev,
  [current.label]: current.prop
}), {})


export const mapPropertyToLabel = columns.reduce((prev, current) => ({
  ...prev,
  [current.prop]: current.label
}), {})

export const requiredProps = columns.filter(column => !!column.required).map(item => item.prop)

export { columns, notOrderTemplate };
