lcw
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { ref, toRefs, isRef } from 'vue';
|
||||
import { getSysDictByCode } from '@/api/sysDict' //引入封装数字字典接口
|
||||
import { getSysDictByCode, fzdict } from '@/api/sysDict' //引入封装数字字典接口
|
||||
|
||||
import { getLocalDic } from "@/utils/localDic/index.js"
|
||||
/**
|
||||
@ -24,11 +24,11 @@ export function getDict(...args) {
|
||||
return (() => {
|
||||
args.forEach((d, index) => {
|
||||
res.value[d] = [];
|
||||
|
||||
// 本地字典拦截,如果本地字典存在,则使用本地字典,否则使用远程字典
|
||||
if (isLocalDict(d) && getLocalDic(d)) {
|
||||
res.value[d] = getLocalDic(d)
|
||||
} else {
|
||||
|
||||
getSysDictByCode({
|
||||
dictCode: d
|
||||
}).then(result => {
|
||||
@ -53,7 +53,42 @@ export function getDict(...args) {
|
||||
return toRefs(res.value);
|
||||
})()
|
||||
}
|
||||
export function getFzDict(...args) {
|
||||
const res = ref({});
|
||||
return (() => {
|
||||
args.forEach((d, index) => {
|
||||
res.value[d] = [];
|
||||
// 本地字典拦截,如果本地字典存在,则使用本地字典,否则使用远程字典
|
||||
if (isLocalDict(d) && getLocalDic(d)) {
|
||||
res.value[d] = getLocalDic(d);
|
||||
} else {
|
||||
fzdict({
|
||||
dictLabel: d
|
||||
}).then(result => {
|
||||
result = result || {};
|
||||
// result.itemList = Array.isArray(result.itemList) ? result.itemList : [];
|
||||
// result.itemList.forEach(p => {
|
||||
// p.label = p.itemName;
|
||||
// p.value = p.itemValue;
|
||||
// p.id = p.itemValue;
|
||||
// p.elTagType = p.dictType;
|
||||
// if (p?.itemList && p.itemList?.length > 0) {
|
||||
// getChildren(p);
|
||||
// }
|
||||
// p.children = p.itemList;
|
||||
// });
|
||||
// console.log(res.value);
|
||||
|
||||
res.value[d] = result
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 使用toRefs确保返回的是响应式对象
|
||||
return toRefs(res.value);
|
||||
})()
|
||||
|
||||
}
|
||||
export function getChildren(item) {
|
||||
item.label = item.zdmc
|
||||
item.value = item.dm
|
||||
@ -177,3 +212,4 @@ export function getMultiDictVal(values, dict) {
|
||||
}).join(',');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user