refactor: loginlog

pull/2/head
xingyu4j 2022-11-13 15:13:38 +08:00
parent 866247959e
commit 4a692ed28c
8 changed files with 56 additions and 34 deletions

View File

@ -1,8 +1,24 @@
import request from '@/config/axios'
import type { ErrorCodeVO } from './types'
export interface ErrorCodeVO {
id: number
type: number
applicationName: string
code: number
message: string
memo: string
createTime: string
}
export interface ErrorCodePageReqVO extends BasePage {
type?: number
applicationName?: string
code?: number
message?: string
createTime?: string[]
}
// 查询错误码列表
export const getErrorCodePageApi = (params) => {
export const getErrorCodePageApi = (params: ErrorCodePageReqVO) => {
return request.get({ url: '/system/error-code/page', params })
}
@ -26,6 +42,6 @@ export const deleteErrorCodeApi = (id: number) => {
return request.delete({ url: '/system/error-code/delete?id=' + id })
}
// 导出错误码
export const excelErrorCodeApi = (params) => {
export const excelErrorCodeApi = (params: ErrorCodePageReqVO) => {
return request.download({ url: '/system/error-code/export-excel', params })
}

View File

@ -1,9 +0,0 @@
export type ErrorCodeVO = {
id: number
type: number
applicationName: string
code: number
message: string
memo: string
createTime: string
}

View File

@ -12,11 +12,18 @@ export interface LoginLogVO {
createTime: string
}
export interface LoginLogReqVO extends BasePage {
userIp?: string
username?: string
status?: boolean
createTime?: string[]
}
// 查询登录日志列表
export const getLoginLogPageApi = (params) => {
export const getLoginLogPageApi = (params: LoginLogReqVO) => {
return request.get({ url: '/system/login-log/page', params })
}
// 导出登录日志
export const exportLoginLogApi = (params) => {
export const exportLoginLogApi = (params: LoginLogReqVO) => {
return request.download({ url: '/system/login-log/export', params })
}

View File

@ -34,7 +34,8 @@ const crudSchemas = reactive<VxeCrudSchema>({
},
{
title: '错误码错误提示',
field: 'message'
field: 'message',
isSearch: true
},
{
title: t('common.createTime'),

View File

@ -21,7 +21,7 @@
preIcon="ep:view"
:title="t('action.detail')"
v-hasPermi="['system:error-code:update']"
@click="handleDetail(row)"
@click="handleDetail(row.id)"
/>
<XTextButton
preIcon="ep:delete"
@ -64,7 +64,6 @@
<script setup lang="ts">
import { ref, unref } from 'vue'
import type { ErrorCodeVO } from '@/api/system/errorCode/types'
import { rules, allSchemas } from './errorCode.data'
import * as ErrorCodeApi from '@/api/system/errorCode'
import { useI18n } from '@/hooks/web/useI18n'
@ -83,7 +82,7 @@ const xGrid = ref<VxeGridInstance>() // grid Ref
const formRef = ref<FormExpose>() // Ref
const detailRef = ref() // Ref
const { gridOptions } = useVxeGrid<ErrorCodeVO>({
const { gridOptions } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
allSchemas: allSchemas,
getListApi: ErrorCodeApi.getErrorCodePageApi
})
@ -101,13 +100,6 @@ const handleCreate = () => {
unref(formRef)?.getElFormRef()?.resetFields()
}
//
const handleDetail = async (row: ErrorCodeVO) => {
//
detailRef.value = row
setDialogTile('detail')
}
//
const handleUpdate = async (rowId: number) => {
setDialogTile('update')
@ -116,6 +108,14 @@ const handleUpdate = async (rowId: number) => {
unref(formRef)?.setValues(res)
}
//
const handleDetail = async (rowId: number) => {
setDialogTile('detail')
//
const res = await ErrorCodeApi.getErrorCodeApi(rowId)
detailRef.value = res
}
//
const handleDelete = async (rowId: number) => {
message
@ -138,7 +138,7 @@ const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as ErrorCodeVO
const data = unref(formRef)?.formModel as ErrorCodeApi.ErrorCodeVO
if (actionType.value === 'create') {
await ErrorCodeApi.createErrorCodeApi(data)
message.success(t('common.createSuccess'))

View File

@ -4,7 +4,7 @@
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
<template #toolbar_buttons>
<XButton
type="primary"
type="warning"
preIcon="ep:download"
:title="t('action.export')"
@click="handleExport()"

View File

@ -13,8 +13,11 @@ const crudSchemas = reactive<VxeCrudSchema>({
{
title: '日志类型',
field: 'logType',
dictType: DICT_TYPE.SYSTEM_LOGIN_TYPE,
isSearch: true
dictType: DICT_TYPE.SYSTEM_LOGIN_TYPE
},
{
title: '用户类型',
field: 'userType'
},
{
title: '用户名称',
@ -27,20 +30,24 @@ const crudSchemas = reactive<VxeCrudSchema>({
isSearch: true
},
{
title: 'userAgent',
title: '浏览器',
field: 'userAgent'
},
{
title: '登陆结果',
field: 'result',
dictType: DICT_TYPE.SYSTEM_LOGIN_RESULT,
isSearch: true
dictType: DICT_TYPE.SYSTEM_LOGIN_RESULT
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
isForm: false
isForm: false,
search: {
itemRender: {
name: 'XDataTimePicker'
}
}
}
]
})

View File

@ -12,7 +12,7 @@
@click="handleCreate()"
/>
<XButton
type="primary"
type="warning"
preIcon="ep:download"
:title="t('action.export')"
v-hasPermi="['system:post:export']"