zayac-admin/continew-admin-ui/src/views/monitor/log/login/index.vue
Charles7c 405c821e2a 重构:🔥 基于阿里巴巴 Java 开发手册(黄山版)重构各表基本结构(简化列名)
1.MySQL数据库>建表规约>第9条:
【强制】表必备三字段:id,create_time,update_time。
说明:其中 id 必为主键,类型为 bigint unsigned、单表时自增、步长为 1。create_time,update_time 的类型均为datetime 类型,如果要记录时区信息,那么类型设置为 timestamp。
个人理解:简化列名的目的是为了后续能抽取更多公共能力
2.MySQL数据库>SQL语句>第10条:
【推荐】SQL 语句中表的别名前加 as,并且以 t1、t2、t3、...的顺序依次命名。
说明:
  1)别名可以是表的简称,或者是依照表在 SQL 语句中出现的顺序,以 t1、t2、t3 的方式命名。
  2)别名前加 as 使别名更容易识别。
正例:select t1.name from first_table as t1 , second_table as t2 where t1.id = t2.id;
2023-03-06 00:09:11 +08:00

170 lines
4.6 KiB
Vue

<template>
<div class="app-container">
<Breadcrumb :items="['menu.monitor', 'menu.log.login.list']" />
<a-card class="general-card" :title="$t('menu.log.login.list')">
<!-- 头部区域 -->
<div class="header">
<!-- 搜索栏 -->
<div class="header-query">
<a-form ref="queryRef" :model="queryParams" layout="inline">
<a-form-item field="status" hide-label>
<a-select
v-model="queryParams.status"
:options="SuccessFailureStatusEnum"
placeholder="登录状态搜索"
allow-clear
style="width: 150px"
/>
</a-form-item>
<a-form-item field="createTime" hide-label>
<date-range-picker v-model="queryParams.createTime" />
</a-form-item>
<a-form-item hide-label>
<a-space>
<a-button type="primary" @click="handleQuery">
<template #icon><icon-search /></template>查询
</a-button>
<a-button @click="resetQuery">
<template #icon><icon-refresh /></template>重置
</a-button>
</a-space>
</a-form-item>
</a-form>
</div>
</div>
<!-- 列表区域 -->
<a-table
ref="tableRef"
row-key="id"
:loading="loading"
:pagination="{
showTotal: true,
showPageSize: true,
total: total,
current: queryParams.page,
}"
:data="loginLogList"
:bordered="false"
:stripe="true"
size="large"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
>
<template #columns>
<a-table-column title="序号">
<template #cell="{ rowIndex }">
{{ rowIndex + 1 + (queryParams.page - 1) * queryParams.size }}
</template>
</a-table-column>
<a-table-column title="用户昵称" data-index="createUserString" />
<a-table-column title="登录行为" data-index="description" />
<a-table-column title="登录状态" align="center">
<template #cell="{ record }">
<a-tag v-if="record.status === 1" color="green"><span class="circle pass" />成功</a-tag>
<a-tooltip v-else :content="record.errorMsg">
<a-tag color="red" style="cursor: pointer">
<span class="circle fail" />失败
</a-tag>
</a-tooltip>
</template>
</a-table-column>
<a-table-column title="登录 IP" data-index="clientIp" />
<a-table-column title="登录地点" data-index="location" />
<a-table-column title="浏览器" data-index="browser" />
<a-table-column title="登录时间" data-index="createTime" />
</template>
</a-table>
</a-card>
</div>
</template>
<script lang="ts" setup>
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
import {
LoginLogParam,
LoginLogRecord,
listLoginLog,
} from '@/api/monitor/log';
const { proxy } = getCurrentInstance() as any;
const { SuccessFailureStatusEnum } = proxy.useDict('SuccessFailureStatusEnum');
const loginLogList = ref<LoginLogRecord[]>([]);
const total = ref(0);
const loading = ref(false);
const data = reactive({
// 查询参数
queryParams: {
status: undefined,
createTime: undefined,
page: 1,
size: 10,
sort: ['createTime,desc'],
},
});
const { queryParams } = toRefs(data);
/**
* 查询列表
*
* @param params 查询参数
*/
const getList = (params: LoginLogParam = { ...queryParams.value }) => {
loading.value = true;
listLoginLog(params)
.then((res) => {
loginLogList.value = res.data.list;
total.value = res.data.total;
})
.finally(() => {
loading.value = false;
});
};
getList();
/**
* 查询
*/
const handleQuery = () => {
getList();
};
/**
* 重置
*/
const resetQuery = () => {
proxy.$refs.queryRef.resetFields();
handleQuery();
};
/**
* 切换页码
*
* @param current 页码
*/
const handlePageChange = (current: number) => {
queryParams.value.page = current;
getList();
};
/**
* 切换每页条数
*
* @param pageSize 每页条数
*/
const handlePageSizeChange = (pageSize: number) => {
queryParams.value.size = pageSize;
getList();
};
</script>
<script lang="ts">
export default {
name: 'LoginLog',
};
</script>
<style scoped lang="less"></style>