import * as api from '@/api';
|
|
const dictCache = {};
|
|
const useDictMap = (groups) => {
|
const dictMapEntity = reactive({});
|
const dictMapCode = reactive({});
|
|
onMounted(async () => {
|
const res = await Promise.all(groups.filter(e => !dictCache[e]).map(key => api.entity.getOldEntitySet({
|
dataName: 'dictitem', filter: " parent_id = '" + key + "'"
|
})));
|
|
groups.filter(e => !dictCache[e]).forEach((e, i) => {
|
dictCache[e] = res[i].data.entityset;
|
});
|
|
groups.forEach(e => {
|
dictMapEntity[e] = dictCache[e];
|
dictMapCode[e] = Object.fromEntries(dictCache[e].map(({code, value}) => [code, value]));
|
});
|
})
|
|
return [dictMapEntity, dictMapCode];
|
}
|
|
export default {useDictMap};
|