From b6163e1bed94b4d02d1b6f01fdc2eb3f15ca22e3 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 07 十月 2024 15:47:46 +0800 Subject: [PATCH] 保存默认工艺路线,工单批次优化 --- src/utils/is.ts | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/utils/is.ts b/src/utils/is.ts index 7080731..e134a8a 100644 --- a/src/utils/is.ts +++ b/src/utils/is.ts @@ -1,12 +1,11 @@ -import { isEmpty } from 'lodash-es'; /* * @Description: file content * @Author: your name * @version: * @Date: 2024-06-17 14:51:26 - * @LastEditors: your name - * @LastEditTime: 2024-06-17 15:43:58 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-08-28 21:38:19 */ export { isArguments, @@ -29,7 +28,6 @@ isMatchWith, isNative, isNil, - isNumber, isNull, isObjectLike, isPlainObject, @@ -81,6 +79,11 @@ return regex.test(str); } +export function isNumber(str: string): boolean{ + const regex = /^[0-9]*$/; + return regex.test(str); +} + export function isTimeViaRegExp8601(value: any): boolean { return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value.toString()); @@ -116,7 +119,23 @@ } export function isNullOrEmpty(val: unknown): val is null | undefined { - return isNullOrUnDef(val) || isEmpty(val); + return isNullOrUnDef(val) || isEmpty2(val); +} + +export function isEmpty2(value: any): boolean { + if (value === null || value === undefined) { + return true; + } + if (typeof value === 'string' && value.trim() === '') { + return true; + } + if (Array.isArray(value) && value.length === 0) { + return true; + } + if (typeof value === 'object' && value !== null && Object.keys(value).length === 0) { + return true; + } + return false; } -- Gitblit v1.9.3