import { statusOptions, biddingTypeOptions } from "./_options";
import { httpList, httpStatus } from "/@/api/sellOut/zixunOrder";
import { ContentConfig } from "/@/components/PageContent";
import { ElImage, ElTag } from "element-plus";
import { h } from "vue";

const columns = [
  {
    prop: 'infoNo',
    label: '竞价编号',
    width: '160'
  },
  {
    prop: 'bargain_num',
    label: '竞价次数',
    width: '70'
  },

  {
    prop: 'good_img',
    label: '图片',
    width: '50',
    cellRenderer({row}){
      if(!row.good_img) return null
      return h(ElImage, { previewSrcList: [row.good_img], src: row.good_img, previewTeleported: true , style: { width: '20px', height: '20px' } })
    }
  },
  {
    prop: 'good_name',
    label: '商品名称',
    'min-width': '120'
  },

  {
    prop: 'status',
    label: '状态',
    width: '120px',
    cellRenderer({ row }){
      return h(ElTag, null, {
        default: () => statusOptions.find((item) => Number(item.value) === Number(row.status))?.label || '--' 
      })
    }
  },
  {
    prop: 'is_project',
    label: '竞价单类型',
    width: '110px',
    cellRenderer({ row }){
      return h(ElTag, null, {
        default: () => biddingTypeOptions.find((item) => Number(item.value) === Number(row.is_project))?.label || '--' 
      })
    }
  },

  {
    prop: 'khNo',
    label: '客户编号',
    width: '160'
  },
  {
    prop: 'khname',
    label: '客户名称',
    'min-width': '135'
  },
  {
    prop: 'companyNo',
    label: '业务公司编号',
    width: '160'
  },
  {
    prop: 'companyName',
    label: '业务公司名称',
    'min-width': '135'
  },

  {
    prop: 'budget_price',
    label: '预算单价',
    width: 110
  },
  {
    prop: 'num',
    label: '竞价数量',
    width: 110
  },
  {
    prop: 'company_name',
    label: '申请人部门',
    minWidth: '150px'
  },
  {
    prop: 'creater',
    label: '申请人',
    width: '60'
  },

  {
    prop: 'addtime',
    label: '添加时间',
    width: 142
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    width: "80px",
    slot: "operation",
  }
];

const contentConfig: ContentConfig = {
  title: "竞价单管理",
  columns,
  apis: {
    httpList,
    httpAdd: true
  }
};

export default contentConfig;
