From d8d636fdbdf79d17c459a00e9381be0bf6b17a86 Mon Sep 17 00:00:00 2001
From: fungleo <web@fengcms.com>
Date: 星期二, 04 八月 2020 11:39:43 +0800
Subject: [PATCH] 优化 回显数据字典(字符串数组)JS 函数
---
ruoyi-ui/src/utils/ruoyi.js | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js
index 23879aa..08fbd9d 100644
--- a/ruoyi-ui/src/utils/ruoyi.js
+++ b/ruoyi-ui/src/utils/ruoyi.js
@@ -78,18 +78,17 @@
}
// 鍥炴樉鏁版嵁瀛楀吀锛堝瓧绗︿覆鏁扮粍锛�
-export function selectDictLabels(datas, value, separator) {
- var actions = [];
- var currentSeparator = undefined === separator ? "," : separator;
- var temp = value.split(currentSeparator);
- Object.keys(value.split(currentSeparator)).some((val) => {
- Object.keys(datas).some((key) => {
- if (datas[key].dictValue == ('' + temp[val])) {
- actions.push(datas[key].dictLabel + currentSeparator);
- }
- })
- })
- return actions.join('').substring(0, actions.join('').length - 1);
+export function selectDictLabels (datas = {}, value = '', separator = ',') {
+ const actions = []
+ const temp = value.split(separator)
+ temp.forEach((_, index) => {
+ Object.keys(datas).forEach(key => {
+ if (datas[key].dictValue === temp[index].toString()) {
+ actions.push(datas[key].dictLabel)
+ }
+ })
+ })
+ return actions.join(separator)
}
// 閫氱敤涓嬭浇鏂规硶
--
Gitblit v1.9.3