From d0e888a5fe66705a7cd0dbc3ea3d92d017c279d9 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Wed, 9 Aug 2023 20:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90issues/668=E3=80=91JDictSelectUtil?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E5=B7=A5=E5=85=B7=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E7=9A=84getDictItems=E6=96=B9=E6=B3=95=E5=87=BA?= =?UTF-8?q?=E9=94=99=20---?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dict/JDictSelectUtil.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/dict/JDictSelectUtil.js b/src/utils/dict/JDictSelectUtil.js index 178369e..d9e5134 100644 --- a/src/utils/dict/JDictSelectUtil.js +++ b/src/utils/dict/JDictSelectUtil.js @@ -128,19 +128,20 @@ export function filterDictTextByCache(dictCode, key) { /** 通过code获取字典数组 */ export async function getDictItems(dictCode, params) { + // update-begin--author:liaozhiyang---date:20230809---for:【issues/668】JDictSelectUtil数据字典工具类中的getDictItems方法出错 //优先从缓存中读取字典配置 if (getDictItemsByCode(dictCode)) { let desformDictItems = getDictItemsByCode(dictCode).map((item) => ({ ...item, label: item.text, })); - return desformDictItems; + return Promise.resolve(desformDictItems); } //缓存中没有,就请求后台 return await ajaxGetDictItems(dictCode, params) - .then(({ success, result }) => { - if (success) { + .then((result) => { + if (result.length) { let res = result.map((item) => ({ ...item, label: item.text })); console.log('------- 从DB中获取到了字典-------dictCode : ', dictCode, res); return Promise.resolve(res); @@ -153,4 +154,5 @@ export async function getDictItems(dictCode, params) { console.error('getDictItems error: ', res); return Promise.resolve([]); }); + // update-end--author:liaozhiyang---date:20230809---for:【issues/668】JDictSelectUtil数据字典工具类中的getDictItems方法出错 }