import { h } from "vue";
import { httpList } from "/@/api/postSupplierOrder/sendOrder";
import { hasAccountOptions, xs_order_source_options, xs_order_type_options } from "/@/utils/status";
import { ContentConfig } from "/@/components/PageContent";
import { renderProp } from "/@/utils/columnRenderHelper";
import { orderOptions } from "./options";
import { ElTag } from "element-plus";


const columns = [
  {
    prop: "TrackCode",
    label: "发货运单编号",
    width: '150px'
  },
  {
    prop: "outChildCode",
    label: "发货工单编号",
    width: '150px'
  },
  {
    width: '150px',
    label: "发货单编号",
    cellRenderer({ row: _ }) { 
       return _.fhdChild.outChildCode
    }
  },
  {
    prop: "orderCode",
    label: "销售订单编号",
    width: '150px'
  },
  {
    prop: "cgdNo",
    width: '150px',
    label: "采购单编号"
  },
  {
    prop: "status",
    width: '90px',
    label: "状态",
    cellRenderer({ row }) {
      return h(ElTag, {
        type: orderOptions.find(({ value }) => Number(value) === Number(row.status))?.type || 'info',
        size: 'small'
      }, {
        default: () => orderOptions.find(({ value }) => Number(value) === Number(row.status))?.label || '--'
      })
    }
  },
  {
    'min-width': '80px',
    label: "供应商端",
    ...renderProp(hasAccountOptions, "has_account")
  },
  {
    width: '80px',
    label: "订单来源",
    cellRenderer({ row }) {
      return xs_order_source_options.find(({ value }) => value === row.fhdChild.order_source)?.label || '--'
    }
  },
  {
    width: '80px',
    label: "商品类型",
    cellRenderer({ row }) {
      return xs_order_type_options.find(({ value }) => value === row.fhdChild.order_type)?.label || '--'
    }
  },
  {
    width: '120px',
    label: "商品名称",
    cellRenderer({ row }) {
      return row.fhdChild.good_name
    }
  },
  {
    width: '120px',
    label: "物流供应商",
    cellRenderer({ row }) {
      return row.fhdChild.supplierName
    }
  },
  {
    width: '120px',
    label: "业务公司",
    cellRenderer({ row }) {
      return row.fhdChild.companyName
    }
  },
  {
    width:'90px',
    label: '商品数量',
    cellRenderer({ row }){
      return row.fhdChild ? row.fhdChild.num : '--'
    }
  },
  {
    width: '100px',
    label: "物流费用",
    prop: 'post_fee'
  },
  {
    prop: "remark",
    width: '120px',
    label: "备注"
  },
  {
    prop: "apply_name",
    label: "创建人",
    width: '80px'
  },
  {
    prop: "create_time",
    width: '120px',
    label: "创建时间"
  },
  {
    label: "操作",
    fixed: "right",
    slot: "operation",
    width: 45
  }
];

const contentConfig: ContentConfig = {
  columns,
  companyProp: 'supplierNo',
  apis: {
    httpList,
  }
};

export default contentConfig;
