Procházet zdrojové kódy

add: 添加获取指定字典指定值对应的label数据

puhui999 před 2 roky
rodič
revize
7697e5c358
1 změnil soubory, kde provedl 10 přidání a 1 odebrání
  1. 10 1
      src/utils/dict.ts

+ 10 - 1
src/utils/dict.ts

@@ -69,7 +69,16 @@ export const getDictObj = (dictType: string, value: any) => {
     }
   })
 }
-
+export const getDictLabel = (dictType: string, value: any) => {
+  const dictOptions: DictDataType[] = getDictOptions(dictType)
+  const dictLabel = ref('')
+  dictOptions.forEach((dict: DictDataType) => {
+    if (dict.value === value) {
+      dictLabel.value = dict.label
+    }
+  })
+  return dictLabel.value
+}
 export enum DICT_TYPE {
   USER_TYPE = 'user_type',
   COMMON_STATUS = 'common_status',