<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="buttons.length" #expandedRowRender="{ record }">
          <BtnList :btnList="buttons" :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, PropType } 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 { queryErmcpTradeDetails } from '@/services/go/ermcp/futures';
import { QueryErmcpTradeDetailsRsp } from '@/services/go/ermcp/futures/interface';
import { getColumns } from './columns';
import { DynamicComponent } from '@/@next/hooks/common/interface'

export default defineComponent({
  props: {
    parentComponent: {
      type: Object as PropType<DynamicComponent>,
      required: true
    }
  },
  components: {
    MtpTableScroll,
    BtnList,
  },
  setup(props) {
    const { buttons } = props.parentComponent;
    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<QueryErmcpTradeDetailsRsp>();

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

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