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

This commit is contained in:
RuoYi 2022-02-23 16:55:09 +08:00
parent 4d8bd8805b
commit cb5a6d29e2

View File

@ -70,6 +70,9 @@ export function addDateRange(params, dateRange, propName) {
// 回显数据字典
export function selectDictLabel(datas, value) {
if (value === undefined) {
return "";
}
var actions = [];
Object.keys(datas).some((key) => {
if (datas[key].value == ('' + value)) {
@ -77,6 +80,9 @@ export function selectDictLabel(datas, value) {
return true;
}
})
if (actions.length === 0) {
actions.push(value);
}
return actions.join('');
}
@ -89,11 +95,16 @@ export function selectDictLabels(datas, value, separator) {
var currentSeparator = undefined === separator ? "," : separator;
var temp = value.split(currentSeparator);
Object.keys(value.split(currentSeparator)).some((val) => {
var match = false;
Object.keys(datas).some((key) => {
if (datas[key].value == ('' + temp[val])) {
actions.push(datas[key].label + currentSeparator);
match = true;
}
})
if (!match) {
actions.push(temp[val] + currentSeparator);
}
})
return actions.join('').substring(0, actions.join('').length - 1);
}