123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <script setup lang="ts">
- import { ref } from "vue";
- import { useRole } from "./hook";
- import { getPickerShortcuts } from "../../utils";
- import { PureTableBar } from "@/components/RePureTableBar";
- import { useRenderIcon } from "@/components/ReIcon/src/hooks";
- import Delete from "@iconify-icons/ep/delete";
- import Refresh from "@iconify-icons/ep/refresh";
- defineOptions({
- name: "LoginLog"
- });
- const formRef = ref();
- const tableRef = ref();
- const {
- form,
- loading,
- columns,
- dataList,
- pagination,
- selectedNum,
- onSearch,
- clearAll,
- resetForm,
- onbatchDel,
- handleSizeChange,
- onSelectionCancel,
- handleCurrentChange,
- handleSelectionChange
- } = useRole(tableRef);
- </script>
- <template>
- <div class="main">
- <el-form
- ref="formRef"
- :inline="true"
- :model="form"
- class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]"
- >
- <el-form-item label="用户名" prop="username">
- <el-input
- v-model="form.username"
- placeholder="请输入用户名"
- clearable
- class="!w-[180px]"
- />
- </el-form-item>
- <el-form-item label="登录时间" prop="loginTime">
- <el-date-picker
- v-model="form.loginTime"
- :shortcuts="getPickerShortcuts()"
- type="datetimerange"
- range-separator="至"
- start-placeholder="开始日期时间"
- end-placeholder="结束日期时间"
- />
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- :icon="useRenderIcon('ri:search-line')"
- :loading="loading"
- @click="onSearch"
- >
- 搜索
- </el-button>
- <el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
- 重置
- </el-button>
- </el-form-item>
- </el-form>
- <PureTableBar
- title="登录日志(仅演示,操作后不生效)"
- :columns="columns"
- @refresh="onSearch"
- >
- <template #buttons>
- <el-popconfirm title="确定要删除所有日志数据吗?" @confirm="clearAll">
- <template #reference>
- <el-button type="danger" :icon="useRenderIcon(Delete)">
- 清空日志
- </el-button>
- </template>
- </el-popconfirm>
- </template>
- <template v-slot="{ size, dynamicColumns }">
- <div
- v-if="selectedNum > 0"
- v-motion-fade
- class="bg-[var(--el-fill-color-light)] w-full h-[46px] mb-2 pl-4 flex items-center"
- >
- <div class="flex-auto">
- <span
- style="font-size: var(--el-font-size-base)"
- class="text-[rgba(42,46,54,0.5)] dark:text-[rgba(220,220,242,0.5)]"
- >
- 已选 {{ selectedNum }} 项
- </span>
- <el-button type="primary" text @click="onSelectionCancel">
- 取消选择
- </el-button>
- </div>
- <el-popconfirm title="是否确认删除?" @confirm="onbatchDel">
- <template #reference>
- <el-button type="danger" text class="mr-1"> 批量删除 </el-button>
- </template>
- </el-popconfirm>
- </div>
- <pure-table
- ref="tableRef"
- row-key="id"
- align-whole="center"
- table-layout="auto"
- :loading="loading"
- :size="size"
- adaptive
- :adaptiveConfig="{ offsetBottom: 108 }"
- :data="dataList"
- :columns="dynamicColumns"
- :pagination="pagination"
- :paginationSmall="size === 'small' ? true : false"
- :header-cell-style="{
- background: 'var(--el-fill-color-light)',
- color: 'var(--el-text-color-primary)'
- }"
- @selection-change="handleSelectionChange"
- @page-size-change="handleSizeChange"
- @page-current-change="handleCurrentChange"
- />
- </template>
- </PureTableBar>
- </div>
- </template>
- <style scoped lang="scss">
- :deep(.el-dropdown-menu__item i) {
- margin: 0;
- }
- .main-content {
- margin: 24px 24px 0 !important;
- }
- .search-form {
- :deep(.el-form-item) {
- margin-bottom: 12px;
- }
- }
- </style>
|