import { h } from "vue";
import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/InvoiceSales/invoiceApply";
import { INV_OPEN_STATUS } from "/@/utils/details/inv-open";
import {
  invoiceTypeList,
  seller_check_type,
  buyer_check_type
} from "/@/utils/status";
import { ElTag } from "element-plus";

const columns = [
  {
    label: "发票申请编码",
    prop: "invNo",
    width: 150
  },
  {
    label: "业务企业编码",
    prop: "inv_out",
    width: 150
  },
  {
    label: "客户公司名称",
    prop: "buyer_title",
    width: 175
  },
  {
    label: "申请额度",
    prop: "inv_value",
    width: 110
  },
  {
    label: "状态",
    prop: "status",
    width: 125,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () => {
          return (
            INV_OPEN_STATUS.find(item => item.value == row.status + "")
              ?.label || "--"
          );
        }
      });
    }
  },
  {
    label: "发票类型",
    prop: "status",
    width: 160,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () =>
          invoiceTypeList.find(item => item.value == row.inv_type + "")
            ?.label || "--"
      });
    }
  },
  {
    label: "发票号码",
    prop: "inv_number",
    width: 130
  },
  {
    label: "发票代码",
    prop: "inv_code",
    width: 100
  },
  {
    label: "购买方抬头状态",
    prop: "seller_check",
    width: 135,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () =>
          seller_check_type.find(item => item.value == row.seller_check + "")
            ?.label || "--"
      });
    }
  },
  {
    label: "销售方抬头状态",
    prop: "buyer_check",
    width: 135,
    cellRenderer: ({ row }) => {
      return h(ElTag, null, {
        default: () =>
          buyer_check_type.find(item => item.value == row.buyer_check + "")
            ?.label || "--"
      });
    }
  },

  {
    label: "申请人",
    prop: "apply_name",
    width: 80
  },
  {
    label: "创建时间",
    width: 140,
    prop: "addtime"
  },
  {
    label: "操作",
    fixed: "right",
    width: 50,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "发票申请管理",
  columns,
  superUserNoAction: true,
  companyProp: "inv_out",
  notPreview: true,
  apis: {
    httpList,
    httpAdd: true
  }
};

export default contentConfig;
