Commit c479bc48 authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 登录日志基本完成

parent f7f7fddb
......@@ -7,7 +7,7 @@
<div class="tw-text-right tw-mt-2">
<a-space>
<a-button @click="queryForm = {}">重置</a-button>
<a-button @click="reset">重置</a-button>
<a-button type="primary" @click="getData">查询</a-button>
</a-space>
</div>
......@@ -23,7 +23,13 @@
</template>
</a-space>
<a-table :data-source="data" :loading="loading" v-bind="$attrs" :pagination="!noPage">
<a-table
:data-source="data"
:loading="loading"
v-bind="$attrs"
:pagination="pagination"
@change="pageChange"
>
<slot />
</a-table>
</div>
......@@ -62,6 +68,11 @@
<script>
import { request, METHOD } from '@/utils/requestUtil';
const initQuery = {
pageSize: 10,
pageNum: 1,
};
export default {
props: {
url: String,
......@@ -76,11 +87,10 @@ export default {
noPage: Boolean,
},
data() {
this.initQuery = {
pageNum: 1,
pageSize: 10,
};
return {
initQuery: {
...initQuery,
},
title: '新增',
data: [],
queryForm: {},
......@@ -99,6 +109,7 @@ export default {
flexDirection: 'column',
},
noFooter: false,
total: 0,
};
},
watch: {
......@@ -110,6 +121,18 @@ export default {
this.getData();
},
computed: {
pagination() {
return this.noPage
? false
: {
current: this.initQuery.pageNum,
pageSize: this.initQuery.pageSize,
total: this.total,
};
},
},
methods: {
async getData() {
this.loading = true;
......@@ -128,6 +151,7 @@ export default {
async getDataWithPage() {
const res = await request(this.url, METHOD.GET, { ...this.initQuery, ...this.queryForm });
this.total = res.total;
if (this.formatData) this.data = this.formatData(res);
else this.data = res.records;
},
......@@ -165,6 +189,15 @@ export default {
this.noFooter = noFooter;
this.addVisible = true;
},
reset() {
this.queryForm = {};
this.initQuery = { ...initQuery };
this.getData();
},
pageChange(page) {
this.initQuery.pageNum = page.current;
this.getData();
},
},
};
</script>
......
<template>
<h1>Form</h1>
</template>
<template>
<my-table url="/api/v1/logger/login" rowKey="logId" ref="table">
<template #search="{query}">
<a-form-model-item label="登录IP">
<a-input v-model="query.loginIp" />
</a-form-model-item>
</template>
<a-table-column title="登录用户" data-index="userName" />
<a-table-column title="登录IP" data-index="loginIp" />
<a-table-column title="事件类型" data-index="loginTypeName" />
<a-table-column title="事件状态" data-index="isSuccessName" />
<a-table-column title="登录时间" data-index="loginTime" />
<a-table-column title="说明" data-index="logResultContent" />
</my-table>
</template>
<script>
export default {
data() {
return {};
},
methods: {
refreshTable() {
this.$refs.table.getData();
},
showDrawer(type, noFooter) {
this.$refs['table'].show({ type, noFooter });
},
},
};
</script>
......@@ -100,7 +100,14 @@ const options = {
{
path: 'log_management',
name: '日志管理',
component: () => import('@/pages/system/view/log'),
component: BlankTemplateView,
children: [
{
path: 'login_log',
name: '登录日志',
component: () => import('@/pages/system/view/log/login_log/index.vue'),
},
],
},
{
path: 'task_management',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment