<template>
  <!-- 现货仓单-现货明细 -->
  <mtp-table-scroll>
    <template #default="{ scroll }">
      <a-table :columns="columns" 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" v-if="record.enableqty > 0" />
        </template>
      </a-table>
    </template>
  </mtp-table-scroll>
  <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"></component>
</template>

<script lang="ts">
import { PropType } from 'vue';
import { BtnList, defineAsyncComponent, defineComponent, queryTableList } from '@/common/export/commonTable';
import { getRecordItemTab } from '@/common/setup/order/orderData';
import { expandIcon } from '@/common/setup/table/clolumn';
import { handleComposeOrderTable } from '@/common/setup/table/compose';
import { ComposeOrderTableParam } from '@/common/setup/table/interface';
import { queryHoldLB } from '@/services/go/wrtrade';
import { WrHoldLB } from '@/services/go/wrtrade/interface';
import MtpTableScroll from '@/common/components/tableScroll/index.vue';
import { DynamicComponent } from '@/@next/hooks/common/interface'

export default defineComponent({
  props: {
    parentComponent: {
      type: Object as PropType<DynamicComponent>,
      required: true
    }
  },
  components: {
    MtpTableScroll,
    BtnList,
    listed: defineAsyncComponent(() => import('./components/listing/index.vue')), // 挂牌
    pickup: defineAsyncComponent(() => import('./components/pick_up/index.vue')), // 提货
  },
  setup(props) {
    const { buttons } = props.parentComponent;
    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<WrHoldLB>();

    // 获取列表数据
    const queryTableAction = () => {
      queryTable(queryHoldLB);
    }

    // 表格通用逻辑
    const param: ComposeOrderTableParam = {
      queryFn: queryTableAction,
      tableName: 'table_pcweb_spot_trade_bottom_spot_warrant_spot_detail',
      recordList: getRecordItemTab(),
    }

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