<template>
  <div>
    <!--引用表格-->
    <BasicTable @register="registerTable">
      <!--操作栏-->
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)" />
      </template>
    </BasicTable>

    <!-- 表单区域 -->
    <PushFileModal @register="registerModal" @success="handleSuccess"></PushFileModal>
  </div>
</template>

<script lang="ts" name="report-pushLog" setup>
  import { ref, computed, unref } from 'vue';
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { useModal } from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage';
  import PushFileModal from './modules/PushFileModal.vue';
  import { columnsgjk, searchFormSchemagjk } from './data';
  import { gjkjllist } from './api';

  //注册model
  const [registerModal, { openModal }] = useModal();
  //注册table数据
  const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
    tableProps: {
      title: '国家库记录',
      api: gjkjllist,
      columns: columnsgjk,
      canResize: false,
      pagination: {
        pageSize: 100,
      },
      formConfig: {
        labelWidth: 120,
        schemas: searchFormSchemagjk,
        autoSubmitOnEnter: true,
        showAdvancedButton: true,
      },
      actionColumn: {
        width: 120,
      },
      scroll: { y: 1000 },
      // showActionColumn: false
    },
  });

  /**
   * 详情
   */
  function handleDetail(record: Recordable) {
    openModal(true, {
      record,
      isUpdate: true,
      showFooter: false,
    });
  }

  /**
   * 操作栏
   */
  function getTableAction(record) {
    return [
      {
        label: '详情',
        onClick: handleDetail.bind(null, record),
      },
    ];
  }

  const [registerTable] = tableContext;
</script>
<style scoped></style>
