<template>
  <PageWrapper>
    <el-card :bordered="false" class="mb-3 proCard">
      <el-space align="center">
        <el-input
          :style="{ width: '320px' }"
          v-model="params.userName"
          clearable
          placeholder="请输入用户名称"
          @keyup.enter="reloadTable"
        />
        <el-button type="primary" @click="reloadTable">
          <template #icon>
            <el-icon>
              <SearchOutlined />
            </el-icon>
          </template>
          查询
        </el-button>
      </el-space>
    </el-card>
    <el-card :bordered="false" class="proCard">
      <BasicTable
        :columns="columns"
        :request="loadDataTable"
        :row-key="(row) => row.id"
        ref="basicTableRef"
      />
    </el-card>
  </PageWrapper>
</template>

<script lang="ts" setup>
  import { reactive, ref } from 'vue';
  import { BasicTable } from '@/components/Table';
  import { loginLogList } from '@/api/system/logs';
  import { SearchOutlined } from '@vicons/antd';
  import { columns } from './loginColumns';

  const basicTableRef = ref();
  const tableData = ref();

  const params = reactive({
    userName: '',
  });

  const loadDataTable = async (res) => {
    const result = await loginLogList({ ...params, ...res });
    tableData.value = result.list;
    return result;
  };

  function reloadTable() {
    basicTableRef.value.reload();
  }
</script>

<style lang="scss" scoped></style>
