From b262de72fb08ee06e6a85a6a73d7764b4183e299 Mon Sep 17 00:00:00 2001 From: valarchie <343928303@qq.com> Date: Fri, 14 Jul 2023 18:27:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E6=9E=84=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=E7=AE=80=E5=8C=96=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system.ts | 2 +- src/utils/common.ts | 55 ++++++++++++++++ src/views/system/notice/index.vue | 21 ++++--- src/views/system/notice/utils/hook.tsx | 87 +++++++++++--------------- types/index.d.ts | 7 ++- 5 files changed, 108 insertions(+), 64 deletions(-) create mode 100644 src/utils/common.ts diff --git a/src/api/system.ts b/src/api/system.ts index 37428b3..290a9f1 100644 --- a/src/api/system.ts +++ b/src/api/system.ts @@ -19,7 +19,7 @@ type ResultDept = { data?: Array; }; -interface SystemNoticeQuery extends BasePageQuery { +export interface SystemNoticeQuery extends BasePageQuery { noticeType: string; noticeTitle: string; creatorName: string; diff --git a/src/utils/common.ts b/src/utils/common.ts new file mode 100644 index 0000000..a90d719 --- /dev/null +++ b/src/utils/common.ts @@ -0,0 +1,55 @@ +import { PaginationProps } from "@pureadmin/table"; +import { Sort } from "element-plus"; + +export class CommonUtils { + static getBeginTimeSafely(timeRange: string[]): string { + if (timeRange == null) { + return undefined; + } + + if (timeRange.length <= 0) { + return undefined; + } + + if (timeRange[0] == null) { + return undefined; + } + + return timeRange[0]; + } + + static getEndTimeSafely(timeRange: string[]): string { + if (timeRange == null) { + return undefined; + } + + if (timeRange.length <= 1) { + return undefined; + } + + if (timeRange[1] == null) { + return undefined; + } + + return timeRange[1]; + } + + static fillPaginationParams( + baseQuery: BasePageQuery, + pagination: PaginationProps + ) { + baseQuery.pageNum = pagination.currentPage; + baseQuery.pageSize = pagination.pageSize; + } + + static fillSortParams(baseQuery: BasePageQuery, sort: Sort) { + if (sort == null) { + return; + } + baseQuery.orderColumn = sort.prop; + baseQuery.orderDirection = sort.order; + } + + // 私有构造函数,防止类被实例化 + private constructor() {} +} diff --git a/src/views/system/notice/index.vue b/src/views/system/notice/index.vue index e7a3cda..fda1047 100644 --- a/src/views/system/notice/index.vue +++ b/src/views/system/notice/index.vue @@ -13,7 +13,7 @@ import Refresh from "@iconify-icons/ep/refresh"; import AddFill from "@iconify-icons/ri/add-circle-line"; import { useUserStoreHook } from "@/store/modules/user"; -/** 组件name最好和菜单表中的router_name一致 */ +/** !!!重要!!! 组件name最好和菜单表中的router_name一致, copy的时候记得更改这个名字*/ defineOptions({ name: "SystemNotice" }); @@ -30,15 +30,13 @@ const { dataList, pagination, defaultSort, + multipleSelection, onSearch, resetForm, openDialog, handleDelete, - handleSizeChange, - handleCurrentChange, - handleSortChange, - handleSelectionChange, - handleBulkDelete + handleBulkDelete, + getNoticeList } = useNoticeHook(); @@ -121,6 +119,7 @@ const {