<template>
  <!-- 仓库信息: 停用 -->
  <div class="warehouse-info-stop">
    <filterCustomTable @search="updateColumn">
      <BtnList :btnList="commonBtn" />
    </filterCustomTable>
    <contextMenu :contextMenuList="forDataBtn">
      <a-table :columns="columns"
               class="topTable"
               :pagination="false"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               rowKey="key"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <template #expandedRowRender="{  }">
          <BtnList :btnList="forDataBtn" />
        </template>
        <template #warehousetype="{ text }">
          <span>{{ getWareHouseTypeName(text) }}</span>
        </template>
        <template #warehousestatus="{ text }">
          <span>{{ gerWareHouseStatusName(text) }}</span>
        </template>
      </a-table>
    </contextMenu>
    <!-- 恢复仓库信息 -->
    <Recover :selectedRow="selectedRow"
             @refresh="queryTable" />
    <!-- 仓库信息详情 -->
    <Detail :selectedRow="selectedRow"
            @refresh="queryTable" />
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, getBtnList, contextMenu, BtnList } from '@/common/export/table';
import { filterCustomTable, Detail, Recover } from '../../compoments';
import { gerWareHouseStatusName, getWareHouseTypeName, queryTableList, ErmcpWareHouseInfo } from '../index';

export default defineComponent({
    name: 'warehouse-info-stop',
    components: {
        contextMenu,
        filterCustomTable,
        Detail,
        Recover,
        BtnList,
    },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick } = getTableEvent<ErmcpWareHouseInfo>({});
        // 表格操作按钮列表
        const { commonBtn, forDataBtn } = getBtnList('warehouse_info_disabled', true);
        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList('2');
        initData(() => {
            // 获取列表数据
            queryTable();
            // 注册表头信息 过滤
            registerColumn('table_pcweb_warehouse', ['warehousetype', 'warehousename', 'address']);
        });

        return {
            columns,

            expandedRowKeys,
            selectedRow,
            Rowclick,
            commonBtn,
            forDataBtn,
            loading,
            tableList,
            updateColumn,
            getWareHouseTypeName,
            gerWareHouseStatusName,
            queryTable,
        };
    },
});
</script>

<style lang="less">
.warehouse-info-stop {
}
</style
>;
