import { cg_order_type_options } from "/@/utils/status";
import { ElTable, ElTableColumn, ElTag  } from "element-plus";
import { h } from "vue";

export const goodColumns = [
  {
    span: 12,
    field: 'seller_name',
    label: '销售方公司'
  },
  {
    span: 12,
    field: 'buyer_name',
    label: '购买方公司'
  },
  {
    span: 12,
    field: 'goodName',
    label: '订单商品名称'
  },
  {
    span: 12,
    field: 'inv_good_name',
    label: '发票商品名称'
  },
  {
    span: 6,
    label: '商品类型',
    render(_, { good_type }){
      return h(ElTag, { size: 'small' }, {
        default: () => cg_order_type_options.find(item => item.value == good_type)?.label || '--'
      })
    }
  },
  {
    span: 6,
    field: 'good_code',
    label: '商品代码'
  },
  {
    span: 6,
    field: 'spec',
    label: '规格'
  },
  {
    span: 6,
    field: 'unit',
    label: '单位'
  },
  {
    span: 6,
    field: 'unit_price',
    label: '税前单价'
  },
  {
    span: 6,
    field: 'subunit_price',
    label: '税后单价'
  },
  {
    span: 6,
    field: 'unit_weight',
    label: '重量'
  },
  {
    span: 6,
    field: 'spectral',
    label: '分光'
  },
  {
    field: 'cat_name',
    label: '进项类目',
    span: 24
  }
]


export const goodHasChildColumns = [
  {
    span: 12,
    field: 'seller_name',
    label: '销售方公司'
  },
  {
    span: 12,
    field: 'buyer_name',
    label: '购买方公司'
  },
  {
    span: 12,
    field: 'goodName',
    label: '订单商品名称'
  },
  {
    span: 12,
    field: 'inv_good_name',
    label: '发票商品名称'
  },
  {
    span: 6,
    label: '商品类型',
    render(_, { good_type }) {
      return h(ElTag, { size: 'small' }, {
        default: () => cg_order_type_options.find(item => item.value == good_type)?.label || '--'
      })
    }
  },
  {
    span: 6,
    field: 'good_code',
    label: '商品代码'
  },
  {
    span: 6,
    field: 'spec',
    label: '规格'
  },
  {
    span: 6,
    field: 'unit',
    label: '单位'
  },
  {
    span: 6,
    field: 'unit_price',
    label: '税前单价'
  },
  {
    span: 6,
    field: 'subunit_price',
    label: '税后单价'
  },
  {
    span: 6,
    field: 'unit_weight',
    label: '重量'
  },
  {
    span: 6,
    field: 'spectral',
    label: '分光'
  },
  {
    field: 'cat_name',
    label: '进项类目',
    span: 24
  },
  {
    label: '子商品',
    span: 24,
    render(_, { ProductsCombind = [] }){
      return h(ElTable, { size: 'small', data: ProductsCombind, border: true }, {
        default: () => [
          h(ElTableColumn, { label: '比例', prop: 'child_num', width: 100, showOverflowTooltip: true }),
          h(ElTableColumn, { label: '商品编号', showOverflowTooltip: true }, { default: (scope) => scope.row.products?.skuCode }),
          h(ElTableColumn, { label: '商品类型', showOverflowTooltip: true }, { default: (scope) =>
            h(ElTag, { size: 'small' }, { default: () => cg_order_type_options.find(item => item.value == scope.row.products?.good_type)?.label || '--'  })
          }),
          h(ElTableColumn, { label: '商品名称' }, { default: (scope) => scope.row.products?.goodName }),
        ]
      })
    }
  }
]