update ruoyi-ui/src/utils/dict/Dict.js.

防止字典重复加载
This commit is contained in:
chf12mm 2022-01-12 02:46:35 +00:00 committed by Gitee
parent ec20194186
commit a6ef318fbb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -37,7 +37,7 @@ export default class Dict {
if (dictMeta.lazy) {
return
}
ps.push(loadDict(this, dictMeta))
ps.push(removal(this, dictMeta))
})
return Promise.all(ps)
}
@ -55,6 +55,26 @@ export default class Dict {
}
}
//过滤重复数据重复请求
function removal(dict, dictMeta) {
const type = dictMeta.type
let that = dict.owner;
let ld;
if(__dictCache.get(type)){
ld = __dictCache.get(type)
ld.then(dicts=>{
dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts)
dicts.forEach(d => {
Vue.set(dict.label[type], d.value, d.label)
})
})
}else{
ld = loadDict(dict, dictMeta);
__dictCache.set(type,ld)
}
return ld
}
/**
* 加载字典
* @param {Dict} dict 字典