Sfoglia il codice sorgente

页面若未匹配到字典标签则返回原字典值

RuoYi 4 anni fa
parent
commit
6f3c3f1b7e
1 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 12 1
      ruoyi-ui/src/utils/ruoyi.js

+ 12 - 1
ruoyi-ui/src/utils/ruoyi.js

@@ -70,6 +70,9 @@ export function addDateRange(params, dateRange, propName) {
70 70
 
71 71
 // 回显数据字典 
72 72
 export function selectDictLabel(datas, value) {
73
+  if (value === undefined) {
74
+    return "";
75
+  }
73 76
   var actions = [];
74 77
   Object.keys(datas).some((key) => {
75 78
     if (datas[key].value == ('' + value)) {
@@ -77,23 +80,31 @@ export function selectDictLabel(datas, value) {
77 80
       return true;
78 81
     }
79 82
   })
83
+  if (actions.length === 0) {
84
+    actions.push(value);
85
+  }
80 86
   return actions.join('');
81 87
 }
82 88
 
83 89
 // 回显数据字典(字符串数组)
84 90
 export function selectDictLabels(datas, value, separator) {
85
-  if(value === undefined) {
91
+  if (value === undefined) {
86 92
     return "";
87 93
   }
88 94
   var actions = [];
89 95
   var currentSeparator = undefined === separator ? "," : separator;
90 96
   var temp = value.split(currentSeparator);
91 97
   Object.keys(value.split(currentSeparator)).some((val) => {
98
+    var match = false;
92 99
     Object.keys(datas).some((key) => {
93 100
       if (datas[key].value == ('' + temp[val])) {
94 101
         actions.push(datas[key].label + currentSeparator);
102
+        match = true;
95 103
       }
96 104
     })
105
+    if (!match) {
106
+      actions.push(temp[val] + currentSeparator);
107
+    }
97 108
   })
98 109
   return actions.join('').substring(0, actions.join('').length - 1);
99 110
 }