<template>
  <!-- 提现审核 -->
  <div class="platinum_withdrawal_review_tab">
    <Filter @search="search" />
    <a-table :columns="columns" class="srcollYTable" :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }" :pagination="false" :loading="loading" :expandedRowKeys="expandedRowKeys" :customRow="Rowclick" :rowKey="(record,index)=>index" :data-source="tableList">
      <!-- 额外的展开行 -->
      <template #expandedRowRender="{ record }">
        <mtp-table-button class="btn-list-sticky" :buttons="handleBtn(record)" :record="record" @click="openComponent" />
      </template>
      <!-- 账户类型 -->
      <template #userinfotype="{ record }">
        <a>{{ record.userinfotype === 1 ? "个人" : "企业" }}</a>
      </template>
      <template #applystatus="{ }">
        <a>{{ getTableListStatus() }}</a>
      </template>
    </a-table>
    <!-- 右键 -->
    <contextMenu :contextMenu="contextMenu" @cancel="closeContext" :list="handleBtn(selectedRow)"> </contextMenu>
    <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"> </component>
  </div>
</template>

<script lang="ts">
import { EnumRouterName } from '@/common/constants/enumRouterName';
import { ComposeTableParam, contextMenu, defineAsyncComponent, defineComponent, handleComposeTable, MtpTableButton, queryTableList } from '@/common/export/commonTable';
import { getTableButton } from '@/common/setup/table/button';
import { queryAccountInOutApply } from '@/services/go/ermcp/qhj';
import { QhjAccountOutInApply } from '@/services/go/ermcp/qhj/interface';
import Filter from '../../compoments/filter/index.vue';
import { handleTableStatus, inOrOutStatus } from '../../setup';

export default defineComponent({
  name: 'platinum_withdrawal_review_tab',
  components: {
    Filter,
    contextMenu,
    MtpTableButton,
    detail: defineAsyncComponent(() => import('./compoments/detail/index.vue')), // 详情
    review_confirm: defineAsyncComponent(() => import('./compoments/withdrawal/index.vue')), // 确认提现
    review_refuse: defineAsyncComponent(() => import('./compoments/refuse/index.vue')), // 审核拒绝
  },
  setup() {
    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<QhjAccountOutInApply>();
    // 状态
    const { tableStatus, getTableListStatus, search } = handleTableStatus(queryTable, 1);

    const queryTableAction = () => {
      queryTable(queryAccountInOutApply, { querytype: 1, applystatus: tableStatus.value });
    };
    // 表格通用逻辑
    const param: ComposeTableParam = {
      queryFn: queryTableAction,
      tableName: 'table_pcweb_qhj_withdrawal_review',
    };

    function handleBtn(record: QhjAccountOutInApply) {
      if (!record) return;
      const buttons = getTableButton();
      if (tableStatus.value === inOrOutStatus.wait) {
        return buttons;
      } else {
        return buttons.filter((e) => e.code === 'detail');
      }
    }

    return {
      ...handleComposeTable<QhjAccountOutInApply>(param),
      loading,
      handleBtn,
      getTableListStatus,
      search,
      tableList,
      queryTable,
    };
  },
});
</script>