🐛 修复 IDEA 在 v-for="dict in getIntDictOptions(...)" 时,el-optionkey 会告警的问题

This commit is contained in:
YunaiV 2023-12-03 09:52:13 +08:00
parent 3d2d48b601
commit aecc9bb8cb
37 changed files with 56 additions and 49 deletions

View File

@ -20,13 +20,20 @@ export interface DictDataType {
cssClass: string
}
export interface NumberDictDataType extends DictDataType {
value: number
}
export const getDictOptions = (dictType: string) => {
return dictStore.getDictByType(dictType) || []
}
export const getIntDictOptions = (dictType: string): DictDataType[] => {
const dictOption: DictDataType[] = []
export const getIntDictOptions = (dictType: string): NumberDictDataType[] => {
// 获得通用的 DictDataType 列表
const dictOptions: DictDataType[] = getDictOptions(dictType)
// 转换成 number 类型的 NumberDictDataType 类型
// why 需要特殊转换:避免 IDEA 在 v-for="dict in getIntDictOptions(...)" 时el-option 的 key 会告警
const dictOption: NumberDictDataType[] = []
dictOptions.forEach((dict: DictDataType) => {
dictOption.push({
...dict,

View File

@ -23,7 +23,7 @@
<el-radio-group v-model="formData.visible">
<el-radio
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
:key="dict.value"
:key="dict.value as string"
:label="dict.value"
>
{{ dict.label }}

View File

@ -44,7 +44,7 @@
<el-select v-model="formData.status" clearable placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -25,7 +25,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -21,7 +21,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -27,7 +27,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -30,7 +30,7 @@
<el-select v-model="queryParams.status" placeholder="数据状态" clearable class="!w-240px">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -35,7 +35,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -14,7 +14,7 @@
<el-select v-model="queryParams.type" placeholder="请选择错误码类型" clearable>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_ERROR_CODE_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
class="!w-240px"

View File

@ -29,7 +29,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -26,7 +26,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -28,7 +28,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -52,7 +52,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -19,7 +19,7 @@
>
<el-option
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -23,7 +23,7 @@
<el-select v-model="formData.type" placeholder="请选择类型">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -33,8 +33,8 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:label="dict.value as string"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>

View File

@ -19,8 +19,8 @@
<el-radio-group v-model="formData.userType">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value as number"
:label="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>

View File

@ -37,7 +37,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -26,7 +26,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -23,7 +23,7 @@
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -28,7 +28,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -37,7 +37,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_OPERATE_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -20,7 +20,7 @@
<el-select v-model="formData.status" clearable placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -28,7 +28,7 @@
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -14,7 +14,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -32,7 +32,7 @@
<el-select v-model="queryParams.status" clearable placeholder="请选择启用状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
class="!w-240px"

View File

@ -14,7 +14,7 @@
<el-select v-model="formData.code" clearable placeholder="请选择渠道编码">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -24,7 +24,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -21,7 +21,7 @@
<el-select v-model="queryParams.status" placeholder="请选择启用状态" clearable>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -24,7 +24,7 @@
<el-select v-model="formData.type" placeholder="请选择短信类型">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -43,8 +43,8 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:label="parseInt(dict.value as string)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>

View File

@ -19,7 +19,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -34,7 +34,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -14,7 +14,7 @@
<el-radio-group v-model="formData.socialType">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
@ -48,7 +48,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -28,7 +28,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -43,7 +43,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
@ -62,7 +62,7 @@
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -19,7 +19,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -61,7 +61,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -46,7 +46,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -44,7 +44,7 @@
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}

View File

@ -23,7 +23,7 @@
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -61,7 +61,7 @@
<el-select v-model="formData.sex" placeholder="请选择">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>

View File

@ -47,7 +47,7 @@
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value as number"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>