/**
 * 付款详情
 */

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

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: "申请人"
  },

  {
    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
  }
];

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

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

  {
    field: "apply_name",
    span: 5,
    label: "申请人"
  },

  {
    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
  }
];

export const columns = [
  {
    label: "对账编码",
    prop: "payNo",
    minWidth: 160,
    align: "left"
  },
  {
    label: "供应商编码",
    prop: "supplierNo",
    minWidth: 150,
    align: "left"
  },
  {
    label: "供应商名称",
    prop: "supplierName",
    minWidth: 180,
    align: "left"
  },
  {
    label: "业务公司编码",
    prop: "companyNo",
    minWidth: 150
  },
  {
    label: "业务公司名称",
    prop: "companyName",
    minWidth: 180
  },
  {
    label: "付款状态",
    prop: "pay_status",
    minWidth: 100
  },
  {
    label: "总额款",
    prop: "total_fee",
    minWidth: 110,
    align: "total_fee"
  },
  {
    label: "付款标签金额",
    prop: "pay_tag_fee",
    minWidth: 110,
    align: "left"
  },
  {
    label: "已付款金额",
    prop: "apay_fee",
    minWidth: 110,
    align: "left"
  },
  {
    label: "申请人",
    prop: "apply_name",
    minWidth: 90,
    align: "total_fee"
  }
];
