<template>
  <!-- 库存查询: 申请记录-->
  <div class="inventory_current"
       :loading="loading">
    <Filter @search="updateColumn">
      <BtnList :btnList="firstBtn" />
    </Filter>
    <contextMenu :contextMenuList="secondBtn">
      <a-table :columns="columns"
               class="srcollYTable"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :pagination="false"
               rowKey="key"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <!-- <template #expandedRowRender="{  }">
          <BtnList :btnList="secondBtn" />
        </template> -->
        <!-- <template #userinfotype="{ text }">
                  <a>{{ text === '2' ? '企业' : '个人'}}</a>
                </template> -->

        <template #biztype="{ text }">
          <a>{{ getBizTypeName(text) }}</a>
        </template>

        <template #pricetype="{ text }">
          <a>{{ getPriceTypeName(text) }}</a>
        </template>

        <template #applystatus="{ text }">
          <a>{{ getApplyStatusName(text) }}</a>
        </template>

        <template #contracttype="{ text }">
          <a>{{ getContractTypeName(text) }}</a>
        </template>

      </a-table>
    </contextMenu>
    <!-- 现货合同: 审核 -->
    <Add :selectedRow="selectedRow"
         @refresh="queryTable" />
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, getBtnList, contextMenu, BtnList, _getBtnList } from '@/common/export/table';
import Filter from '../../components/filterTable/index.vue';
import Add from '../../components/add/index.vue';

import { getApplyStatusName, getBizTypeName, getContractStatusName, getContractTypeName, getPriceTypeName } from '@/common/constants/enumsName';
import { Ermcp3AreaStockApply, queryTableList } from './setup';

export default defineComponent({
    name: 'inventory_current',
    components: {
        Filter,
        contextMenu,
        Add,
        BtnList,
    },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick } = getTableEvent<Ermcp3AreaStockApply>({});
        // 表格操作按钮列表
        const [firstBtn, secondBtn] = _getBtnList('inventory_applyrecord', false).value;

        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList();

        initData(() => {
            // 获取列表数据
            queryTable();
            // 注册表头信息 过滤
            registerColumn('table_pcweb_application_record', ['deliverygoodsid', 'wrstandardid', 'spotgoodsbrandid', 'warehouseinfoid']);
        });
        return {
            columns,

            expandedRowKeys,
            selectedRow,
            Rowclick,
            firstBtn,
            secondBtn,
            loading,
            tableList,
            updateColumn,
            queryTable,
            getBizTypeName,
            getPriceTypeName,
            getContractStatusName,
            getContractTypeName,
            getApplyStatusName,
        };
    },
});
</script>

<style lang="less">
.inventory_current {
}
</style>;
