修复字典键值为bool类型和字符串类型时,下拉列表逻辑Bug,增加自动检测类型,不强制手动传入valueType

pull/45/head
zqx 2024-09-04 19:43:23 +08:00
parent 26df81a16f
commit 9cdc9cc4ad
1 changed files with 17 additions and 0 deletions

View File

@ -39,7 +39,24 @@ export function getDictOpts(dictType: string) {
return getDictDatas(dictType)
}
/**
*
* @param dictType
*/
function determineType(dictType) {
if (dictType === "true" || dictType === "false") {
return "boolean";
} else if (!isNaN(parseFloat(dictType)) && parseFloat(input).toString() === input) {
return "number";
} else {
return "string";
}
}
export function getDictOptions(dictType: string, valueType?: 'string' | 'number' | 'boolean') {
if(!valueType){
valueType = determineType(dictType);
}
const dictOption: DictDataType[] = []
const dictOptions: DictDataType[] = getDictDatas(dictType)
if (dictOptions && dictOptions.length > 0) {