import { ContentConfig } from "/@/components/PageContent";
import { httpProofs } from "/@/api/sellOut/salesOrder";
import { ElImage, ElTag } from "element-plus";
import { h } from "vue";

const options = [
  { value: '1', label: '视频' },
  { value: '2', label: '图片' },
  { value: '3', label: '其他' }
]

const columns = [
  { type: 'selection', fixed: 'left', _noset_: true },
  {
    prop: 'spuCode',
    label: '商品编码',
    width: '160px'
  },
  {
    label: '凭证类型',
    width: '80px',
    cellRenderer({ row }){
      return h(ElTag, { size: 'small' }, {
        default: () => options.find(item => item.value === row.proof_type)?.label || '--'
      })
    }
  },
  {
    label: '比价凭证',
    cellRenderer({ row }){
      if(row.proof_type == '2'){
        return h(ElImage, { 
          style: { height: '25px', width: '25px'},
          previewSrcList: [ row.proof_url],
          previewTeleported: true,
          src: row.proof_url
        } , null)
      }
    }
  },
  {
    prop: 'creater',
    label: '创建人',
    width: '120px'
  },
  {
    prop: 'addtime',
    label: '创建时间',
    width: '120px'
  }
];

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

export default contentConfig;
