From 4a692ed28caf46b7b4ca9444342d97ccfb47167f Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Sun, 13 Nov 2022 15:13:38 +0800 Subject: [PATCH] refactor: loginlog --- .../src/api/system/errorCode/index.ts | 22 ++++++++++++++++--- .../src/api/system/errorCode/types.ts | 9 -------- .../src/api/system/loginLog/index.ts | 11 ++++++++-- .../views/system/errorCode/errorCode.data.ts | 3 ++- .../src/views/system/errorCode/index.vue | 22 +++++++++---------- .../src/views/system/loginlog/index.vue | 2 +- .../views/system/loginlog/loginLog.data.ts | 19 +++++++++++----- .../src/views/system/post/index.vue | 2 +- 8 files changed, 56 insertions(+), 34 deletions(-) delete mode 100644 yudao-ui-admin-vue3/src/api/system/errorCode/types.ts diff --git a/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts b/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts index da3a8e64d..f75dd3c23 100644 --- a/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/errorCode/index.ts @@ -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 }) } diff --git a/yudao-ui-admin-vue3/src/api/system/errorCode/types.ts b/yudao-ui-admin-vue3/src/api/system/errorCode/types.ts deleted file mode 100644 index de8423979..000000000 --- a/yudao-ui-admin-vue3/src/api/system/errorCode/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type ErrorCodeVO = { - id: number - type: number - applicationName: string - code: number - message: string - memo: string - createTime: string -} diff --git a/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts b/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts index 4ca31dc3b..621144c16 100644 --- a/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/loginLog/index.ts @@ -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 }) } diff --git a/yudao-ui-admin-vue3/src/views/system/errorCode/errorCode.data.ts b/yudao-ui-admin-vue3/src/views/system/errorCode/errorCode.data.ts index 92bcbebbd..5050f5493 100644 --- a/yudao-ui-admin-vue3/src/views/system/errorCode/errorCode.data.ts +++ b/yudao-ui-admin-vue3/src/views/system/errorCode/errorCode.data.ts @@ -34,7 +34,8 @@ const crudSchemas = reactive({ }, { title: '错误码错误提示', - field: 'message' + field: 'message', + isSearch: true }, { title: t('common.createTime'), diff --git a/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue b/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue index 437bab688..ae83747e2 100644 --- a/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue @@ -21,7 +21,7 @@ preIcon="ep:view" :title="t('action.detail')" v-hasPermi="['system:error-code:update']" - @click="handleDetail(row)" + @click="handleDetail(row.id)" /> 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() // grid Ref const formRef = ref() // 表单 Ref const detailRef = ref() // 详情 Ref -const { gridOptions } = useVxeGrid({ +const { gridOptions } = useVxeGrid({ 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')) diff --git a/yudao-ui-admin-vue3/src/views/system/loginlog/index.vue b/yudao-ui-admin-vue3/src/views/system/loginlog/index.vue index f131d0300..dc89857f0 100644 --- a/yudao-ui-admin-vue3/src/views/system/loginlog/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/loginlog/index.vue @@ -4,7 +4,7 @@