import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/InvoiceSales/sheetOrderPool";

import { h } from "vue";
import { ElTag } from "element-plus";
import {
  cat_status,
  good_source,
  good_type,
  inv_open_status,
  retrun_status
} from "./search.config";
import { send_status_list } from "/@/utils/status";

const USE_STATUS = [
  {
    value: "0",
    label: "未对账"
  },
  {
    value: "1",
    label: "参与对账"
  },
  {
    value: "2",
    label: "参与核销对账"
  }
];

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "确认单编号",
    prop: "sequenceNo",
    width: 150
  },
  {
    label: "确认单名称",
    prop: "name",
    width: 150
  },
  {
    label: "客户编号",
    prop: "customerNo",
    width: 100
  },
  {
    label: "客户名称",
    prop: "customerName",
    width: 100
  },
  {
    label: "部门",
    prop: "department",
    width: 100
  },
  {
    label: "平台名称",
    prop: "platName",
    width: 100
  },
  {
    label: "使用状态",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElTag, null, {
        default: () =>
          USE_STATUS.find(s => s.value === row.status)?.label || "--"
      })
  },
  {
    label: "商品类型",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElTag, null, {
        default: () =>
          good_type.find(s => s.value === row.qrdType)?.label || "--"
      })
  },
  {
    label: "发货状态",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElTag, null, {
        default: () =>
          send_status_list.find(s => s.value === row.sendStatus)?.label || "--"
      })
  },
  {
    label: "订单来源",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElTag, null, {
        default: () =>
          good_source.find(s => s.value === row.qrdSource)?.label || "--"
      })
  },
  {
    label: "类目设置",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElTag, null, {
        default: () =>
          cat_status.find(s => s.value === row.cat_status)?.label || "--"
      })
  },
  {
    label: "开票状态",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElTag, null, {
        default: () =>
          inv_open_status.find(s => s.value === row.inv_status)?.label || "--"
      })
  },
  {
    label: "已开票",
    prop: "ainv_fee"
  },
  {
    label: "开票中",
    prop: "inv_fee"
  },
  {
    label: "开票标签金额",
    prop: "inv_tag_fee",
    width: 120
  },
  {
    label: "未开票",
    prop: "winv_fee",
    width: 100
  },
  {
    label: "付款状态",
    width: 110,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () =>
          retrun_status.find(s => s.value === row.pay_status)?.label
      });
    }
  },
  {
    label: "已付款",
    prop: "apay_fee",
    width: 100
  },
  {
    label: "付款中",
    prop: "pay_fee"
  },
  {
    label: "回款标签金额",
    prop: "pay_tag_fee",
    width: 120
  },
  {
    label: "未付款",
    prop: "wpay_fee"
  },
  {
    label: "发货数量",
    prop: "sendNum",
    width: 100
  },
  {
    label: "未发数量",
    prop: "wsendNum"
  },
  {
    label: "销售员",
    prop: "ownerName"
  },
  {
    label: "操作",
    fixed: "right",
    width: 120,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "确认单公海池",
  powers: ["001", "002", "003", "004", "005", "006", "007", "008"],
  columns,
  payProps: {
    prop: "sequenceNo",
    type: "3"
  },
  returnProps: {
    prop: "sequenceNo",
    type: "4"
  },
  apis: {
    httpList
  }
};

export default contentConfig;
