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

This commit is contained in:
tangliu 2021-03-15 12:14:34 +08:00
parent c10c3966fb
commit c48c76754a
1 changed files with 28 additions and 6 deletions

View File

@ -497,8 +497,15 @@ var table = {
}, },
// 回显数据字典 // 回显数据字典
selectDictLabel: function(datas, value) { selectDictLabel: function(datas, value) {
if ($.common.isEmpty(datas) || $.common.isEmpty(value)) { if ($.common.isEmpty(value)) {
return ''; return ''
}
if ($.common.isEmpty(datas)) {
if($.common.isEmpty(value)){
return ''
}else{
return value
}
} }
var actions = []; var actions = [];
$.each(datas, function(index, dict) { $.each(datas, function(index, dict) {
@ -508,23 +515,38 @@ var table = {
return false; return false;
} }
}); });
if (actions.length === 0) {
actions.push($.common.sprintf("<span class=''>%s</span>", value))
}
return actions.join(''); return actions.join('');
}, },
// 回显数据字典(字符串数组) // 回显数据字典(字符串数组)
selectDictLabels: function(datas, value, separator) { selectDictLabels: function(datas, value, separator) {
if ($.common.isEmpty(datas) || $.common.isEmpty(value)) { if ($.common.isEmpty(value)) {
return ''; return ''
}
if ($.common.isEmpty(datas)) {
if($.common.isEmpty(value)){
return ''
}else{
return value
}
} }
var currentSeparator = $.common.isEmpty(separator) ? "," : separator; var currentSeparator = $.common.isEmpty(separator) ? "," : separator;
var actions = []; var actions = [];
$.each(value.split(currentSeparator), function(i, val) { $.each(value.split(currentSeparator), function(i, val) {
var match = false
$.each(datas, function(index, dict) { $.each(datas, function(index, dict) {
if (dict.dictValue == ('' + val)) { if (dict.dictValue == ('' + val)) {
var listClass = $.common.equals("default", dict.listClass) || $.common.isEmpty(dict.listClass) ? "" : "badge badge-" + dict.listClass; var listClass = $.common.equals("default", dict.listClass) || $.common.isEmpty(dict.listClass) ? "" : "badge badge-" + dict.listClass;
actions.push($.common.sprintf("<span class='%s'>%s </span>", listClass, dict.dictLabel)); actions.push($.common.sprintf("<span class='%s'>%s </span>", listClass, dict.dictLabel));
match = true
return false; return false;
} }
}); });
if (!match) {
actions.push($.common.sprintf("<span class=''>%s </span>", val));
}
}); });
return actions.join(''); return actions.join('');
}, },