refactor: 字典类型支持数组
This commit is contained in:
@@ -10,7 +10,7 @@ interface DictTagGroupProps {
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
type: string;
|
||||
type: string[];
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@@ -31,37 +31,39 @@ const dictTag = computed(() => {
|
||||
}
|
||||
|
||||
const dictTagGroup: any[] = [];
|
||||
props.value.forEach((value) => {
|
||||
// 获取字典对象
|
||||
const dict = getDictObj(props.type, String(value));
|
||||
if (!dict) {
|
||||
return null;
|
||||
}
|
||||
props.type.forEach((type) => {
|
||||
props.value?.forEach((value) => {
|
||||
// 获取字典对象
|
||||
const dict = getDictObj(type, String(value));
|
||||
if (!dict) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 处理颜色类型
|
||||
let colorType = dict.colorType;
|
||||
switch (colorType) {
|
||||
case 'danger': {
|
||||
colorType = 'error';
|
||||
break;
|
||||
}
|
||||
case 'info': {
|
||||
colorType = 'default';
|
||||
break;
|
||||
}
|
||||
case 'primary': {
|
||||
colorType = 'processing';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!colorType) {
|
||||
// 处理颜色类型
|
||||
let colorType = dict.colorType;
|
||||
switch (colorType) {
|
||||
case 'danger': {
|
||||
colorType = 'error';
|
||||
break;
|
||||
}
|
||||
case 'info': {
|
||||
colorType = 'default';
|
||||
break;
|
||||
}
|
||||
case 'primary': {
|
||||
colorType = 'processing';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (!colorType) {
|
||||
colorType = 'default';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dictTagGroup.push({
|
||||
label: dict.label || '',
|
||||
colorType,
|
||||
dictTagGroup.push({
|
||||
label: dict.label || '',
|
||||
colorType,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user