import { ContentConfig } from "/@/components/PageContent";
import { httpProducts } from "/@/api/sellOut/salesOrder";
import { h } from "vue";
import { ElImage } from "element-plus";
import { is } from "@pureadmin/utils";

const columns = [
  { type: 'selection', fixed: 'left', _noset_: true },
  {
    prop: 'skuCode',
    label: '商品编码',
    width: '160'
  },
  {
    prop: 'good_thumb_img',
    label: '图片',
    'width': '50',
    cellRenderer({ row }){
      if(!row.good_thumb_img) return null
      return h(ElImage, { 
        style: { height: '25px', width: '25px'},
        previewSrcList: [ row.good_thumb_img],
        previewTeleported: true,
        src: row.good_thumb_img
      } , null)

    }
  },
  {
    prop: 'good_name',
    label: '商品名称',
    'min-width': '120'
  },
  {
    prop: 'plat_code',
    label: '平台商品编号',
    'width': '160'
  },
  {
    prop: 'cat_name',
    label: '商品分类',
    width: '120',
    cellRenderer({ row }){
      return row.cat_info.map(({ name }) => name).join('_')
    }
  },

  {
    prop: 'unit',
    label: '单位',
    width: '45'
  },
  {
    prop: 'model',
    label: '规格',
    // _slot_: 'model',
    width: '110',
    cellRenderer({ row }){
      console.log(row.specinfo)
      return (row.specinfo || []).map((item, index) => {
        return `${index !== 0 ? '--' : ''}${item.spec_name}[${item.spec_value}]`
      })
    }
  },

  {
    prop: 'brand_name',
    label: '品牌',
    'width': '100'
  },
  {
    prop: 'is_stock',
    label: '库存类型',
    // _slot_: 'is_stock',
    'width': '100',
    cellRenderer({ row }){
      return row.is_stock == '1' ? '库存品' : '非库存品'
    }
  },

  {
    prop: 'platform_name',
    label: '所属平台',
    'width': '100'
  },

  {
    prop: 'company',
    label: '业务公司',
    'min-width': '150'
  },
  {
    prop: 'purchase',
    label: '供应商负责人',
    fixed: 'right',
    width: '95'
  }
];

const contentConfig: ContentConfig = {
  title: "销售订单管理",
  columns,
  apis: {
    httpList: httpProducts,
  }
};

export default contentConfig;
