@ithinkdt/core
Version:
iThinkDT Core
22 lines (15 loc) • 605 B
JavaScript
import { shallowReactive } from 'vue'
import { getDictMap, getDicts, hasDictType, _getDict } from './service'
export function getDict(dictType, getType, valueType, forceCache, hideDisabled, onGet) {
const $fetch = _getDict(dictType, forceCache)
onGet && $fetch.then(onGet)
const isGetMap = getType === 'map'
let $ret
if (hasDictType(dictType)) {
$ret = isGetMap ? getDictMap(dictType, hideDisabled, valueType) : getDicts(dictType, hideDisabled, valueType)
} else {
$ret = shallowReactive(isGetMap ? new Map() : [])
}
$ret.$ = $fetch
return $ret
}