feat: 工具更细
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { ref, toRefs } from 'vue';
|
||||
import { ref, toRefs, isRef } from 'vue';
|
||||
import { getSysDictByCode } from '@/api/sysDict' //引入封装数字字典接口
|
||||
|
||||
import { getLocalDic } from "@/utils/localDic/index.js"
|
||||
@ -45,7 +45,7 @@ export function getDict(...args) {
|
||||
p.children = p.itemList
|
||||
})
|
||||
res.value[d] = result.itemList
|
||||
// console.log(`${d} - ${result.zdmc} :`, result.itemList);
|
||||
//
|
||||
})
|
||||
}
|
||||
|
||||
@ -142,3 +142,38 @@ export function IdCard(IdCard, type) {
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*翻译字典数据
|
||||
* @export
|
||||
* @param {*} dm
|
||||
* @param {*} array
|
||||
*/
|
||||
export function getDictValue(dm, array) {
|
||||
let item = array.value.find(item => {
|
||||
if (item.value) {
|
||||
return item.value == dm;
|
||||
} else if (item.dm) {
|
||||
return item.dm == dm;
|
||||
}
|
||||
})
|
||||
return item ? item.label : ""
|
||||
}
|
||||
|
||||
/** 获取多个字典值(一个值也可以) 字典内容 value-label
|
||||
* @param {String} 要查的值
|
||||
* @param {Array} dict 字典内容
|
||||
*/
|
||||
export function getMultiDictVal(values, dict) {
|
||||
if (typeof values === 'string' && values?.length) values = values.split(',')
|
||||
if (!Array.isArray(values)) return ''
|
||||
if (isRef(dict)) dict = dict.value
|
||||
if (!Array.isArray(dict)) return ''
|
||||
|
||||
return values.map(v => {
|
||||
const item = dict.find(item => item.value === v);
|
||||
return item ? item.label : v;
|
||||
}).join(',');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user