/**
 * 资金退款详情
 */
import { ElImage, ElTag } from "element-plus";
import { h } from "vue";
import { createTooltip } from "../tootip";
import { DescriptionColumns } from "/@/components/BasicDescriptions";

//退款类型
export const RETRUN_TYPE = [
  {
    value: "1",
    label: "退款"
  },
  {
    value: "2",
    label: "资金认领解除"
  }
];

//退款状态
export const RETRUN_STATUS = [
  {
    value: "0",
    label: "待审核"
  },
  {
    value: "1",
    label: "审核通过"
  },
  {
    value: "2",
    label: "财务驳回"
  }
];

export const REFOUD_COLUMNS: DescriptionColumns = [
  {
    label: "退款编码",
    span: 2,
    field: "returnCode"
  },
  {
    label: "资金认领编码",
    span: 2,
    field: "logNo"
  },
  {
    label: "资金编码",
    span: 2,
    field: "tradNo"
  },
  {
    label: "退款类型",
    field: "type",
    render(type) {
      return h(ElTag, null, {
        default: () => RETRUN_TYPE.find(t => t.value === type)?.label
      });
    }
  },
  {
    label: "退款状态",
    field: "status",
    render(status) {
      return h(ElTag, null, {
        default: () => RETRUN_STATUS.find(s => s.value === status)?.label
      });
    }
  },
  {
    label: "申请人",
    field: "apply_name",
    render: (apply_name, { apply_id }) =>
      createTooltip(apply_name, "申请人ID : " + apply_id, 90)
  },
  {
    label: "付款",
    span: 2,
    field: "trade_out"
  },
  {
    label: "退款时间",
    field: "addtime"
  },
  {
    label: "交易公司",
    span: 2,
    field: "trade_out"
  },
  {
    label: "收款公司",
    span: 2,
    field: "trade_in"
  },
  {
    label: "交易银行",
    span: 2,
    field: "trade_bank"
  },
  {
    label: "总金额",
    field: "total_fee"
  },
  {
    label: "余额",
    field: "balance"
  },
  {
    label: "已认领金额",
    field: "used_fee"
  },
  {
    label: "认领金额",
    field: "log_total_fee"
  },
  {
    label: "退款回执",
    field: "return_img",
    span: 2,
    render(img_url) {
      const imgs = img_url ? img_url.split(",") : [];
      return imgs.map(url => {
        return h(ElImage, {
          src: url,
          style: { height: "20px" },
          previewSrcList: [url],
          previewTeleported: true
        });
      });
    }
  },
  {
    label: "退款原因",
    field: "return_reason",
    span: 6
  },
  {
    label: "备注",
    field: "remark"
  }
];
