Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDictSelectUtil数据字典工具类中的getDictItems方法出错 #668

Closed
q060831 opened this issue Aug 1, 2023 · 1 comment
Closed

Comments

@q060831
Copy link

q060831 commented Aug 1, 2023

版本号:3.5.3
问题描述:
src/utils/dict/JDictSelectUtil.js中的getDictItems方法出错
缓存中没有,就请求后台时,ajaxGetDictItems接口返回数据是处理后的,单是接收的参数却用没处理前的返回结果

截图&代码:

/** 通过code获取字典数组 */
export async function getDictItems(dictCode, params) {
  //优先从缓存中读取字典配置
  if (getDictItemsByCode(dictCode)) {
    let desformDictItems = getDictItemsByCode(dictCode).map((item) => ({
      ...item,
      label: item.text,
    }));
    return desformDictItems;
  }

  //缓存中没有,就请求后台
 // ajaxGetDictItems没有设置不处理返回结果,所以then里的参数应该只有result
  return await ajaxGetDictItems(dictCode, params)
    .then(({ success, result }) => {
      if (success) {
        let res = result.map((item) => ({ ...item, label: item.text }));
        console.log('------- 从DB中获取到了字典-------dictCode : ', dictCode, res);
        return Promise.resolve(res);
      } else {
        console.error('getDictItems error: : ', res);
        return Promise.resolve([]);
      }
    })
    .catch((res) => {
      console.error('getDictItems error: ', res);
      return Promise.resolve([]);
    });
}

@liaozhiyang
Copy link

已经修复,下一版本发布。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants