<template>
  <!-- 提现审核 -->
  <div class="platinum_withdrawal_review_tab">
    <Filter @search="search" />
    <contextMenu :contextMenuList="getBtnListAction()">
      <a-table :columns="columns"
               class="srcollYTable"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :pagination="false"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               rowKey="key"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <template #expandedRowRender="{ record }">
          <BtnList :btnList="getBtnListAction()"
                   class="btn-list-sticky"
                   @onClick="btnClick(record)" />
        </template>
        <!-- 账户类型 -->
        <template #userinfotype="{ record }">
          <a>{{ record.userinfotype === 1 ? "个人" : "企业" }}</a>
        </template>
        <template #applystatus="{ }">
          <a>{{ getTableListStatus() }}</a>
        </template>
      </a-table>
    </contextMenu>
    <ControlModal :selectedRow="selectedRow"
                  @refresh="getTableList" />
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, contextMenu, BtnList, queryTableList, _getBtnList } from '@/common/export/table';
import { queryAccountInOutApply } from '@/services/go/ermcp/qhj';
import { QhjAccountOutInApply } from '@/services/go/ermcp/qhj/interface';
import Filter from '../../compoments/filter/index.vue';
import ControlModal from './compoments/controlModal/index.vue';
import { handleTableStatus, inOrOutStatus } from '../../setup';
import { BtnListType } from '@/common/components/btnList/interface';

export default defineComponent({
    name: 'platinum_withdrawal_review_tab',
    components: { Filter, contextMenu, BtnList, ControlModal },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();

        // 表格操作按钮列表
        const [firstBtn] = _getBtnList('platinum_withdrawal_review_tab', true).value;
        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick, btnClick } = getTableEvent<QhjAccountOutInApply>({});
        // 状态
        const { tableStatus, getTableListStatus, search } = handleTableStatus(queryTable, 1);
        function getBtnListAction(): BtnListType[] {
            const arr: string[] = ['详情'];
            switch (tableStatus.value) {
                case inOrOutStatus.wait:
                    arr.push('确认提现');
                    arr.push('审核拒绝');
                    break;
            }
            return firstBtn.filter((e: BtnListType) => arr.includes(e.lable));
        }

        function getTableList() {
            queryTable(queryAccountInOutApply, { querytype: 1, applystatus: tableStatus.value });
        }
        initData(() => {
            // 默认 查询待审核状态列表
            getTableList();
            // 注册表头信息 过滤
            registerColumn('table_pcweb_qhj_withdrawal_review', []);
        });

        return {
            getTableListStatus,
            getBtnListAction,
            getTableList,
            search,
            columns,
            updateColumn,
            expandedRowKeys,
            selectedRow,
            Rowclick,
            loading,
            tableList,
            queryTable,
            btnClick,
        };
    },
});
</script>