彻底重写回显数据字典方法

master
fungleo 4 years ago
parent 503dd64e3f
commit 26dfee2ce8
  1. 3
      .gitignore
  2. 27
      ruoyi-ui/src/utils/ruoyi.js

3
.gitignore vendored

@ -37,7 +37,8 @@ nbdist/
# Others # Others
*.log *.log
*.xml.versionsBackup *.xml.versionsBackup
*.swp
!*/build/*.java !*/build/*.java
!*/build/*.html !*/build/*.html
!*/build/*.xml !*/build/*.xml

@ -63,29 +63,20 @@ export function addDateRange (params = {}, dateRange) {
} }
// 回显数据字典 // 回显数据字典
export function selectDictLabel(datas, value) { export function selectDictLabel(datas = [], value = '') {
var actions = []; if (!value) return '-';
Object.keys(datas).some((key) => { const dataArr = datas.filter(item => item.dictValue === value.toString());
if (datas[key].dictValue == ('' + value)) { return dataArr.length ? dataArr[0].dictLabel : 'Error Dict';
actions.push(datas[key].dictLabel);
return true;
}
})
return actions.join('');
} }
// 回显数据字典(字符串数组) // 回显数据字典(字符串数组)
export function selectDictLabels (datas = {}, value = '', separator = ',') { export function selectDictLabels(datas = [], value = '', separator = ',') {
const actions = [] const actions = [];
const temp = value.split(separator) const temp = value.split(separator).filter(item => item);
temp.forEach((_, index) => { temp.forEach((_, index) => {
Object.keys(datas).forEach(key => { actions.push(selectDictLabel(datas, temp[index]));
if (datas[key].dictValue === temp[index].toString()) {
actions.push(datas[key].dictLabel)
}
})
}) })
return actions.join(separator) return actions.join(separator);
} }
// 通用下载方法 // 通用下载方法

Loading…
Cancel
Save