mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-12-16 07:10:34 +08:00
fix: 重构通知列表 简化写法
This commit is contained in:
55
src/utils/common.ts
Normal file
55
src/utils/common.ts
Normal file
@@ -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() {}
|
||||
}
|
||||
Reference in New Issue
Block a user