修改公共配置字典

This commit is contained in:
wuweihua
2026-09-08 10:51:20 +08:00
parent 647be14d66
commit 38796d8683
25 changed files with 389 additions and 80 deletions
+10 -4
View File
@@ -2,23 +2,29 @@ import useDictStore from '@/store/modules/dict'
import { getDicts } from '@/api/system/dict/data'
/**
* 获取字典数据
* 获取字典数据(优先使用登录后全量缓存,按 dictType code 匹配)
*/
export function useDict(...args) {
const res = ref({})
return (() => {
args.forEach((dictType, index) => {
args.forEach((dictType) => {
res.value[dictType] = []
const dicts = useDictStore().getDict(dictType)
if (dicts) {
res.value[dictType] = dicts
} else {
// 缓存未命中时按类型补拉(如字典管理刚改完被 removeDict)
getDicts(dictType).then(resp => {
res.value[dictType] = resp.data.map(p => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass }))
res.value[dictType] = (resp.data || []).map(p => ({
label: p.dictLabel,
value: p.dictValue,
elTagType: p.listClass,
elTagClass: p.cssClass
}))
useDictStore().setDict(dictType, res.value[dictType])
})
}
})
return toRefs(res.value)
})()
}
}