refactor: 优化 queryForm 的 Query 类型使用

This commit is contained in:
2024-05-02 20:22:10 +08:00
parent 05ab89d03f
commit 5b71369251
22 changed files with 82 additions and 96 deletions

View File

@@ -4,7 +4,7 @@ import type * as Monitor from './type'
const BASE_URL = '/monitor/online'
/** @desc 查询在线用户列表 */
export function listOnlineUser(query: Monitor.OnlineUserQuery) {
export function listOnlineUser(query: Monitor.OnlineUserPageQuery) {
return http.get<PageRes<Monitor.OnlineUserResp[]>>(`${BASE_URL}`, query)
}

View File

@@ -13,10 +13,12 @@ export interface OnlineUserResp {
createUserString: string
createTime: string
}
export interface OnlineUserQuery extends PageQuery {
export interface OnlineUserQuery {
nickname?: string
loginTime?: string
sort: Array<string>
}
export interface OnlineUserPageQuery extends OnlineUserQuery, PageQuery {}
/** 系统日志类型 */
export interface LogResp {
@@ -52,4 +54,4 @@ export interface LogQuery {
status?: number
sort: Array<string>
}
export interface LogPageQuery extends PageQuery, LogQuery {}
export interface LogPageQuery extends LogQuery, PageQuery {}

View File

@@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/dict'
/** @desc 查询字典列表 */
export function listDict(query: System.DictQuery) {
export function listDict(query: System.DictPageQuery) {
return http.get<PageRes<System.DictResp[]>>(`${BASE_URL}`, query)
}
@@ -29,7 +29,7 @@ export function deleteDict(id: string) {
}
/** @desc 查询字典项列表 */
export function listDictItem(query: System.DictItemQuery) {
export function listDictItem(query: System.DictItemPageQuery) {
return http.get<PageRes<System.DictItemResp[]>>(`${BASE_URL}/item`, query)
}

View File

@@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/file'
/** @desc 查询文件列表 */
export function listFile(query: System.FileQuery) {
export function listFile(query: System.FilePageQuery) {
return http.get<PageRes<System.FileItem[]>>(`${BASE_URL}`, query)
}

View File

@@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/notice'
/** @desc 查询公告列表 */
export function listNotice(query: System.NoticeQuery) {
export function listNotice(query: System.NoticePageQuery) {
return http.get<PageRes<System.NoticeResp[]>>(`${BASE_URL}`, query)
}

View File

@@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/role'
/** @desc 查询角色列表 */
export function listRole(query: System.RoleQuery) {
export function listRole(query: System.RolePageQuery) {
return http.get<PageRes<System.RoleResp[]>>(`${BASE_URL}`, query)
}

View File

@@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/storage'
/** @desc 查询存储列表 */
export function listStorage(query: System.StorageQuery) {
export function listStorage(query: System.StoragePageQuery) {
return http.get<PageRes<System.StorageResp[]>>(`${BASE_URL}`, query)
}

View File

@@ -29,7 +29,7 @@ export interface UserQuery {
deptId?: string
sort: Array<string>
}
export interface UserPageQuery extends PageQuery, UserQuery {}
export interface UserPageQuery extends UserQuery, PageQuery {}
/** 系统角色类型 */
export interface RoleResp {
@@ -62,9 +62,11 @@ export interface RoleDetailResp {
updateTime: string
disabled: boolean
}
export interface RoleQuery extends PageQuery {
export interface RoleQuery {
description?: string
sort: Array<string>
}
export interface RolePageQuery extends RoleQuery, PageQuery {}
/** 系统菜单类型 */
export interface MenuResp {
@@ -116,25 +118,6 @@ export interface DeptQuery {
sort: Array<string>
}
/** 系统公告类型 */
export interface NoticeResp {
id: string
title: string
content: string
status: number
type: string
effectiveTime: string
terminateTime: string
createUserString: string
createTime: string
updateUserString: string
updateTime: string
}
export interface NoticeQuery extends PageQuery {
title?: string
type?: string
}
/** 系统字典类型 */
export interface DictResp {
id: string
@@ -147,9 +130,11 @@ export interface DictResp {
updateUserString: string
updateTime: string
}
export interface DictQuery extends PageQuery {
export interface DictQuery {
description?: string
sort: Array<string>
}
export interface DictPageQuery extends DictQuery, PageQuery {}
export type DictItemResp = {
id: string
label: string
@@ -164,11 +149,34 @@ export type DictItemResp = {
updateUserString: string
updateTime: string
}
export interface DictItemQuery extends PageQuery {
export interface DictItemQuery {
description?: string
status?: number
sort: Array<string>
dictId: string
}
export interface DictItemPageQuery extends DictItemQuery, PageQuery {}
/** 系统公告类型 */
export interface NoticeResp {
id: string
title: string
content: string
status: number
type: string
effectiveTime: string
terminateTime: string
createUserString: string
createTime: string
updateUserString: string
updateTime: string
}
export interface NoticeQuery {
title?: string
type?: string
sort: Array<string>
}
export interface NoticePageQuery extends NoticeQuery, PageQuery {}
/** 系统文件类型 */
export type FileItem = {
@@ -184,18 +192,19 @@ export type FileItem = {
updateUserString: string
updateTime: string
}
export interface FileQuery extends PageQuery {
name?: string
type?: string
}
/** 文件资源统计 */
/** 文件资源统计信息 */
export interface FileStatisticsResp {
type: string
size: number
formattedSize: string
number: number
data: Array<FileStatisticsResp>
}
export interface FileQuery {
name?: string
type?: string
sort: Array<string>
}
export interface FilePageQuery extends FileQuery, PageQuery {}
/** 系统存储类型 */
export type StorageResp = {
@@ -217,10 +226,12 @@ export type StorageResp = {
updateUserString: string
updateTime: string
}
export interface StorageQuery extends PageQuery {
export interface StorageQuery {
description?: string
status?: number
sort: Array<string>
}
export interface StoragePageQuery extends StorageQuery, PageQuery {}
/** 系统参数类型 */
export interface OptionResp {
@@ -232,7 +243,6 @@ export interface OptionResp {
export interface OptionQuery {
code: Array<string>
}
/** 基础配置类型 */
export interface BasicConfigResp {
site_favicon: string

1
src/types/api.d.ts vendored
View File

@@ -17,5 +17,4 @@ interface PageRes<T> {
interface PageQuery {
page: number
size: number
sort: Array<string>
}

View File

@@ -133,8 +133,11 @@ const onOauth = async (source: string) => {
&-logo {
width: 100%;
height: 104px;
font-weight: 700;
font-size: 20px;
line-height: 32px;
display: flex;
padding: 0px 20px;
padding: 0 20px;
align-items: center;
justify-content: start;
background-image: url('/src/assets/images/login_h5.jpg');
@@ -175,10 +178,7 @@ const onOauth = async (source: string) => {
}
:deep(.arco-tabs-tab) {
color: var(--color-text-2);
margin-right: 20px;
margin-top: 0px;
margin-left: 0px;
margin-bottom: 0px;
margin: 0 20px 0 0;
}
:deep(.arco-tabs-tab-title) {
font-size: 16px;

View File

@@ -45,7 +45,7 @@
</template>
<script setup lang="ts">
import { exportLoginLog, listLog } from '@/apis'
import { exportLoginLog, listLog, type LogQuery } from '@/apis'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
import { useTable, useDownload } from '@/hooks'
@@ -90,15 +90,12 @@ const columns: TableInstanceColumns[] = [
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
]
const queryForm = reactive({
const queryForm = reactive<LogQuery>({
module: '登录',
ip: undefined,
createUserString: undefined,
createTime: [
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
],
status: undefined,
sort: ['createTime,desc']
})

View File

@@ -56,7 +56,7 @@
</template>
<script setup lang="ts">
import { listLog, exportOperationLog, type LogResp } from '@/apis'
import { listLog, exportOperationLog, type LogResp, type LogQuery } from '@/apis'
import OperationLogDetailDrawer from './OperationLogDetailDrawer.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
@@ -102,15 +102,11 @@ const columns: TableInstanceColumns[] = [
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
]
const queryForm = reactive({
description: undefined,
ip: undefined,
createUserString: undefined,
const queryForm = reactive<LogQuery>({
createTime: [
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
],
status: undefined,
sort: ['createTime,desc']
})

View File

@@ -44,7 +44,7 @@
</template>
<script setup lang="ts">
import { listOnlineUser, kickout } from '@/apis'
import { listOnlineUser, kickout, type OnlineUserQuery } from '@/apis'
import { Message } from '@arco-design/web-vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
@@ -79,9 +79,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
nickname: undefined,
loginTime: undefined,
const queryForm = reactive<OnlineUserQuery>({
sort: ['createTime,desc']
})

View File

@@ -112,9 +112,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
description: undefined,
status: undefined,
const queryForm = reactive<DeptQuery>({
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
})

View File

@@ -52,7 +52,7 @@
</template>
<script setup lang="ts">
import { listDict, deleteDict, type DictResp } from '@/apis'
import { listDict, deleteDict, type DictResp, type DictQuery } from '@/apis'
import DictAddModal from './DictAddModal.vue'
import DictItemModal from '@/views/system/dict/item/index.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
@@ -87,8 +87,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
description: undefined,
const queryForm = reactive<DictQuery>({
sort: ['createTime,desc']
})

View File

@@ -63,7 +63,7 @@
</template>
<script lang="ts" setup>
import { listDictItem, deleteDictItem, type DictItemResp } from '@/apis'
import { listDictItem, deleteDictItem, type DictItemResp, type DictItemQuery } from '@/apis'
import DictItemAddModal from './DictItemAddModal.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useTable } from '@/hooks'
@@ -97,9 +97,7 @@ const columns: TableInstanceColumns[] = [
{ title: '操作', slotName: 'action', width: 130, align: 'center', fixed: !isMobile() ? 'right' : undefined }
]
const queryForm = reactive({
description: undefined,
status: undefined,
const queryForm = reactive<DictItemQuery>({
sort: ['createTime,desc']
})

View File

@@ -94,7 +94,7 @@
</template>
<script setup lang="ts">
import { listFile, uploadFile, deleteFile, type FileItem, type FileQuery } from '@/apis'
import { listFile, uploadFile, deleteFile, type FileItem, type FileQuery, type FilePageQuery } from '@/apis'
import { Message, Modal, type RequestOption } from '@arco-design/web-vue'
import FileGrid from './FileGrid.vue'
import {
@@ -108,6 +108,7 @@ import { ImageTypes } from '@/constant/file'
import { api as viewerApi } from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import { downloadByUrl } from '@/utils/downloadFile'
const FileList = defineAsyncComponent(() => import('./FileList.vue'))
onMounted(() => {
const fileMainDom = document.getElementById('fileMain')
@@ -138,7 +139,7 @@ const handleScroll = (event) => {
const route = useRoute()
const { mode, selectedFileIds, toggleMode, addSelectedFileItem } = useFileManage()
const queryForm = reactive({
const queryForm = reactive<FileQuery>({
name: undefined,
type: route.query.type?.toString() || undefined,
sort: ['updateTime,desc']
@@ -151,7 +152,7 @@ const fileList = ref<FileItem[]>([])
const isBatchMode = ref(false)
const loading = ref(false)
// 查询文件列表
const getFileList = async (query: FileQuery = { ...queryForm, page: pagination.page, size: pagination.size }) => {
const getFileList = async (query: FilePageQuery = { ...queryForm, page: pagination.page, size: pagination.size }) => {
try {
loading.value = true
isBatchMode.value = false

View File

@@ -129,9 +129,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
title: undefined,
status: undefined,
const queryForm = reactive<MenuQuery>({
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
})

View File

@@ -57,7 +57,7 @@
</div>
</template>
<script lang="ts" setup>
import { listNotice, deleteNotice, type NoticeResp } from '@/apis'
import { listNotice, deleteNotice, type NoticeResp, type NoticeQuery } from '@/apis'
import NoticeAddModal from './NoticeAddModal.vue'
import NoticeDetailModal from './NoticeDetailModal.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
@@ -94,9 +94,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
title: undefined,
type: undefined,
const queryForm = reactive<NoticeQuery>({
sort: ['createTime,desc']
})

View File

@@ -57,7 +57,7 @@
</template>
<script setup lang="ts">
import { listRole, deleteRole, type RoleResp } from '@/apis'
import { listRole, deleteRole, type RoleResp, type RoleQuery } from '@/apis'
import RoleAddModal from './RoleAddModal.vue'
import RoleDetailDrawer from './RoleDetailDrawer.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
@@ -97,8 +97,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
description: undefined,
const queryForm = reactive<RoleQuery>({
sort: ['createTime,desc']
})

View File

@@ -68,7 +68,7 @@
</template>
<script setup lang="ts">
import { listStorage, deleteStorage, type StorageResp } from '@/apis'
import { listStorage, deleteStorage, type StorageResp, type StorageQuery } from '@/apis'
import StorageAddModal from './StorageAddModal.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useTable } from '@/hooks'
@@ -111,9 +111,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
description: undefined,
status: undefined,
const queryForm = reactive<StorageQuery>({
sort: ['createTime,desc']
})

View File

@@ -107,7 +107,7 @@
</template>
<script setup lang="ts">
import { listUser, deleteUser, exportUser, type UserResp } from '@/apis'
import { listUser, deleteUser, exportUser, type UserResp, type UserQuery } from '@/apis'
import UserAddModal from './UserAddModal.vue'
import UserDetailDrawer from './UserDetailDrawer.vue'
import UserResetPwdModal from './UserResetPwdModal.vue'
@@ -121,12 +121,7 @@ import has from '@/utils/has'
import { DisEnableStatusList } from '@/constant/common'
defineOptions({ name: 'SystemUser' })
interface queryFormType {
description?: string
status?: number
deptId?: string
sort: ['createTime,desc']
}
const columns: TableInstanceColumns[] = [
{
title: '序号',
@@ -165,7 +160,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive<queryFormType>({
const queryForm = reactive<UserQuery>({
sort: ['createTime,desc']
})