const columns = [
  {
    label: '商品ID',
    prop: 'product_id',
    minWidth: '100px',
    required: true,
    defaultData: [
      '10',
      '12'
    ]
  },
  {
    label: '购买方公司纳税号',
    prop: 'buyer_code',
    minWidth: '100px',
    required: true,
    defaultData: [
      '91110118MACEA1R94G',
      '91110118MACEA1R94G'
    ]
  },
  {
    label: '购买方公司名称',
    prop: 'buyer_name',
    minWidth: '100px',
    required: true,
    defaultData: [
      '北京锦兴弘昌科技有限公司',
      '北京锦兴弘昌科技有限公司'
    ]
  },
  {
    label: '盘点类型',
    prop: 'check_type',
    minWidth: '100px',
    required: true,
    defaultData: [
      '调整单',
      '前期数据导入'
    ]
  },
  {
    label: '盘点数量',
    prop: 'check_num',
    minWidth: '100px',
    required: true,
    defaultData: [
      '100',
      '120'
    ]
  },
  {
    label: '库存数量',
    prop: 'balance_num',
    minWidth: '100px',
    required: true,
    defaultData: [
      '110',
      '120'
    ]
  },
  {
    label: '调整单入账月份',
    prop: 'fz_date',
    minWidth: '160px',
    required: true,
    defaultData: [
      '2024-11',
      '2024-11'
    ]
  }
]

const orderTemplate = new Array(3).fill(1).map((_, index) => (columns.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, orderTemplate };
