<template>
  <!-- 期货订单-成交 -->
  <mtp-table-scroll>
    <template #default="{ scroll }">
      <a-table :columns="getColumns()" class="srcollYTable" :scroll="scroll" :pagination="false" :loading="loading" :expandedRowKeys="expandedRowKeys" :customRow="Rowclick" :expandIcon="expandIcon" :expandIconAsCell="false" :rowKey="(record,index)=>index" :data-source="tableList">
        <!-- 额外的展开行 -->
        <template v-if="btnList.length" #expandedRowRender="{ record }">
          <BtnList :btnList="btnList" :record="record" class="btn-list-sticky" @click="openComponent" />
        </template>
      </a-table>
    </template>
  </mtp-table-scroll>
  <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"></component>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import MtpTableScroll from '@/common/components/tableScroll/index.vue';
import { queryTableList, BtnList } from '@/common/export/commonTable';
import { handleComposeOrderTable } from '@/common/setup/table/compose';
import { ComposeOrderTableParam } from '@/common/setup/table/interface';
import { expandIcon } from '@/common/setup/table/clolumn';
import { getRecordItemTab } from '@/common/setup/order/orderData';
import { queryErmcpTradeDetails } from '@/services/go/ermcp/futures';
import { QueryErmcpTradeDetailsRsp } from '@/services/go/ermcp/futures/interface';
import { getColumns } from './columns';

export default defineComponent({
  components: {
    MtpTableScroll,
    BtnList,
  },
  setup() {
    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<QueryErmcpTradeDetailsRsp>();

    // 表格通用逻辑
    const param: ComposeOrderTableParam = {
      queryFn: () => queryTable(queryErmcpTradeDetails),
      recordList: getRecordItemTab(),
    };

    return {
      ...handleComposeOrderTable(param),
      getColumns,
      loading,
      expandIcon,
      tableList,
    };
  },
});
</script>