import { ContentConfig } from "/@/components/PageContent";
import {
  httpList,
  httpAdd,
  httpUpdate,
  httpStatus,
  httpDelete
} from "/@/api/operate/setComGood";
import { GOOD_OPTIONS, STATUS_OPTIONS } from "/@/config/status";
import { renderImage, renderStatus } from "/@/utils/column-helper";

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },

  {
    prop: "id",
    label: "ID"
  },
  {
    label: "商品编号",
    prop: "good_code",
    width: 180,
    showOverflowTooltip: true
  },
  {
    prop: "status",
    label: "状态",
    ...renderStatus(STATUS_OPTIONS)
  },
  {
    prop: "company_title",
    label: "公司名称"
  },
  {
    prop: "card_title",
    label: "卡类型"
  },

  {
    label: "商品类型",
    prop: "type",
    width: 95,
    showOverflowTooltip: true,
    ...renderStatus(GOOD_OPTIONS, "type")
  },
  {
    label: "图片",
    prop: "good_cover_img",
    width: 60,
    showOverflowTooltip: true,
    ...renderImage("good_cover_img")
  },
  {
    label: "商品名称",
    prop: "good_name",
    minWidth: 160
  },
  {
    label: "单位",
    prop: "unit",
    width: 80,
    showOverflowTooltip: true
  },
  {
    label: "起订量",
    prop: "moq",
    width: 80,
    showOverflowTooltip: true
  },
  {
    label: "步长",
    prop: "step",
    width: 80,
    showOverflowTooltip: true
  },
  {
    label: "售价",
    prop: "price",
    width: 110,
    showOverflowTooltip: true
  },

  {
    prop: "addtime",
    label: "创建时间",
    width: 155
    // sortable: true
  },

  {
    label: "操作",
    fixed: "right",
    width: 160,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "商品管理",
  columns,
  apis: {
    httpAdd,
    httpList,
    httpStatus,
    httpDelete
  }
};

export default contentConfig;
