<template>
  <!-- 现货参考价 -->
  <mtp-table-scroll>
    <template #header>
      <mtp-table-filter @search="updateColumn"></mtp-table-filter>
    </template>
    <template #default="{ scroll }">
      <a-table :columns="columns" class="srcollYTable" :scroll="scroll" :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="buttons" :record="record" @click="openComponent" />
        </template>
      </a-table>
    </template>
  </mtp-table-scroll>
  <!-- 右键 -->
  <contextMenu :contextMenu="contextMenu" @cancel="closeContext" :list="buttons"> </contextMenu>
  <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"> </component>
</template>

<script lang="ts">
import MtpTableScroll from '@/common/components/tableScroll/index.vue';
import { queryTableList, MtpTableButton, contextMenu, defineAsyncComponent, defineComponent, handleComposeTable, ComposeTableParam } from '@/common/export/commonTable';
import { Ermcp3SpotGoodsPrice } from '@/services/go/ermcp/qhj/interface';
import { querySpotGoodsPrice } from '@/services/go/ermcp/qhj';
import { getTableButton } from '@/common/setup/table/button';
import { useColumn } from './setup';
import MtpTableFilter from '../../components/filter/index.vue';

export default defineComponent({
  name: 'spotmarket_price',
  components: {
    MtpTableScroll,
    contextMenu,
    MtpTableFilter,
    MtpTableButton,
    detail: defineAsyncComponent(() => import('../../components/detail/index.vue')), // 详情
    modify: defineAsyncComponent(() => import('../../components/modify/index.vue')), // 修改
  },
  setup() {
    // 权限按钮
    const buttons = getTableButton();

    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<Ermcp3SpotGoodsPrice>(true, 2);

    // 获取列表数据
    const queryTableAction = () => queryTable(querySpotGoodsPrice);

    // 表格通用逻辑
    const param: ComposeTableParam = {
      queryFn: queryTableAction,
      tableName: 'table_pcweb_hedging_plan',
    };

    return {
      ...handleComposeTable<Ermcp3SpotGoodsPrice>(param),
      ...useColumn(),
      loading,
      tableList,
      queryTable,
      buttons,
    };
  },
});
</script>