Commit f195c929 authored by 陈浩玮's avatar 陈浩玮

Merge branch 'master' into 'feature/chw'

# Conflicts:
#   src/components/table/index.vue
parents 38a398bb 67c2dcf2
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,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>
...@@ -25,7 +25,13 @@ ...@@ -25,7 +25,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: {},
...@@ -103,6 +113,7 @@ export default { ...@@ -103,6 +113,7 @@ export default {
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 20 }, wrapperCol: { span: 20 },
}, },
total: 0,
}; };
}, },
watch: { watch: {
...@@ -114,6 +125,18 @@ export default { ...@@ -114,6 +125,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;
...@@ -132,6 +155,7 @@ export default { ...@@ -132,6 +155,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;
}, },
...@@ -169,6 +193,15 @@ export default { ...@@ -169,6 +193,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>
...@@ -107,7 +107,14 @@ const options = { ...@@ -107,7 +107,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