/* eslint-disable prettier/prettier */
import { BeforeRequestType, ContentConfig } from "/@/components/PageContent";
import { isBeyondTime } from "/@/views/reportCollection/_utils";
import apis from "./apis";
import { h } from "vue";
import { ElTag } from "element-plus";

const platformTypeOptions = [
  { value: '1', label: 'ToB' },
  { value: '2', label: 'ToC' },
]

const statusOptions = [
  { value: "0", label: "待采购备货" },
  { value: "1", label: "待库管发货" },
  { value: "2", label: "已发货待收货" },
  { value: "3", label: "已收货" },
  { value: "4", label: "已全部退货" }
]

const columns = [
  {
    prop: 'outCode',
    label: '发货单编号',
    minWidth: '155px'
  },
  {
    prop: 'orderCode',
    label: '订单编号',
    minWidth: '155px'
  },
  {
    prop: 'cgdNo',
    label: '采购单编号',
    minWidth: '155px'
  },
  {
    prop: 'send_num',
    label: '发货数量'
  },
  {
    prop: 'platform_type',
    label: '平台类型',
    minWidth: '70px',
    cellRenderer({ row }) {
      return h('div', null, {
        default: () => platformTypeOptions.find(({ value }) => value === String(row.platform_type))?.label || '--'
      })
    }
  },
  {
    prop: 'status',
    label: '状态',
    minWidth: '90px',
    cellRenderer({ row }) {
      return h(ElTag, null, {
        default: () => statusOptions.find(({ value }) => value === String(row.status))?.label || '--'
      })
    }
  },
  {
    prop: 'order_source',
    label: '订单来源'
  },
  {
    prop: 'order_type',
    label: '商品类型',
    width: '100px'
  },
  {
    prop: 'supName',
    label: '供应商',
    minWidth: '190px'
  },
  {
    prop: 'cat_name',
    label: '商品分类',
    minWidth: '120px'
  },
  {
    prop: 'good_code',
    label: '商品编号',
    minWidth: '160px'
  },
  {
    prop: 'good_name',
    label: '商品名称',
    minWidth: '160px'
  },
  {
    prop: 'customer_code',
    label: '客户编码',
    minWidth: '160px'
  },
  {
    prop: 'customerName',
    label: '客户名称',
    minWidth: '160px'
  },
  {
    prop: 'supplierNo',
    label: '业务公司编码',
    minWidth: '160px'
  },
  {
    prop: 'supplierName',
    label: '业务公司名称',
    minWidth: '160px'
  },
  {
    prop: 'contactor',
    label: '联系人',
    minWidth: '90px'
  },
  {
    prop: 'mobile',
    label: '联系电话',
    minWidth: '110px'
  },
  // {
  //   prop: 'post_name',
  //   label: '物流公司',
  //   minWidth: '90px'
  // },
  // {
  //   prop: 'post_code',
  //   label: '物流单号',
  //   minWidth: '90px'
  // },
  // {
  //   prop: 'post_fee',
  //   label: '物流费用',
  //   minWidth: '90px'
  // },
  // {
  //   prop: 'send_time',
  //   label: '发货时间',
  //   minWidth: '90px'
  // },
  {
    prop: 'apply_name',
    label: '申请人',
    minWidth: '90px'
  },
  {
    prop: 'depart',
    label: '申请人部门',
    minWidth: '90px'
  },
  {
    prop: 'addtime',
    label: '添加时间',
    minWidth: '110px'
  },
  {
    prop: 'createdTime',
    label: '下单时间',
    minWidth: '110px'
  },
  {
    prop: 'report_sx',
    label: '时效',
    minWidth: '90px'
  },
  {
    prop: 'cgder',
    label: '供应商负责人',
    minWidth: '100px'
  }
]


const contentConfig: ContentConfig = {
  columns,
  showTitle: false,
  responseCode: 1,
  superUserNoAction: false,
  // beforeRequestList(params) {
  //   const { start, end } = params;
  //   const beyondTime = isBeyondTime({ name: "竞价时间", len: 90, start, end });
  //   if (beyondTime) return BeforeRequestType.EMPTY
  //   return BeforeRequestType.NEXT;
  // },
  apis: { httpList: apis.list }
};


export default contentConfig;
