<template>
  <!-- 仓库信息: 正常 -->
  <div class="warehouse-info-normal"
       :loading="loading">
    <filterCustomTable @search="updateColumn">
      <BtnList :btnList="commonBtn" />
    </filterCustomTable>
    <contextMenu :contextMenuList="forDataBtn">
      <a-table :columns="columns"
               class="srcollYTable"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :pagination="false"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               rowKey="key"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <template #expandedRowRender="{ record }">
          <BtnList :selectedData="record"
          class="btn-list-sticky"
                   :btnList="forDataBtn"
                   @onClick="btnClick" />
        </template>
        <template #warehousetype="{ text }">
          <span>{{ getWareHouseTypeName(text) }}</span>
        </template>
        <template #warehousestatus="{ text }">
          <span>{{ gerWareHouseStatusName(text) }}</span>
        </template>
      </a-table>
    </contextMenu>
    <!-- 新增仓库信息 -->
    <Add :selectedRow="selectedRow"
         @refresh="queryTable" />
    <!-- 停用仓库信息 -->
    <Disable :selectedRow="selectedRow"
             @refresh="queryTable" />
    <!-- 仓库信息详情 -->
    <Detail :selectedRow="selectedRow"
            @refresh="queryTable" />
    <!-- 修改仓息库信 -->
    <Modify :selectedRow="selectedRow"
            @refresh="queryTable" />
  </div>
</template>

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

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

        return {
            columns,

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

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

