/**
 * 付款解除详情
 */

import { h } from "vue";
import { ElImage, ElTag } from "element-plus";
import { DescriptionColumns } from "/@/components/BasicDescriptions";

import {
  purchPayReliveStatusOptions,
  purchPayStatusOptions
} from "/@/utils/status";

export const purchpayReliveColumns: DescriptionColumns = [
  {
    field: "returnCode",
    label: "付款解除编码"
  },
  {
    field: "status",
    label: "状态",

    render(status) {
      return h(ElTag, null, {
        default: () =>
          purchPayReliveStatusOptions.find(
            s => String(status) === String(s.value)
          )?.label || "--"
      });
    }
  },
  {
    field: "apply_name",
    label: "申请人"
  },
  {
    field: "addtime",
    label: "申请时间"
  },
  {
    field: "apay_fee",
    label: "解除额度"
  },

  {
    field: "returnImg",
    label: "退款回执",
    span: 18,
    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: "remark",
    span: 24,
    label: "备注"
  }
];

export const purchpayColumns: DescriptionColumns = [
  {
    field: "dzNo",
    span: 6,
    label: "对账付款编码"
  },
  {
    field: "status",
    label: "状态",
    span: 6,
    render(status) {
      return h(ElTag, null, {
        default: () =>
          purchPayStatusOptions.find(s => String(status) === String(s.value))
            ?.label || "--"
      });
    }
  },

  {
    field: "payNo",
    span: 7,
    label: "对账申请编码"
  },

  {
    field: "apply_name",
    span: 5,
    label: "申请人"
    // render: (apply_name, { apply_id }) =>
    //   createTooltip(apply_name, "申请人ID : " + apply_id, 90)
  },

  {
    field: "pay_fee",
    span: 6,
    label: "付款额度"
  },
  {
    field: "return_time",
    span: 6,
    label: "回执时间"
  },

  {
    field: "return_img",
    label: "付款回执",
    span: 12,
    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: "remark",
    label: "备注",
    span: 24
  }
];
