import { ElButton, ElImage, ElTag } from "element-plus"
import { h } from "vue"

export const statusOptions = [
  { value: '1', label: '待采购反馈' },
  { value: '2', label: '已生成采购单' },
  { value: '3', label: '备货申请已取消' }
]

const isMultiplePlaceOptions = [
  { value : '0', label: '一地' },
  { value : '1', label: '多地' }
]

const isCustomizedOptions = [
  { value : '0', label: '否' },
  { value : '1', label: '是' }
] 

export const beExpectedToPassOptions = [
  { value: '0', label: '全部无法通过' },
  { value: '1', label: '业务主管通过' },
  { value: '2', label: '财务主管通过' },
  { value: '3', label: 'boss通过' }
]

export const bargainColumns = [
  {
    field: 'bk_code',
    label: '申请编码',
    span: 6
  },

  {
    field: 'status',
    label: '状态',
    // _slot_: 'status',
    span: 6,
    render(status){
      return h(ElTag, null, {
        default: () => statusOptions.find(({ value })  => value == status)?.label || '--'
      })
    }
  },
  {
    field: 'apply_name',
    label: '申请人',
    span: 6
  },
  {
    field: 'addtime',
    label: '创建时间',
    span: 6
  },
  {
    field: 'wsm_name',
    label: '仓库名称',
    _slot_: 'wsm',
    span: 12
  },
  {
    field: 'wsm_name',
    label: '仓库所在供应商',
    _slot_: 'wsm_supplier',
    span: 12
  },
  {
    field: 'good_num',
    label: '采购数量',
    span: 6
  },
  {
    field: 'lasttime',
    label: '最晚入库时间',
    span: 6
  },
  {
    field: 'file_url',
    label: '附件',
    // _slot_: 'file_url',
    span: 12,
    render(_,{ file_name, file_url }){
      return h(ElButton, { type: 'primary', link: true  }, {
        default: () => file_name
      })
    }
  },

  {
    field: 'remark',
    label: '备注',
    span: 24
  }
]

const paymentWayOptions = [
  { value: '0', label: '现结' },
  { value: '1', label: '月清' },
  { value: '2', label: '双月清' }
]


export const productColumns = [
  {
    field: 'good_name',
    label: '商品名称',
    _slot_: 'good_name',
    span: 18
  },
  {
    field:'is_combind',
    label:'组合类型',
    // _slot_:"is_combind",
    span: 6,
    render(is_combind){
      return is_combind === '1' ? '组合商品' : '非组合商品'
    }
  },
  {
    field: 'cat_info',
    label: '分类',
    span: 8,
    render(cat_info){
      return cat_info ? cat_info.map(({name}) => name).join('-') : ''
    }
  },
  {
    field: 'creater',
    label: '商品创建人',
    span: 4
  },
  {
    field: 'brand_name',
    label: '品牌',
    span: 6
  },
  {
    field: 'send_way',
    label: '发货方式',
    span: 6,
    render(send_way){
      return send_way === '1' ? '供应商包邮' : '公司自提'
    }
  },
  {
    field: 'unit',
    label: '单位',
    span: 4
  },
  {
    field: 'tax',
    label: '税点',
    append: '%',
    span: 4
  },
  {
    field: 'pay_way',
    label: '支付方式',
    span: 4,
    render(pay_way){
      return paymentWayOptions.find(({value}) => value == pay_way)?.label || '--'
    }
  },

  {
    field: 'weight',
    label: '商品总克重',
    append: 'g',
    span: 6
  },

  {
    field: 'addtime',
    label: '反馈时间',
    span: 6
  },
  {
    field: 'good_img',
    label: '商品图片',
    span: 8,
    render(good_img){
      return h(ElImage, { src: good_img, previewSrcList: [good_img], style: {  height: '20px', width: '20px' } })
    }
  },
  {
    field: 'supply_area',
    label: '供货区域',
    span: 4,
    render(supply_area){
      return supply_area === '1' ? '全国' : '全国出偏远'
    }
  },

  {
    field: 'noble',
    label: '贵金属信息',
    span: 12,
    render(_,context){
      if(!context.noble_metal) { return null }
      return `${context.noble_weight ? context.noble_weight : '0'}g-${context.noble_name}-${context.gold_price ? context.gold_price : '0'}元/g
      -${context.is_gold_price + '' === '0' ? '不' : ''}启用实时金价-${context.is_diff + '' === '1' ? '有' : '无'}工差-${context.config}-${context.other_config}`
    }
  },

  {
    field: 'cost_desc',
    label: '工艺说明',
    span: 24
  },
  {
    field: 'remark',
    label: '采返备注',
    span: 24
  }
]

export const costColumns = [
  {
    field: 'cert_fee',
    label: '成本证书费',
    append: '元',
    span: 6
  },
  {
    field: 'pakge_fee',
    label: '成本包装费',
    append: '元',
    span: 6
  },
  {
    field: 'cost_fee',
    label: '成本工艺费',
    append: '元',
    span: 6
  },
  {
    field: 'mark_fee',
    label: '成本加标费',
    append: '元',
    span: 6
  },

  {
    field: 'demo_fee',
    label: '成本打样费',
    append: '元',
    span: 6
  },
  {
    field: 'open_fee',
    label: '成本开模费',
    append: '元',
    span: 6
  },
  {
    field: 'delivery_fee',
    label: '成本物流费',
    append: '元',
    span: 6
  },
  {
    field: 'nake_fee',
    label: '成本裸价',
    append: '元',
    span: 6
  },
  {
    field: 'total_fee',
    label: '采购成本合计',
    append: '元',
    span: 24
  }
]


export const bargainingColumns = [
  {
    field: 'before_rate',
    label: '议价前毛利率',
    append: '%',
    span: 12
  },

  {
    field: 'after_rate',
    label: '议价后毛利率',
    append: '%',
    span: 12
  }
]
