Commit 26dfee2ce8ac0112d698bffdb66c0e3ca5bf61d1
1 parent
503dd64e
彻底重写回显数据字典方法
Showing
2 changed files
with
11 additions
and
19 deletions
.gitignore
| @@ -37,7 +37,8 @@ nbdist/ | @@ -37,7 +37,8 @@ nbdist/ | ||
| 37 | # Others | 37 | # Others |
| 38 | *.log | 38 | *.log |
| 39 | *.xml.versionsBackup | 39 | *.xml.versionsBackup |
| 40 | +*.swp | ||
| 40 | 41 | ||
| 41 | !*/build/*.java | 42 | !*/build/*.java |
| 42 | !*/build/*.html | 43 | !*/build/*.html |
| 43 | -!*/build/*.xml | ||
| 44 | \ No newline at end of file | 44 | \ No newline at end of file |
| 45 | +!*/build/*.xml |
ruoyi-ui/src/utils/ruoyi.js
| @@ -63,29 +63,20 @@ export function addDateRange (params = {}, dateRange) { | @@ -63,29 +63,20 @@ export function addDateRange (params = {}, dateRange) { | ||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | // 回显数据字典 | 65 | // 回显数据字典 |
| 66 | -export function selectDictLabel(datas, value) { | ||
| 67 | - var actions = []; | ||
| 68 | - Object.keys(datas).some((key) => { | ||
| 69 | - if (datas[key].dictValue == ('' + value)) { | ||
| 70 | - actions.push(datas[key].dictLabel); | ||
| 71 | - return true; | ||
| 72 | - } | ||
| 73 | - }) | ||
| 74 | - return actions.join(''); | 66 | +export function selectDictLabel(datas = [], value = '') { |
| 67 | + if (!value) return '-'; | ||
| 68 | + const dataArr = datas.filter(item => item.dictValue === value.toString()); | ||
| 69 | + return dataArr.length ? dataArr[0].dictLabel : 'Error Dict'; | ||
| 75 | } | 70 | } |
| 76 | 71 | ||
| 77 | // 回显数据字典(字符串数组) | 72 | // 回显数据字典(字符串数组) |
| 78 | -export function selectDictLabels (datas = {}, value = '', separator = ',') { | ||
| 79 | - const actions = [] | ||
| 80 | - const temp = value.split(separator) | 73 | +export function selectDictLabels(datas = [], value = '', separator = ',') { |
| 74 | + const actions = []; | ||
| 75 | + const temp = value.split(separator).filter(item => item); | ||
| 81 | temp.forEach((_, index) => { | 76 | temp.forEach((_, index) => { |
| 82 | - Object.keys(datas).forEach(key => { | ||
| 83 | - if (datas[key].dictValue === temp[index].toString()) { | ||
| 84 | - actions.push(datas[key].dictLabel) | ||
| 85 | - } | ||
| 86 | - }) | 77 | + actions.push(selectDictLabel(datas, temp[index])); |
| 87 | }) | 78 | }) |
| 88 | - return actions.join(separator) | 79 | + return actions.join(separator); |
| 89 | } | 80 | } |
| 90 | 81 | ||
| 91 | // 通用下载方法 | 82 | // 通用下载方法 |