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

feat: 登录日志基本完成

parent f7f7fddb
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="tw-text-right tw-mt-2"> <div class="tw-text-right tw-mt-2">
<a-space> <a-space>
<a-button @click="queryForm = {}">重置</a-button> <a-button @click="reset">重置</a-button>
<a-button type="primary" @click="getData">查询</a-button> <a-button type="primary" @click="getData">查询</a-button>
</a-space> </a-space>
</div> </div>
...@@ -23,7 +23,13 @@ ...@@ -23,7 +23,13 @@
</template> </template>
</a-space> </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 /> <slot />
</a-table> </a-table>
</div> </div>
...@@ -62,6 +68,11 @@ ...@@ -62,6 +68,11 @@
<script> <script>
import { request, METHOD } from '@/utils/requestUtil'; import { request, METHOD } from '@/utils/requestUtil';
const initQuery = {
pageSize: 10,
pageNum: 1,
};
export default { export default {
props: { props: {
url: String, url: String,
...@@ -76,11 +87,10 @@ export default { ...@@ -76,11 +87,10 @@ export default {
noPage: Boolean, noPage: Boolean,
}, },
data() { data() {
this.initQuery = {
pageNum: 1,
pageSize: 10,
};
return { return {
initQuery: {
...initQuery,
},
title: '新增', title: '新增',
data: [], data: [],
queryForm: {}, queryForm: {},
...@@ -99,6 +109,7 @@ export default { ...@@ -99,6 +109,7 @@ export default {
flexDirection: 'column', flexDirection: 'column',
}, },
noFooter: false, noFooter: false,
total: 0,
}; };
}, },
watch: { watch: {
...@@ -110,6 +121,18 @@ export default { ...@@ -110,6 +121,18 @@ export default {
this.getData(); this.getData();
}, },
computed: {
pagination() {
return this.noPage
? false
: {
current: this.initQuery.pageNum,
pageSize: this.initQuery.pageSize,
total: this.total,
};
},
},
methods: { methods: {
async getData() { async getData() {
this.loading = true; this.loading = true;
...@@ -128,6 +151,7 @@ export default { ...@@ -128,6 +151,7 @@ export default {
async getDataWithPage() { async getDataWithPage() {
const res = await request(this.url, METHOD.GET, { ...this.initQuery, ...this.queryForm }); const res = await request(this.url, METHOD.GET, { ...this.initQuery, ...this.queryForm });
this.total = res.total;
if (this.formatData) this.data = this.formatData(res); if (this.formatData) this.data = this.formatData(res);
else this.data = res.records; else this.data = res.records;
}, },
...@@ -165,6 +189,15 @@ export default { ...@@ -165,6 +189,15 @@ export default {
this.noFooter = noFooter; this.noFooter = noFooter;
this.addVisible = true; this.addVisible = true;
}, },
reset() {
this.queryForm = {};
this.initQuery = { ...initQuery };
this.getData();
},
pageChange(page) {
this.initQuery.pageNum = page.current;
this.getData();
},
}, },
}; };
</script> </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 = { ...@@ -100,7 +100,14 @@ const options = {
{ {
path: 'log_management', path: 'log_management',
name: '日志管理', 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', 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