import { ElTag } from "element-plus"
import { cg_order_type_options, useTypeOptions, xs_inv_type_list } from "/@/utils/status"
import { h } from "vue"
import { managerStatusOptions, sourceOptions, statusOptions, typeOptions } from "./shared"
import { createTooltip } from "/@/utils/tootip"

export const goodColumns = [
  {
    span: 8,
    field: 'orderCode',
    label: '确认单编号'
  },
  {
    span: 8,
    field: 'cxCode',
    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 orderGoodColumns = [
  {
    span: 6,
    field: 'orderCode',
    label: '确认单编号'
  },
  {
    span: 6,
    field: 'cxCode',
    label: '销售主单号'
  },
  {
    label: '类型',
    span: 6,
    render(_, row) {
      return h(ElTag, { type: 'primary', size: 'small' }, {
        default: () => typeOptions.find(item => item.value == row.type)?.label
      })
    }
  },
  {
    label: '数据来源',
    span: 6,
    render(_, row) {
      return h(ElTag, { type: 'primary', size: 'small' }, {
        default: () => sourceOptions.find(item => item.value == row.source)?.label
      })
    }
  },
  {
    span: 12,
    label: '销售方公司',
    render(_, row) {
      return createTooltip(row.seller_name, '销售方公司纳税号:' + row.seller_code)
    }
  },
  {
    span: 12,
    label: '购买方公司',
    render(_, row) {
      return createTooltip(row.buyer_name, '购买方公司编号:' + row.buyer_code)
    }
  },
  {
    span: 6,
    label: '业务类型',
    render(_, row) {
      return managerStatusOptions.find((item) => item.value == row.manager_status)?.label
    }
  },
  {
    span: 6,
    label: '平台类型',
    render(_, row) {
      return h(ElTag, { size: 'small' }, {
        default: () => useTypeOptions.find(item => item.value == row.platform_type)?.label || '--'
      })
    }
  },
  {
    label: '出库时间',
    span: 6,
    field: 'fz_date'
  },
  {
    span: 6,
    label: '平台订单号',
    field: 'poCode'
  },
  {
    label: '状态',
    span: 6,
    render(_, row) {
      return h(ElTag, { type: statusOptions.find(item => item.value == row.status)?.type, size: 'small' }, {
        default: () => statusOptions.find(item => item.value == row.status)?.label
      })
    }
  },

  {
    label: '异常原因',
    span: 18,
  }
]