const columns = [
  {
    type: "index",
    fixed: "left",
    label: "序号",
    width: "50"
  },
  {
    label: '确认单编号',
    prop: 'orderCode',
    minWidth: '100px',
    required: true,
    defaultData: ''
  },
  {
    label: '销售主单号',
    prop: 'cxCode',
    minWidth: '100px',
    required: true,
    defaultData: ''
  },
  {
    label:'业务类型',
    prop: 'type',
    minWidth: '100px',
    required: true,
    defaultData: ''
  },
  {
    label: '平台订单号',
    prop: 'poCode',
    minWidth: '120px',
    required: true,
    defaultData: ''
  },
  {
    label: '卖出方公司编码',
    prop: 'seller_code',
    minWidth: '120px',
    required: true,
    defaultData: ''
  },
  {
    label: '卖出方公司名称',
    prop: 'seller_name',
    minWidth: '120px',
    required: true,
    defaultData: ''
  },
  {
    label: '客户公司编号',
    prop: 'buyer_code',
    minWidth: '120px',
    required: true,
    defaultData: ''
  },
  {
    label: '客户公司名称',
    prop: 'buyer_name',
    minWidth: '100px',
    required: true,
    defaultData: ''
  },
  {
    label: '商品编号',
    prop: 'goodNo',
    minWidth: '100px',
    required: true,
    defaultData: ''
  },
  {
    label: '商品名称',
    prop: 'goodName',
    minWidth: '100px',
    required: true,
    defaultData: ''
  },
  {
    label: '下单数量',
    prop: 'num',
    minWidth: '110px',
    required: true,
    defaultData: ''
  },
  {
    label:'销售单价',
    prop: 'goodPrice',
    minWidth: '110px',
    required: true,
    defaultData: ''
  },
  {
    label: '销售合计',
    prop: 'totalPrice',
    minWidth: '110px',
    required: true,
    defaultData: ''
  },
  {
    label: '出库月份',
    prop: 'fz_date',
    minWidth: '80px',
    required: true,
    defaultData: ''
  }
]

const orderTemplate = [columns.slice(1).reduce((prev, current) => {
  return { ...prev, [current.label]: current.defaultData ? current.defaultData : '' }
}, {})]


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 };
