Browse Source

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

YunaiV 1 year ago
parent
commit
aecc9bb8cb
37 changed files with 56 additions and 49 deletions
  1. 9 2
      src/utils/dict.ts
  2. 1 1
      src/views/infra/config/ConfigForm.vue
  3. 1 1
      src/views/system/dept/DeptForm.vue
  4. 1 1
      src/views/system/dept/index.vue
  5. 1 1
      src/views/system/dict/DictTypeForm.vue
  6. 1 1
      src/views/system/dict/data/DictDataForm.vue
  7. 1 1
      src/views/system/dict/data/index.vue
  8. 1 1
      src/views/system/dict/index.vue
  9. 1 1
      src/views/system/errorCode/index.vue
  10. 1 1
      src/views/system/menu/index.vue
  11. 1 1
      src/views/system/notice/index.vue
  12. 2 2
      src/views/system/notify/message/index.vue
  13. 1 1
      src/views/system/notify/my/index.vue
  14. 3 3
      src/views/system/notify/template/NotifyTemplateForm.vue
  15. 2 2
      src/views/system/notify/template/NotifyTemplateSendForm.vue
  16. 1 1
      src/views/system/notify/template/index.vue
  17. 1 1
      src/views/system/oauth2/client/ClientForm.vue
  18. 1 1
      src/views/system/oauth2/client/index.vue
  19. 1 1
      src/views/system/oauth2/token/index.vue
  20. 1 1
      src/views/system/operatelog/index.vue
  21. 1 1
      src/views/system/post/PostForm.vue
  22. 1 1
      src/views/system/post/index.vue
  23. 1 1
      src/views/system/sensitiveWord/SensitiveWordForm.vue
  24. 1 1
      src/views/system/sensitiveWord/index.vue
  25. 2 2
      src/views/system/sms/channel/SmsChannelForm.vue
  26. 1 1
      src/views/system/sms/channel/index.vue
  27. 3 3
      src/views/system/sms/template/SmsTemplateForm.vue
  28. 2 2
      src/views/system/sms/template/index.vue
  29. 2 2
      src/views/system/social/client/SocialClientForm.vue
  30. 3 3
      src/views/system/social/client/index.vue
  31. 1 1
      src/views/system/social/user/index.vue
  32. 1 1
      src/views/system/tenant/TenantForm.vue
  33. 1 1
      src/views/system/tenant/index.vue
  34. 1 1
      src/views/system/tenantPackage/TenantPackageForm.vue
  35. 1 1
      src/views/system/tenantPackage/index.vue
  36. 1 1
      src/views/system/user/UserForm.vue
  37. 1 1
      src/views/system/user/index.vue

+ 9 - 2
src/utils/dict.ts

@@ -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,

+ 1 - 1
src/views/infra/config/ConfigForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/dept/DeptForm.vue

@@ -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"
           />

+ 1 - 1
src/views/system/dept/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/dict/DictTypeForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/dict/data/DictDataForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/dict/data/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/dict/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/errorCode/index.vue

@@ -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"

+ 1 - 1
src/views/system/menu/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/notice/index.vue

@@ -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"
           />

+ 2 - 2
src/views/system/notify/message/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/notify/my/index.vue

@@ -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"
           />

+ 3 - 3
src/views/system/notify/template/NotifyTemplateForm.vue

@@ -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>

+ 2 - 2
src/views/system/notify/template/NotifyTemplateSendForm.vue

@@ -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>

+ 1 - 1
src/views/system/notify/template/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/oauth2/client/ClientForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/oauth2/client/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/oauth2/token/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/operatelog/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/post/PostForm.vue

@@ -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"
           />

+ 1 - 1
src/views/system/post/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/sensitiveWord/SensitiveWordForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/sensitiveWord/index.vue

@@ -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"

+ 2 - 2
src/views/system/sms/channel/SmsChannelForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/sms/channel/index.vue

@@ -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"
           />

+ 3 - 3
src/views/system/sms/template/SmsTemplateForm.vue

@@ -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>

+ 2 - 2
src/views/system/sms/template/index.vue

@@ -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"
           />

+ 2 - 2
src/views/system/social/client/SocialClientForm.vue

@@ -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 }}

+ 3 - 3
src/views/system/social/client/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/social/user/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/tenant/TenantForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/tenant/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/tenantPackage/TenantPackageForm.vue

@@ -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 }}

+ 1 - 1
src/views/system/tenantPackage/index.vue

@@ -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"
           />

+ 1 - 1
src/views/system/user/UserForm.vue

@@ -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"
               />

+ 1 - 1
src/views/system/user/index.vue

@@ -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"
               />