Pre Merge pull request !46 from kuxiao/master

pull/46/MERGE
kuxiao 2024-09-04 14:14:02 +00:00 committed by Gitee
commit 85303c8957
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 16 additions and 1 deletions

View File

@ -38,11 +38,26 @@ 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(dictType).toString() === dictType) {
return "number";
} else {
return "string";
}
}
export function getDictOptions(dictType: string, valueType?: 'string' | 'number' | 'boolean') {
const dictOption: DictDataType[] = []
const dictOptions: DictDataType[] = getDictDatas(dictType)
if (dictOptions && dictOptions.length > 0) {
if(!valueType){
valueType = determineType(dictOptions[0].value);
}
dictOptions.forEach((dict: DictDataType) => {
dictOption.push({
...dict,