Skip to content

Commit 210c4d4

Browse files
YunaiVgitee-org
authored andcommitted
!453 fix: Add StringDictDataType type by imitating getIntDictOptions
Merge pull request !453 from AhJindeg/hotfix/dict
2 parents 33366ef + a9082d8 commit 210c4d4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/utils/dict.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export interface NumberDictDataType extends DictDataType {
2424
value: number
2525
}
2626

27+
export interface StringDictDataType extends DictDataType {
28+
value: string
29+
}
30+
2731
export const getDictOptions = (dictType: string) => {
2832
return dictStore.getDictByType(dictType) || []
2933
}
@@ -44,8 +48,11 @@ export const getIntDictOptions = (dictType: string): NumberDictDataType[] => {
4448
}
4549

4650
export const getStrDictOptions = (dictType: string) => {
47-
const dictOption: DictDataType[] = []
51+
// 获得通用的 DictDataType 列表
4852
const dictOptions: DictDataType[] = getDictOptions(dictType)
53+
// 转换成 string 类型的 StringDictDataType 类型
54+
// why 需要特殊转换:避免 IDEA 在 v-for="dict in getStrDictOptions(...)" 时,el-option 的 key 会告警
55+
const dictOption: StringDictDataType[] = []
4956
dictOptions.forEach((dict: DictDataType) => {
5057
dictOption.push({
5158
...dict,

0 commit comments

Comments
 (0)