<template>
  <!-- 仓单贸易 贸易圈挂牌 买-->
  <div>
    <a-table :columns="columns"
             :class="['srcollYTable', isBottom ? 'condSecondTabTable' : 'condSecondTabTableNoBottom']"
             :scroll="{ x: '100%', y: isBottom ? 'calc(100vh- 443px)' : 'calc(100vh - 196px)' }"
             :pagination="false"
             :loading="loading"
             :expandedRowKeys="expandedRowKeys"
             :customRow="Rowclick"
             rowKey="key"
             :data-source="tableList">
      <template #index="{ index }">
        <span>{{ index + 1  }}</span>
      </template>
      <!-- 议价 -->
      <template #canbargain="{ text }">
        <span>{{ text ? '是' : '否' }}</span>
      </template>
      <!-- 整单 -->
      <template #canpart="{ text }">
        <span>{{ text ? '是' : '否' }}</span>
      </template>
      <!-- 挂牌有效期 -->
      <template #validtime="{ text }">
        <span>{{ formatTime(text, 'd') }}</span>
      </template>
    </a-table>
    <!-- 右键 -->
    <contextMenu :contextMenu="contextMenu"
                 @cancel="closeContext"
                 :list="firstBtn"></contextMenu>
    <component :is="componentId"
               v-if="componentId"
               :enumName="name"
               :selectedRow="selectedRow"
               @cancel="closeComponent"></component>
  </div>
</template>

<script lang="ts">
import { EnumRouterName } from '@/common/constants/enumRouterName';
import { queryTableList, contextMenu, defineAsyncComponent, defineComponent, ModalEnum, ComposeTableParam } from '@/common/export/commonTable';
import { QueryOrderQuoteMyqQsp, QueryOrderQuoteMyqQsq, QueryOrderQuoteReq, WrOrderQuote } from '@/services/go/wrtrade/interface';
import { queryOrderQuote, queryQueryOrderQuoteMyq } from '@/services/go/wrtrade';
import { handleComposeTable } from '@/common/setup/table/compose';
import Filter from '../../components/filter/index.vue';
import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
import { getShowBottomValue } from '@/common/config/constrolBottom';
import { handleColumns } from '../../setup';
import { BuyOrSell } from '@/common/constants/enumCommon';
import { formatTime } from '@/common/methods';

export default defineComponent({
    name: EnumRouterName.warehouse_receipt_trade_floating_price,
    components: {
        contextMenu,
    },
    setup() {
        const isBottom = getShowBottomValue();
        // 表头
        const { getBuyOrSellColumns } = handleColumns();
        const columns = getBuyOrSellColumns(BuyOrSell.buy).map((el) => {
            const slots = { customRender: el.key };
            return { ...el, slots, dataIndex: el.key };
        });

        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList<QueryOrderQuoteMyqQsp>();
        // 获取列表数据
        const queryTableAction = () => {
            const param: QueryOrderQuoteMyqQsq = {
                buyorsell: BuyOrSell.buy,
                haswr: 1,
            };
            queryTable(queryQueryOrderQuoteMyq, param);
        };
        // 表格通用逻辑
        const param: ComposeTableParam = {
            queryFn: queryTableAction,
            menuType: EnumRouterName.warehouse_receipt_trade_blocs,
            tableFilterKey: [],
            isDetail: false,
        };
        const {
            contextMenu,
            openContext,
            closeContext, // 右键
            expandedRowKeys,
            selectedRow,
            Rowclick, // 表格折腾面板数据与单击、双击事件
            componentId,
            closeComponent,
            openComponent, // 控制异步组件
            firstBtn,
            secondBtn, // 表格按钮
        } = handleComposeTable<QueryOrderQuoteMyqQsp>(param);
        function search(value: Object) {
            // const param: QueryOrderQuoteReq = {
            //     wrpricetype: 2,
            //     haswr: 1,
            // };
            // Object.assign(param, value);
            // queryTable(queryOrderQuote, param);
        }

        return {
            isBottom,
            contextMenu,
            openContext,
            closeContext, // 右键
            columns,
            expandedRowKeys,
            selectedRow,
            Rowclick, // 表格折腾面板数据与单击、双击事件
            componentId,
            closeComponent, // 控制异步组件
            firstBtn, // 表格按钮
            loading,
            tableList,
            search,
            formatTime,
        };
    },
});
</script>
<style lang="less">
</style>