feat(sj_1.0.0): transformRecordToNumberOption
This commit is contained in:
parent
19201310c9
commit
fe93afd252
@ -1,4 +1,4 @@
|
|||||||
import { transformRecordToOption } from '@/utils/common';
|
import { transformRecordToNumberOption, transformRecordToOption } from '@/utils/common';
|
||||||
|
|
||||||
export const yesOrNoRecord: Record<Api.Common.YesOrNo, App.I18n.I18nKey> = {
|
export const yesOrNoRecord: Record<Api.Common.YesOrNo, App.I18n.I18nKey> = {
|
||||||
'0': 'common.yesOrNo.no',
|
'0': 'common.yesOrNo.no',
|
||||||
@ -17,7 +17,7 @@ export const enableStatus01Record: Record<Api.Common.EnableStatus01, App.I18n.I1
|
|||||||
1: 'page.manage.common.status.disable'
|
1: 'page.manage.common.status.disable'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const enableStatus01Options = transformRecordToOption(enableStatus01Record);
|
export const enableStatus01Options = transformRecordToNumberOption(enableStatus01Record);
|
||||||
|
|
||||||
export const userGenderRecord: Record<Api.SystemManage.UserGender, App.I18n.I18nKey> = {
|
export const userGenderRecord: Record<Api.SystemManage.UserGender, App.I18n.I18nKey> = {
|
||||||
'1': 'page.manage.user.gender.male',
|
'1': 'page.manage.user.gender.male',
|
||||||
@ -45,11 +45,6 @@ export const podsType: Record<Api.Dashboard.DashboardPodsType, App.I18n.I18nKey>
|
|||||||
2: 'page.pods.type.server'
|
2: 'page.pods.type.server'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const idGeneratorModeRecord: Record<Api.GroupConfig.IdGeneratorModeType, App.I18n.I18nKey> = {
|
|
||||||
'1': 'page.groupConfig.idMode.segment',
|
|
||||||
'2': 'page.groupConfig.idMode.idWorker'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const alarmTypeRecord: Record<Api.NotifyRecipient.AlarmType, App.I18n.I18nKey> = {
|
export const alarmTypeRecord: Record<Api.NotifyRecipient.AlarmType, App.I18n.I18nKey> = {
|
||||||
1: 'page.notifyRecipient.dingDing',
|
1: 'page.notifyRecipient.dingDing',
|
||||||
2: 'page.notifyRecipient.email',
|
2: 'page.notifyRecipient.email',
|
||||||
@ -80,3 +75,21 @@ export const jobNotifyScene: Record<Api.NotifyConfig.JobNotifyScene, App.I18n.I1
|
|||||||
'1': 'page.notifyConfig.jobNotifyScene.jobTaskError'
|
'1': 'page.notifyConfig.jobNotifyScene.jobTaskError'
|
||||||
};
|
};
|
||||||
export const jobNotifySceneOptions = transformRecordToOption(jobNotifyScene);
|
export const jobNotifySceneOptions = transformRecordToOption(jobNotifyScene);
|
||||||
|
|
||||||
|
export const groupConfigStatusRecord: Record<Api.GroupConfig.GroupStatusType, App.I18n.I18nKey> = {
|
||||||
|
0: 'page.manage.common.status.disable',
|
||||||
|
1: 'page.manage.common.status.enable'
|
||||||
|
};
|
||||||
|
export const groupConfigStatusOptions = transformRecordToNumberOption(groupConfigStatusRecord);
|
||||||
|
|
||||||
|
export const groupConfigIdModeRecord: Record<Api.GroupConfig.IdGeneratorModeType, App.I18n.I18nKey> = {
|
||||||
|
1: 'page.groupConfig.idMode.segment',
|
||||||
|
2: 'page.groupConfig.idMode.idWorker'
|
||||||
|
};
|
||||||
|
export const groupConfigIdModeOptions = transformRecordToNumberOption(groupConfigIdModeRecord);
|
||||||
|
|
||||||
|
export const groupConfigYesOrNoRecord: Record<Api.GroupConfig.YesOrNoType, App.I18n.I18nKey> = {
|
||||||
|
0: 'common.yesOrNo.no',
|
||||||
|
1: 'common.yesOrNo.yes'
|
||||||
|
};
|
||||||
|
export const groupConfigYesOrNoOptions = transformRecordToNumberOption(groupConfigYesOrNoRecord);
|
||||||
|
@ -25,6 +25,18 @@ export function transformRecordToOption<T extends Record<string, string>>(record
|
|||||||
})) as CommonType.Option<keyof T>[];
|
})) as CommonType.Option<keyof T>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform record to option with keys of number
|
||||||
|
*
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
export function transformRecordToNumberOption<T extends Record<number, string>>(record: T) {
|
||||||
|
return Object.entries(record).map(([value, label]) => ({
|
||||||
|
value: Number(value),
|
||||||
|
label
|
||||||
|
})) as CommonType.Option<keyof T>[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate options
|
* Translate options
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user