| 12345678910111213141516171819202122232425262728 |
- import {useDictStore} from "@/store/modules/dict";
- import {storeToRefs} from "pinia";
- import {listDetialByCodes} from "@/api/system/dict/";
- export const useDictCache = (type: string[]) => {
- const dictObj = useDictStore()
- const queryDictDetailByCodes = async () => {
- let newDictCode = []
- type.forEach(key => {
- let dictList = dictObj.getDict(key)
- if (!dictList || dictList.length <= 0) {
- newDictCode.push(key)
- }
- })
- if(newDictCode.length <= 0) return
- const res = await listDetialByCodes(newDictCode)
- newDictCode.forEach(key => {
- dictObj.setDict(key, res.result[key])
- })
- }
- return {
- queryDictDetailByCodes
- }
- }
|