From 75cfe2f8f77a641469d62c8bf8d3c6a00a5604f1 Mon Sep 17 00:00:00 2001 From: 若依 <yzz_ivy@163.com> Date: 星期六, 23 四月 2022 22:04:12 +0800 Subject: [PATCH] Merge pull request #48 from JavaLionLi/patch-1 --- src/utils/ruoyi.js | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/src/utils/ruoyi.js b/src/utils/ruoyi.js index 5d46531..a051e82 100644 --- a/src/utils/ruoyi.js +++ b/src/utils/ruoyi.js @@ -70,6 +70,9 @@ // 鍥炴樉鏁版嵁瀛楀吀 export function selectDictLabel(datas, value) { + if (value === undefined) { + return ""; + } var actions = []; Object.keys(datas).some((key) => { if (datas[key].value == ('' + value)) { @@ -77,23 +80,31 @@ return true; } }) + if (actions.length === 0) { + actions.push(value); + } return actions.join(''); } // 鍥炴樉鏁版嵁瀛楀吀锛堝瓧绗︿覆鏁扮粍锛� export function selectDictLabels(datas, value, separator) { - if(value === undefined) { + if (value === undefined) { return ""; } var actions = []; 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); } -- Gitblit v1.9.3