<template>
  <!-- 销售： 待点价-->
  <div class="sell-peddding"
       :loading="loading">
    <filterCustomTable @search="updateColumn">
      <BtnList :btnList="firstBtn"
               @click="openComponent" />
    </filterCustomTable>
    <a-table :columns="columns"
             class="srcollYTable"
             :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
             :pagination="false"
             :loading="loading"
             :expandedRowKeys="expandedRowKeys"
             :customRow="Rowclick"
             rowKey="key"
             :data-source="tableList">
      <!-- 额外的展开行 -->
      <template #expandedRowRender="{ record }">
        <BtnList :btnList="secondBtn"
                 :record="record"
                 @click="openComponent" />
      </template>
    </a-table>
    <!-- 右键 -->
    <contextMenu :contextMenu="contextMenu"
                 @cancel="closeContext"
                 :list="secondBtn">
    </contextMenu>
    <component :is="componentId"
               v-if="componentId"
               :selectedRow="selectedRow"
               @cancel="closeComponent"></component>
  </div>
</template>

<script lang="ts">
import { EnumRouterName } from '@/common/constants/enumRouterName';
import { queryTableList, BtnList, contextMenu, defineAsyncComponent, defineComponent, ModalEnum, handleComposeTable, ComposeTableParam } from '@/common/export/commonTable';
import { QueryWareHouse } from '@/services/go/ermcp/sell';
import { Ermcp3SellBuyContract } from '@/views/business/purchase/list';

import { filterCustomTable } from '../../components';
const Detail = defineAsyncComponent(() => import('../../components/detail/index.vue'));
const SomePrice = defineAsyncComponent(() => import('../../components/someprice/index.vue')); //采购点价登记

export default defineComponent({
    name: EnumRouterName.sell_pending,
    components: {
        contextMenu,
        filterCustomTable,
        BtnList,
        [ModalEnum.detail]: Detail,
        [ModalEnum.sell_pending_someprice]: SomePrice,
    },
    setup() {
        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList<Ermcp3SellBuyContract>();
        // 获取列表数据
        const queryTableAction = () => queryTable(QueryWareHouse, { querytype: 2 });
        // 表格通用逻辑
        const param: ComposeTableParam = {
            queryFn: queryTableAction,
            menuType: EnumRouterName.sell_pending,
            tableName: 'table_pcweb_sales_pointprice',
            tableFilterKey: ['accountname', 'contractno', 'deliverygoodsname', 'convertfactor', 'goodsname'],
            isDetail: true,
        };

        return {
            ...handleComposeTable<Ermcp3SellBuyContract>(param),
            tableList,
            loading,
        };
    },
});
</script>

<style lang="less">
.sell-peddding {
}
</style
>;
