From a6ef318fbb653fae50b5f008da8d6743a3547387 Mon Sep 17 00:00:00 2001 From: chf12mm Date: Wed, 12 Jan 2022 02:46:35 +0000 Subject: [PATCH] =?UTF-8?q?update=20ruoyi-ui/src/utils/dict/Dict.js.=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=AD=97=E5=85=B8=E9=87=8D=E5=A4=8D=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/dict/Dict.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ruoyi-ui/src/utils/dict/Dict.js b/ruoyi-ui/src/utils/dict/Dict.js index 22db32fe2..422f8ef5c 100644 --- a/ruoyi-ui/src/utils/dict/Dict.js +++ b/ruoyi-ui/src/utils/dict/Dict.js @@ -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 字典