Commit d8d636fdbdf79d17c459a00e9381be0bf6b17a86

Authored by fungleo
1 parent 8deacb70

优化 回显数据字典(字符串数组)JS 函数

Showing 1 changed file with 11 additions and 12 deletions
ruoyi-ui/src/utils/ruoyi.js
... ... @@ -78,18 +78,17 @@ export function selectDictLabel(datas, value) {
78 78 }
79 79  
80 80 // 回显数据字典(字符串数组)
81   -export function selectDictLabels(datas, value, separator) {
82   - var actions = [];
83   - var currentSeparator = undefined === separator ? "," : separator;
84   - var temp = value.split(currentSeparator);
85   - Object.keys(value.split(currentSeparator)).some((val) => {
86   - Object.keys(datas).some((key) => {
87   - if (datas[key].dictValue == ('' + temp[val])) {
88   - actions.push(datas[key].dictLabel + currentSeparator);
89   - }
90   - })
91   - })
92   - return actions.join('').substring(0, actions.join('').length - 1);
  81 +export function selectDictLabels (datas = {}, value = '', separator = ',') {
  82 + const actions = []
  83 + const temp = value.split(separator)
  84 + temp.forEach((_, index) => {
  85 + Object.keys(datas).forEach(key => {
  86 + if (datas[key].dictValue === temp[index].toString()) {
  87 + actions.push(datas[key].dictLabel)
  88 + }
  89 + })
  90 + })
  91 + return actions.join(separator)
93 92 }
94 93  
95 94 // 通用下载方法
... ...