feat:更新字典

This commit is contained in:
2025-12-11 11:29:43 +08:00
parent 654e4636a2
commit d631a31dc6
2 changed files with 163 additions and 19 deletions

View File

@ -1,29 +1,52 @@
import { ref, toRefs } from 'vue';
import { getSysDictByCode } from '@/api/sysDict' //引入封装数字字典接口
import { getLocalDic } from "@/utils/localDic/index.js"
/**
* 获取字典数据
*/
let list = []
/** 是否取本地字典 (需要本地加载就加这里,不需要就删除) */
export function isLocalDict(dictCode) {
let localDicObj = {
D_GS_ZDR_YJDJ: true, // "岗哨系统重点人员预警等级"
D_BZ_XB: true, // 性别
D_GS_BQ_DJ: true, // "岗哨系统标签管理标签等级"
D_GS_SSYJ: true, // "岗哨系统四色预警"
D_BZ_SF: true, // "是否"
BD_BK_CLYJBQ: true, // "车辆预警标签"
D_YJXX_CZCSLX:true, //常控处置措施类型
}
return localDicObj[dictCode]
}
export function getDict(...args) {
const res = ref({});
return (() => {
args.forEach((d, index) => {
res.value[d] = [];
getSysDictByCode({
dictCode: d
}).then(result => {
result.itemList.forEach(p => {
p.label = p.zdmc
p.value = p.dm
p.id = p.dm
p.elTagType = p.dictType
if ( p.itemList && p.itemList.length > 0) {
getChildren(p)
}
p.children = p.itemList
// 本地字典拦截,如果本地字典存在,则使用本地字典,否则使用远程字典
if (isLocalDict(d) && getLocalDic(d)) {
res.value[d] = getLocalDic(d)
} else {
getSysDictByCode({
dictCode: d
}).then(result => {
result.itemList.forEach(p => {
p.label = p.zdmc
p.value = p.dm
p.id = p.dm
p.elTagType = p.dictType
if (p.itemList && p.itemList.length > 0) {
getChildren(p)
}
p.children = p.itemList
})
res.value[d] = result.itemList
// console.log(`${d} - ${result.zdmc} :`, result.itemList);
})
res.value[d] = result.itemList
})
}
})
return toRefs(res.value);
})()
@ -61,9 +84,9 @@ export function setCascader(id, array, childDeptList = 'childDeptList', fun) {
}
/**
* 当type=1时获取出生日期,type=2时获取性别,type=3时获取年龄 all
* @param {*} IdCard
* @param {*} type
* @returns
* @param {*} IdCard
* @param {*} type
* @returns
*/
export function IdCard(IdCard, type) {
let user = {