From 260058da45b2fa9f5b5f970fdc5e711f4692c4ed Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sat, 20 Apr 2024 17:14:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(sj=5F1.0.0):=20transformRecordToNumberOpti?= =?UTF-8?q?on=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9key=E8=BF=9B=E8=A1=8C=E9=80=86=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constants/business.ts | 4 ++-- src/utils/common.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/constants/business.ts b/src/constants/business.ts index ccedcfa..9a22951 100644 --- a/src/constants/business.ts +++ b/src/constants/business.ts @@ -80,7 +80,7 @@ export const groupConfigStatusRecord: Record = { 1: 'page.groupConfig.idMode.segment', @@ -92,4 +92,4 @@ export const groupConfigYesOrNoRecord: Record>(record * * @param record */ -export function transformRecordToNumberOption>(record: T) { - return Object.entries(record).map(([value, label]) => ({ +export function transformRecordToNumberOption>(record: T, reverse: boolean = false) { + const options = Object.entries(record).map(([value, label]) => ({ value: Number(value), label })) as CommonType.Option[]; + + return reverse ? options.sort((a: any, b: any) => b.value - a.value) : options; } /**