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

import dayjs from "dayjs";
import { h } from "vue";
import { ElTag } from "element-plus";
import { invoiceTypeList, useTypeOptions } from "/@/utils/status";

const columns = [
  // {
  //   type: "selection",
  //   width: 40,
  // align: "center",
  //   hide: ({ checkList }) => !checkList.includes("勾选列")
  // },
  // {
  //   label: "序号",
  //   type: "index",
  //   width: 70,
  //   hide: ({ checkList }) => !checkList.includes("序号列")
  // },
  {
    label: "发票申请编码",
    prop: "invNo",
    width: 150
  },
  {
    label: "业务企业编码",
    prop: "inv_out",
    width: 150
  },
  {
    label: "业务公司名称",
    prop: "inv_company",
    minWidth: 160
  },
  {
    prop: "buyer_title",
    label: "客户发票抬头",
    minWidth: 160
  },
  {
    label: "税后金额",
    prop: "inv_value",
    width: 110
  },
  {
    label: "平台类型",
    prop: "platform_type",
    width: 110,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () => {
          return (
            useTypeOptions.find(item => item.value == row.platform_type + "")
              ?.label || "--"
          );
        }
      });
    }
  },
  {
    label: "发票类型",
    width: 160,
    cellRenderer({ row }) {
      const current = invoiceTypeList.find(
        i => i.value === String(row.inv_type)
      );

      return h(ElTag, null, {
        default: () => current.label
      });
    }
  },
  {
    label: "申请人",
    prop: "apply_name",
    width: 80
  },
  {
    label: "申请时间",
    width: 170,
    prop: "addtime",
    formatter: ({ addtime }) =>
      addtime ? dayjs(addtime).format("YYYY-MM-DD HH:mm:ss") : ""
  },
  {
    label: "操作",
    fixed: "right",
    width: 55,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "发票公海池",
  inv: true,
  columns,
  apis: {
    httpList
  }
};

export default contentConfig;