2025-02-13 02:29:50 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref } from "vue";
|
|
|
|
import { useLogin } from "./utils/hook";
|
|
|
|
import { getPickerShortcuts } from "../utils";
|
|
|
|
import { PureTableBar } from "@/components/RePureTableBar";
|
|
|
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
|
|
import { useI18n } from "vue-i18n";
|
2025-02-23 22:05:59 +08:00
|
|
|
import Delete from "@iconify-icons/ep/delete";
|
2025-02-13 02:29:50 +08:00
|
|
|
import Plane from "@iconify-icons/ri/plane-line";
|
|
|
|
import Refresh from "@iconify-icons/ep/refresh";
|
2025-02-23 22:05:59 +08:00
|
|
|
import { hasAuth } from "@/utils/auth";
|
2025-02-13 02:29:50 +08:00
|
|
|
defineOptions({
|
|
|
|
name: "MonitorLogin"
|
|
|
|
});
|
|
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
const formRef = ref();
|
|
|
|
const tableRef = ref();
|
|
|
|
|
|
|
|
const {
|
|
|
|
form,
|
|
|
|
loading,
|
|
|
|
columns,
|
|
|
|
dataList,
|
|
|
|
pagination,
|
|
|
|
selectedNum,
|
2025-02-23 22:05:59 +08:00
|
|
|
departments,
|
2025-02-13 02:29:50 +08:00
|
|
|
onSearch,
|
|
|
|
onbatchDel,
|
2025-02-23 22:05:59 +08:00
|
|
|
onbatchForce,
|
|
|
|
resetForm,
|
|
|
|
deleteUserHandle,
|
2025-02-13 02:29:50 +08:00
|
|
|
onSelectionCancel,
|
|
|
|
handleCurrentChange,
|
|
|
|
handleSizeChange,
|
2025-02-23 22:05:59 +08:00
|
|
|
handleDelete,
|
2025-02-13 02:29:50 +08:00
|
|
|
handleSelectionChange
|
|
|
|
} = useLogin(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] overflow-auto"
|
|
|
|
>
|
2025-02-23 22:05:59 +08:00
|
|
|
<el-form-item label="用户账号" prop="username">
|
2025-02-13 02:29:50 +08:00
|
|
|
<el-input
|
|
|
|
v-model="form.username"
|
2025-02-23 22:05:59 +08:00
|
|
|
placeholder="请输入用户账号~"
|
|
|
|
clearable
|
|
|
|
class="!w-[200px]"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="用户名称" prop="nickname">
|
|
|
|
<el-input
|
|
|
|
v-model="form.nickname"
|
|
|
|
placeholder="请输入用户名称~"
|
2025-02-13 02:29:50 +08:00
|
|
|
clearable
|
2025-02-23 22:05:59 +08:00
|
|
|
class="!w-[200px]"
|
2025-02-13 02:29:50 +08:00
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="登录状态" prop="status">
|
|
|
|
<el-select
|
|
|
|
v-model="form.status"
|
|
|
|
placeholder="请选择"
|
|
|
|
clearable
|
2025-02-23 22:05:59 +08:00
|
|
|
class="!w-[200px]"
|
2025-02-13 02:29:50 +08:00
|
|
|
>
|
2025-02-23 22:05:59 +08:00
|
|
|
<el-option label="成功" :value="1" />
|
|
|
|
<el-option label="失败" :value="0" />
|
2025-02-13 02:29:50 +08:00
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2025-02-24 18:24:24 +08:00
|
|
|
<el-form-item
|
|
|
|
v-if="hasAuth('login:btn:admin')"
|
|
|
|
label="所属部门:"
|
|
|
|
prop="department_id"
|
|
|
|
>
|
2025-02-23 22:05:59 +08:00
|
|
|
<el-cascader
|
|
|
|
v-model="form.department_id"
|
|
|
|
class="!w-[200px]"
|
|
|
|
:options="departments"
|
|
|
|
:props="{
|
|
|
|
value: 'id',
|
|
|
|
label: 'name',
|
|
|
|
emitPath: false,
|
|
|
|
checkStrictly: true
|
|
|
|
}"
|
|
|
|
clearable
|
|
|
|
filterable
|
|
|
|
placeholder="请选择所属部门~"
|
|
|
|
>
|
|
|
|
<template #default="{ node, data }">
|
|
|
|
<span>{{ data.name }}</span>
|
|
|
|
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
|
|
|
|
</template>
|
|
|
|
</el-cascader>
|
|
|
|
</el-form-item>
|
2025-02-13 02:29:50 +08:00
|
|
|
<el-form-item label="登录时间" prop="loginTime">
|
|
|
|
<el-date-picker
|
|
|
|
v-model="form.loginTime"
|
|
|
|
:shortcuts="getPickerShortcuts()"
|
|
|
|
type="datetimerange"
|
|
|
|
range-separator="至"
|
|
|
|
start-placeholder="开始日期时间"
|
|
|
|
end-placeholder="结束日期时间"
|
2025-02-23 22:05:59 +08:00
|
|
|
value-format="x"
|
|
|
|
unlink-panels
|
2025-02-13 02:29:50 +08:00
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button
|
|
|
|
type="primary"
|
|
|
|
:icon="useRenderIcon('ri:search-line')"
|
|
|
|
:loading="loading"
|
|
|
|
@click="onSearch"
|
|
|
|
>
|
|
|
|
{{ t("buttons:Search") }}
|
|
|
|
</el-button>
|
|
|
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
|
|
|
|
{{ t("buttons:Reset") }}
|
|
|
|
</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
|
2025-02-23 22:05:59 +08:00
|
|
|
<PureTableBar title="登录日志管理" :columns="columns" @refresh="onSearch">
|
2025-02-13 02:29:50 +08:00
|
|
|
<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">
|
|
|
|
{{ t("buttons:Deselect") }}
|
|
|
|
</el-button>
|
|
|
|
</div>
|
2025-02-23 22:05:59 +08:00
|
|
|
<el-popconfirm
|
|
|
|
v-if="hasAuth('login:btn:logout')"
|
|
|
|
title="是否确认强制退出?"
|
|
|
|
@confirm="onbatchForce"
|
|
|
|
>
|
2025-02-13 02:29:50 +08:00
|
|
|
<template #reference>
|
2025-02-23 22:05:59 +08:00
|
|
|
<el-button
|
|
|
|
type="warning"
|
|
|
|
text
|
|
|
|
class="mr-1"
|
|
|
|
:disabled="selectedNum < 0 || !hasAuth('login:btn:logout')"
|
|
|
|
>
|
|
|
|
{{ t("buttons:ExitInBatches") }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
|
|
|
<el-popconfirm
|
|
|
|
v-if="hasAuth('login:btn:delete')"
|
|
|
|
title="是否确认删除?"
|
|
|
|
@confirm="onbatchDel"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button
|
|
|
|
type="danger"
|
|
|
|
text
|
|
|
|
class="mr-1"
|
|
|
|
:disabled="selectedNum < 0 || !hasAuth('login:btn:delete')"
|
|
|
|
>
|
2025-02-13 02:29:50 +08:00
|
|
|
{{ t("buttons:DeleteInBatches") }}
|
|
|
|
</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, size }"
|
|
|
|
: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 #operation="{ row }">
|
2025-02-23 22:05:59 +08:00
|
|
|
<el-popconfirm
|
|
|
|
:title="`是否删除这条登录记录?`"
|
|
|
|
@confirm="handleDelete(row)"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button
|
|
|
|
class="reset-margin"
|
|
|
|
link
|
|
|
|
type="danger"
|
|
|
|
:disabled="!hasAuth('login:btn:delete')"
|
|
|
|
:size="size"
|
|
|
|
:icon="useRenderIcon(Delete)"
|
|
|
|
>
|
|
|
|
{{ t("buttons:Delete") }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
2025-02-13 02:29:50 +08:00
|
|
|
<el-popconfirm
|
|
|
|
:title="`是否强制下线${row.username}`"
|
|
|
|
@confirm="deleteUserHandle(row.session_id)"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button
|
|
|
|
class="reset-margin"
|
|
|
|
link
|
|
|
|
type="primary"
|
2025-02-23 22:05:59 +08:00
|
|
|
:disabled="!row.online || !hasAuth('login:btn:logout')"
|
2025-02-13 02:29:50 +08:00
|
|
|
:size="size"
|
|
|
|
:icon="useRenderIcon(Plane)"
|
|
|
|
>
|
|
|
|
{{ t("buttons:ForceToExit") }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
|
|
|
</template>
|
|
|
|
</pure-table>
|
|
|
|
</template>
|
|
|
|
</PureTableBar>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
: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>
|