/**
 * 采购回票详情
 */

import { ElTag } from "element-plus";
import { h } from "vue";
import { createTooltip } from "../../tootip";
import { DescriptionColumns } from "/@/components/BasicDescriptions";

import {
  invoiceTypeList,
  seller_check_type,
  buyer_check_type,
  ticketReturnStatusOptions
} from "/@/utils/status";

export const ticketReturnColumns: DescriptionColumns = [
  {
    field: "hpNo",
    label: "对账回票编码"
  },
  {
    field: "status",
    label: "状态",
    render(data) {
      return h(ElTag, null, {
        default: () =>
          ticketReturnStatusOptions.find(s => s.value === String(data))?.label
      });
    }
  },
  {
    field: "apply_name",
    label: "申请人"
  },
  {
    field: "addtime",
    label: "创建时间"
  },
  {
    field: "supplierName",
    span: 12,
    label: "卖方公司名称",
    render(supplierName, { supplierNo }) {
      return createTooltip(supplierName, "卖方公司编码 : " + supplierNo, 360);
    }
  },
  {
    field: "companyName",
    label: "买方公司名称",
    span: 12,
    render(companyName, { companyNo }) {
      return createTooltip(companyName, "买方公司编码 : " + companyNo, 360);
    }
  },
  {
    field: "inv_fee",
    label: "回票金额"
  },
  {
    field: "invoiceType",
    label: "发票类型",
    render(data) {
      return h(ElTag, null, {
        default: () =>
          invoiceTypeList.find(s => s.value === String(data))?.label || "--"
      });
    }
  },

  {
    field: "open_time",
    label: "发票日期"
  },
  {
    field: "invoiceNumber",
    label: "发票号码"
  },

  {
    label: "购买方抬头状态",
    field: "seller_check",
    render(data) {
      return h(
        ElTag,
        {
          type: seller_check_type.find(s => s.value === String(data))
            ?.type as any
        },
        {
          default: () =>
            seller_check_type.find(s => s.value === String(data))?.label || "--"
        }
      );
    }
  },
  {
    field: "inv_subtotal_amount",
    label: "税前总金额"
  },
  {
    field: "invoiceCode",
    label: "发票代码",
    span: 12
  },
  {
    label: "销售方抬头状态",
    field: "buyer_check",
    render(data) {
      return h(
        ElTag,
        {
          type: buyer_check_type.find(s => s.value === String(data))
            ?.type as any
        },
        {
          default: () =>
            buyer_check_type.find(s => s.value === String(data))?.label || "--"
        }
      );
    }
  },
  {
    field: "inv_amount",
    label: "税后总金额"
  },
  {
    field: "checkNumber",
    span: 12,
    label: "校验码"
  },
  {
    field: "remark",
    span: 24,
    label: "审核备注"
  }
];
