Pre Merge pull request !411 from chf12mm/master
This commit is contained in:
commit
785d05f295
@ -37,7 +37,7 @@ export default class Dict {
|
|||||||
if (dictMeta.lazy) {
|
if (dictMeta.lazy) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ps.push(loadDict(this, dictMeta))
|
ps.push(removal(this, dictMeta))
|
||||||
})
|
})
|
||||||
return Promise.all(ps)
|
return Promise.all(ps)
|
||||||
}
|
}
|
||||||
@ -51,10 +51,30 @@ export default class Dict {
|
|||||||
if (dictMeta === undefined) {
|
if (dictMeta === undefined) {
|
||||||
return Promise.reject(`the dict meta of ${type} was not found`)
|
return Promise.reject(`the dict meta of ${type} was not found`)
|
||||||
}
|
}
|
||||||
return loadDict(this, dictMeta)
|
return removal(this, dictMeta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//过滤重复数据重复请求
|
||||||
|
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 字典
|
* @param {Dict} dict 字典
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import Dict from './Dict'
|
import Dict from './Dict'
|
||||||
import { mergeOptions } from './DictOptions'
|
import { mergeOptions } from './DictOptions'
|
||||||
|
var __dictCache = new Map();
|
||||||
|
window.__dictCache = __dictCache;
|
||||||
export default function(Vue, options) {
|
export default function(Vue, options) {
|
||||||
mergeOptions(options)
|
mergeOptions(options)
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user