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

import { ElImage, ElTag } from "element-plus";
import { h } from "vue";
import { createTooltip } from "/@/utils/tootip";
import { DescriptionColumns } from "/@/components/BasicDescriptions";
import { ticketReturnReliveStatusOptions } from "/@/utils/status";

export const ticketReturnReliveColumns: DescriptionColumns = [
  {
    field: "returnCode",
    label: "退票编码"
  },
  {
    field: "apply_name",
    label: "申请人名称"
  },
  {
    field: "supplierName",
    label: "卖方公司名称",
    render(supplierName, { supplierNo }) {
      return createTooltip(supplierName, "卖方公司编码 : " + supplierNo, 360);
    }
  },
  {
    field: "companyName",
    label: "买方公司名称",
    render(companyName, { companyNo }) {
      return createTooltip(companyName, "买方公司编码 : " + companyNo, 360);
    }
  },
  {
    field: "status",
    label: "状态",
    render(data) {
      return h(ElTag, null, {
        default: () =>
          ticketReturnReliveStatusOptions.find(
            s => String(s.value) === String(data)
          )?.label
      });
    }
  },
  {
    field: "inv_fee",
    label: "发票金额"
  },
  {
    field: "total_fee",
    label: "对账申请总额"
  },
  {
    field: "returnImg",
    label: "回执图片",
    render(return_img) {
      const chunks = return_img?.split(",");
      if (!chunks) return null;

      return chunks.map(src => {
        return h(ElImage, {
          src,
          previewSrcList: [src],
          style: {
            height: "20px"
          }
        });
      });
    }
  },
  {
    field: "reason",
    label: "退票原因"
  },
  {
    field: "remark",
    label: "备注"
  }
];


export const sendTicketReturnReliveColumns: DescriptionColumns = [
  {
    field: "returnCode",
    label: "退票编码"
  },
  {
    field: "apply_name",
    label: "申请人名称"
  },
  {
    field: "supplierName",
    label: "物流供应商",
    render(supplierName, { supplierNo }) {
      return createTooltip(supplierName, "物流供应商编码 : " + supplierNo, 360);
    }
  },
  {
    field: "companyName",
    label: "业务公司",
    render(companyName, { companyNo }) {
      return createTooltip(companyName, "业务公司编码 : " + companyNo, 360);
    }
  },
  {
    field: "status",
    label: "状态",
    render(data) {
      return h(ElTag, null, {
        default: () =>
          ticketReturnReliveStatusOptions.find(
            s => String(s.value) === String(data)
          )?.label
      });
    }
  },
  {
    field: "inv_fee",
    label: "发票金额"
  },
  {
    field: "total_fee",
    label: "对账申请总额"
  },
  {
    field: "returnImg",
    label: "回执图片",
    render(return_img) {
      const chunks = return_img?.split(",");
      if (!chunks) return null;

      return chunks.map(src => {
        return h(ElImage, {
          src,
          previewSrcList: [src],
          style: {
            height: "20px"
          }
        });
      });
    }
  },
  {
    field: "reason",
    label: "退票原因"
  },
  {
    field: "remark",
    label: "备注"
  }
];
