Ver Fonte

低版本浏览器兼容

高雄 há 1 ano atrás
pai
commit
7aa3e3aa07
1 ficheiros alterados com 29 adições e 11 exclusões
  1. 29 11
      src/utils/globalMixins.js

+ 29 - 11
src/utils/globalMixins.js

@@ -39,11 +39,10 @@ export default {
       let item = this.dictionary.find(v => {
         return v.key === key
       })
-      console.log(item, 'item')
       if(item){
-        return item.value
+        return item.value;
       }
-      return null
+      return null;
     },
     /** 获取字典值
      * key: String 查询具体值
@@ -51,15 +50,34 @@ export default {
      * 组件页面中需要设置:mapGetters(['dictionary']']),
      * */
     getDictLabel(key, dictType) {
-      let item = this.dictionary.find(v => {
-        return v.key === dictType
-      })
-      let dictLabel = item.value.find(v => {
-        if (v.dictValue == key) {
-          return v.dictLabel
+      if(this.dictionary){
+        let item = this.dictionary.find(v => {
+          return v.key === dictType
+        })
+        if(item){
+          let val = item.value;
+          if(val){
+            let dictLabel = val.find(v => {
+              if (v.dictValue == key) {
+                return v.dictLabel
+              }
+            })
+            if(dictLabel){
+              return dictLabel.dictLabel
+            }else{
+              return null;
+            }
+          }else{
+            return null;
+          }
+
+        }else{
+          return null;
         }
-      })
-      return dictLabel.dictLabel
+
+      }
+      return null;
+
     },
     //时间范围模板:2020-01-01~2020-01-02
     rangDate(start, end, a) {