You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.8 KiB

2 years ago
<template>
2 years ago
<ContentWrap>
2 years ago
<!-- 搜索工作栏 -->
2 years ago
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
2 years ago
<el-form-item label="用户名称" prop="username">
2 years ago
<el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable @keyup.enter="handleQuery"
class="!w-240px" />
2 years ago
</el-form-item>
2 years ago
<el-form-item label="登录地址" prop="userIp">
2 years ago
<el-input v-model="queryParams.userIp" placeholder="请输入登录地址" clearable @keyup.enter="handleQuery"
class="!w-240px" />
2 years ago
</el-form-item>
2 years ago
<el-form-item label="登录日期" prop="createTime">
2 years ago
<el-date-picker v-model="queryParams.createTime" value-format="YYYY-MM-DD HH:mm:ss" type="daterange"
start-placeholder="开始日期" end-placeholder="结束日期" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px" />
2 years ago
</el-form-item>
<el-form-item>
2 years ago
<el-button type="info" plain @click="handleQuery">
<Icon icon="ep:search" class="mr-5px" /> 搜索
</el-button>
<el-button type="info" plain @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" /> 重置
</el-button>
<el-button type="success" @click="handleExport" :loading="exportLoading" v-hasPermi="['infra:config:export']">
2 years ago
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
2 years ago
</el-form-item>
</el-form>
2 years ago
</ContentWrap>
2 years ago
2 years ago
<!-- 列表 -->
<ContentWrap>
2 years ago
<el-table v-loading="loading" :data="list">
2 years ago
<el-table-column label="日志编号" align="center" prop="id" />
<el-table-column label="操作类型" align="center" prop="logType">
<template #default="scope">
2 years ago
<dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="scope.row.logType" />
</template>
</el-table-column>
2 years ago
<el-table-column label="用户名称" align="center" prop="username" width="180" />
<el-table-column label="登录地址" align="center" prop="userIp" width="180" />
<el-table-column label="浏览器" align="center" prop="userAgent" />
<el-table-column label="登陆结果" align="center" prop="result">
<template #default="scope">
2 years ago
<dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="scope.row.result" />
</template>
</el-table-column>
2 years ago
<el-table-column label="登录日期" align="center" prop="createTime" width="180" :formatter="dateFormatter" />
<el-table-column label="操作" align="center" fixed="right" width="120">
2 years ago
<template #default="scope">
2 years ago
<el-button link type="primary" @click="openDetail(scope.row)" v-hasPermi="['infra:config:query']">
<Icon icon="ep:document-copy" />
2 years ago
详情
</el-button>
2 years ago
</template>
</el-table-column>
</el-table>
2 years ago
<!-- 分页 -->
2 years ago
<Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
@pagination="getList" />
2 years ago
</ContentWrap>
2 years ago
2 years ago
<!-- 表单弹窗详情 -->
<LoginLogDetail ref="detailRef" />
2 years ago
</template>
2 years ago
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as LoginLogApi from '@/api/system/loginLog'
import LoginLogDetail from './LoginLogDetail.vue'
2 years ago
2 years ago
defineOptions({ name: 'SystemLoginLog' })
2 years ago
2 years ago
const message = useMessage() // 消息弹窗
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
username: undefined,
userIp: undefined,
createTime: []
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await LoginLogApi.getLoginLogPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
2 years ago
}
2 years ago
}
2 years ago
2 years ago
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (data: LoginLogApi.LoginLogVO) => {
detailRef.value.open(data)
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await LoginLogApi.exportLoginLog(queryParams)
download.excel(data, '登录日志.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>