<!-- 会员中心-我的出入金 -->
<template>
    <app-view>
        <template #header>
            <app-filter :options="filterOptons" />
        </template>
        <app-table :data="dataList" v-model:columns="tableColumns" :loading="loading">
            <template #header>
                <app-auth-operation :menus="['bank_deposit', 'bank_withdraw']" @closed="onRefresh" />
            </template>
            <!-- 申请状态 -->
            <template #applystatus="{ value }">
                {{ getApplyStatusName(value) }}
            </template>
            <!-- 申请类型 -->
            <template #executetype="{ value }">
                {{ getExecuteTypeName(value) }}
            </template>
            <!-- 操作 -->
            <template #operate="{ row }">
                <app-auth-operation type="dropdown" :menus="['bank_cancel']" :options="{ selectedRow: row }"
                    @closed="onRefresh" />
            </template>
        </app-table>
    </app-view>
</template>

<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { useDataFilter } from '@/hooks/datatable'
import { useAccountInOut } from '@/business/bank'
import { getApplyStatusName, getExecuteTypeName } from '@/constants/bank'
import { useComposeTable } from '@pc/components/base/table'
import AppTable from '@pc/components/base/table/index.vue'
import AppFilter from '@pc/components/base/table-filter/index.vue'
import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'

const { dataList, loading, getAccountInOutApply } = useAccountInOut()
const { tableColumns } = useComposeTable<Ermcp.AccountOutInApplyRsp>({ rowKey: 'bankticket', columnKey: 'mine_capital' })
const { filterOptons, getQueryParams } = useDataFilter<Ermcp.AccountInOutApplyReq>()

const onSearch = (clear = false) => {
    getQueryParams((qs) => {
        getAccountInOutApply(qs)
    }, clear)
}

const onRefresh = () => {
    getQueryParams((qs) => {
        getAccountInOutApply(qs).catch((err) => ElMessage.error(err))
    })
}

filterOptons.selectList = [
    {
        label: '状态',
        key: 'applystatus',
        options: [
            { label: '待审核', value: 1 },
            { label: '待复审', value: 2 }
        ],
    },
    {
        label: '申请类型',
        key: 'querytype',
        options: [
            { label: '出金', value: 1 },
            { label: '入金', value: 2 }
        ],
    },
]

filterOptons.buttonList = [
    { lable: '重置', onClick: () => onSearch(true) },
    { lable: '查询', className: 'el-button--primary', onClick: () => onSearch() }
]

onRefresh()
</script>