import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/invoiceInOut/productManager";

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

const columns = [
  {
    width: 40,
    type: 'selection'
  },
  {
    label: "商品编码",
    prop: "skuCode",
    width: 150
  },
  {
    label: "销售方公司",
    prop: "seller_name",
    width: 160
  },
  {
    label: "购买方公司",
    prop: "buyer_name",
    width: 160
  },
  {
    label: '商品类型',
    width: 100,
    cellRenderer({ row }){
      return h(ElTag, { size: 'small' }, {
        default: () => cg_order_type_options.find(item => item.value == row.good_type)?.label || '--'
      })
    }
  },
  {
    label: '商品名称',
    prop: 'goodName',
    width: 150
  },
  {
    label: "规格",
    prop: "spec",
    width: 80
  },
  {
    label: "单位",
    prop: "unit",
    width: 80
  },
  {
    label: "状态",
    prop: "status",
    width: 80,
    cellRenderer({ row }){
      return h(ElTag, { size: 'small', type: statusList.find(item => item.value == row.status)?.type || 'warning' }, {
        default: () => statusList.find(item => item.value == row.status)?.label || '--'
      })
    }
  },
  {
    label: '税前单价',
    prop: 'subunit_price',
    width: 100
  },
  {
    label: '税后单价',
    prop: 'unit_price',
    width: 100
  },
  {
    label: '重量',
    prop: 'unit_weight',
    width: 80
  },
  {
    label: '分光',
    prop: 'spectral',
    width: 80
  },
  {
    label: '创建人',
    prop: 'apply_name',
    width: 80
  },
  {
    label:'创建时间',
    prop: 'create_time',
    width: 140
  }
];

const contentConfig: ContentConfig = {
  columns,
  apis: { httpList: (parameter = {}) => httpList({ ...parameter, is_combind: '0' }) }
};

export default contentConfig;
