From 7076bb1ed67ea47eb59adb34312b048ac9bd948a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 24 Jul 2024 14:19:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E4=B8=80=E4=B8=8B=20integer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editorTable/excel/rule.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/editorTable/excel/rule.ts b/src/editorTable/excel/rule.ts index 15c33ee..cc36fdb 100644 --- a/src/editorTable/excel/rule.ts +++ b/src/editorTable/excel/rule.ts @@ -128,6 +128,12 @@ const as = { number: (defaultValue?: number) => { return new AsRule(parseFloat).default(defaultValue); }, + /** + * 将值视为整数 + */ + integer: (defaultValue?: number) => { + return new AsRule(parseInt).default(defaultValue); + }, /** * 将值视为字符串。 * @param value 值 @@ -176,6 +182,12 @@ const reader = { number: (title: string, defaultValue?: number) => { return new ReaderRule((row) => parseFloat(row[title])).default(defaultValue); }, + /** + * 将值视为整数。 + */ + integer: (title: string, defaultValue?: number) => { + return new ReaderRule((row) => parseInt(row[title])).default(defaultValue); + }, /** * 将值视为布尔值。 * @param title 列标题