--日志板块

This commit is contained in:
lai
2023-11-10 18:25:56 +08:00
parent b8190bd640
commit ca4493aaa6
12 changed files with 330 additions and 151 deletions

View File

@@ -98,48 +98,48 @@ let tableState: TabeStateType = reactive({
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: '日志编号',
title: t('views.system.log.login.operId'),
dataIndex: 'loginId',
align: 'center',
},
{
title: '登录账号',
title: t('views.system.log.login.account'),
dataIndex: 'userName',
align: 'center',
},
{
title: '登录地址',
title: t('views.system.log.login.loginIp'),
dataIndex: 'ipaddr',
align: 'center',
},
{
title: '登录地点',
title: t('views.system.log.login.loginLoc'),
dataIndex: 'loginLocation',
align: 'center',
},
{
title: '操作系统',
title: t('views.system.log.login.os'),
dataIndex: 'os',
align: 'center',
},
{
title: '浏览器',
title: t('views.system.log.login.browser'),
dataIndex: 'browser',
align: 'center',
},
{
title: '登录状态',
title: t('views.system.log.login.status'),
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '登录信息',
title: t('views.system.log.login.info'),
dataIndex: 'msg',
align: 'center',
},
{
title: '登录时间',
title: t('views.system.log.login.loginTime'),
dataIndex: 'loginTime',
align: 'center',
customRender(opt) {
@@ -167,7 +167,7 @@ let tablePagination = reactive({
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => `总共 ${total}`,
showTotal: (total: number) => t('common.tablePaginationTotal', { total }),
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
@@ -192,6 +192,7 @@ function fnTableSelectedRows(
_: (string | number)[],
rows: Record<string, string>[]
) {
//debugger
tableState.selectedRowKeys = rows.map(item => item.loginId);
// 针对单个登录账号解锁
if (rows.length === 1) {
@@ -206,14 +207,14 @@ function fnRecordDelete() {
const ids = tableState.selectedRowKeys.join(',');
Modal.confirm({
title: t('common.tipTitle'),
content: `确认删除访问编号为 【${ids}】 的数据项吗?`,
content: t('views.system.log.login.browser', { ids: ids }),
onOk() {
const key = 'delSysLogLogin';
message.loading({ content: t('common.loading'), key });
delSysLogLogin(ids).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
content: t('common.msgSuccess', { msg: t('common.deleteText') }),
key,
duration: 3,
});
@@ -234,14 +235,16 @@ function fnRecordDelete() {
function fnCleanList() {
Modal.confirm({
title: t('common.tipTitle'),
content: `确认清空所有登录日志数据项?`,
content: t('views.system.log.login.delAllSure'),
onOk() {
const key = 'cleanSysLogLogin';
message.loading({ content: t('common.loading'), key });
cleanSysLogLogin().then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `清空成功`,
content: t('common.msgSuccess', {
msg: t('views.system.log.login.delAll'),
}),
key,
duration: 3,
});
@@ -263,14 +266,16 @@ function fnUnlock() {
const username = tableState.selectedUserName;
Modal.confirm({
title: t('common.tipTitle'),
content: `确认解锁用户 【${username}】 数据项?`,
content: t('views.system.log.login.unlockSure', { username }),
onOk() {
const hide = message.loading(t('common.loading'), 0);
unlock(username).then(res => {
hide();
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `${username} 解锁成功`,
content: t('views.system.log.login.unlockSure', {
userName: username,
}),
duration: 3,
});
} else {
@@ -288,14 +293,16 @@ function fnUnlock() {
function fnExportList() {
Modal.confirm({
title: t('common.tipTitle'),
content: `确认根据搜索条件导出xlsx表格文件吗?`,
content: t('views.system.user.exportSure'),
onOk() {
const key = 'exportSysLogLogin';
message.loading({ content: t('common.loading'), key });
exportSysLogLogin(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成导出`,
content: t('common.msgSuccess', {
msg: t('views.system.user.export'),
}),
key,
duration: 2,
});
@@ -316,7 +323,7 @@ function fnExportList() {
function fnGetList(pageNum?: number) {
if (tableState.loading) return;
tableState.loading = true;
if(pageNum){
if (pageNum) {
queryParams.pageNum = pageNum;
}
if (!queryRangePicker.value) {
@@ -360,44 +367,52 @@ onMounted(() => {
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录地址" name="ipaddr">
<a-form-item
:label="t('views.system.log.login.loginIp')"
name="ipaddr"
>
<a-input
v-model:value="queryParams.ipaddr"
allow-clear
:maxlength="128"
placeholder="请输入登录地址"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录账号" name="userName">
<a-form-item
:label="t('views.system.log.login.account')"
name="userName"
>
<a-input
v-model:value="queryParams.userName"
allow-clear
:maxlength="30"
placeholder="请输入登录账号"
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录状态" name="status">
<a-form-item
:label="t('views.system.log.login.status')"
name="status"
>
<a-select
v-model:value="queryParams.status"
allow-clear
placeholder="请选择登录状态"
:options="dict.sysCommonStatus"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="登录时间" name="queryRangePicker">
<a-form-item
:label="t('views.system.log.login.loginTime')"
name="queryRangePicker"
>
<a-range-picker
v-model:value="queryRangePicker"
allow-clear
bordered
value-format="YYYY-MM-DD"
:placeholder="['登录开始', '登录结束']"
style="width: 100%"
></a-range-picker>
</a-form-item>
@@ -407,11 +422,11 @@ onMounted(() => {
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList(1)">
<template #icon><SearchOutlined /></template>
搜索</a-button
{{ t('common.search') }}</a-button
>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
重置</a-button
{{ t('common.reset') }}</a-button
>
</a-space>
</a-form-item>
@@ -431,7 +446,7 @@ onMounted(() => {
v-perms:has="['system:log:login:unlock']"
>
<template #icon><UnlockOutlined /></template>
解锁
{{ t('views.system.log.login.unlock') }}
</a-button>
<a-button
type="default"
@@ -441,7 +456,7 @@ onMounted(() => {
v-perms:has="['system:log:login:remove']"
>
<template #icon><DeleteOutlined /></template>
删除
{{ t('common.deleteText') }}
</a-button>
<a-button
type="dashed"
@@ -450,7 +465,7 @@ onMounted(() => {
v-perms:has="['system:log:login:remove']"
>
<template #icon><DeleteOutlined /></template>
清空
{{ t('views.system.log.operate.delAll') }}
</a-button>
<a-button
type="dashed"
@@ -458,7 +473,7 @@ onMounted(() => {
v-perms:has="['system:log:login:export']"
>
<template #icon><ExportOutlined /></template>
导出
{{ t('common.export') }}
</a-button>
</a-space>
</template>
@@ -467,31 +482,31 @@ onMounted(() => {
<template #extra>
<a-space :size="8" align="center">
<a-tooltip>
<template #title>搜索栏</template>
<template #title>{{ t('common.searchBarText') }}</template>
<a-switch
v-model:checked="tableState.seached"
checked-children=""
un-checked-children=""
:checked-children="t('common.switch.show')"
:un-checked-children="t('common.switch.hide')"
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>表格斑马纹</template>
<template #title>{{ t('common.zebra') }}</template>
<a-switch
v-model:checked="tableState.striped"
checked-children=""
un-checked-children=""
:checked-children="t('common.switch.show')"
:un-checked-children="t('common.switch.hide')"
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>刷新</template>
<template #title>{{ t('common.reloadText') }}</template>
<a-button type="text" @click.prevent="fnGetList()">
<template #icon><ReloadOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip placement="topRight">
<template #title>密度</template>
<template #title>{{ t('common.sizeText') }}</template>
<a-dropdown placement="bottomRight" trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
@@ -501,9 +516,15 @@ onMounted(() => {
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">默认</a-menu-item>
<a-menu-item key="middle">中等</a-menu-item>
<a-menu-item key="small">紧凑</a-menu-item>
<a-menu-item key="default"
>{{ t('common.size.default') }}
</a-menu-item>
<a-menu-item key="middle"
>{{ t('common.size.middle') }}
</a-menu-item>
<a-menu-item key="small"
>{{ t('common.size.small') }}
</a-menu-item>
</a-menu>
</template>
</a-dropdown>