import { queryAccountInOutApply } from "@/services/go/ermcp/qhj";
import { ref } from "vue";

// 铂金宝 充值和提现审核状态
export enum inOrOutStatus {
    wait = 1,  // 待审核
    success,    // 审核成功
    refuse  // 审核拒绝
}
export function getApplyStatus(type: inOrOutStatus) {
    let result = '--'
    switch (type) {
        case inOrOutStatus.wait:
            result = '待审核'
            break
        case inOrOutStatus.success:
            result = '审核成功'
            break
        case inOrOutStatus.refuse:
            result = '审核拒绝'
            break
    }
    return result
}

export function handleTableStatus(queryTable: Function, querytype: 1 | 2) {
    // 表格数据状态
    const tableStatus = ref<inOrOutStatus>(inOrOutStatus.wait)
    /**
     * 获取铂金宝 充值和提现审核状态 对应中午显示名称
     * @param type inOrOutStatus
     * @returns 
     */

    // 获取表格数据状态
    function getTableListStatus() {
        return getApplyStatus(tableStatus.value)
    }
    function search(value: any) {
        const { accountcode, applystatus, reqtime } = value;
        // 申请起始日期
        const begindate = reqtime.length > 1 ? reqtime[0] : '';
        // 申请截止日期
        const enddate = reqtime.length > 1 ? reqtime[reqtime.length - 1] : '';
        // 模糊搜索名称
        const likename = accountcode.length ? accountcode[0] : '';
        // 状态 1-待审核 2-审核通过 3-审核拒绝
        const status = applystatus[0] as 1 | 2 | 3;
        // 记录状态
        tableStatus.value = status;
        const param = { querytype, applystatus: status, begindate, enddate, likename };
        queryTable(queryAccountInOutApply, param);
    }
    return { tableStatus, getApplyStatus, getTableListStatus, search }
}

