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[] = [];
|
const dictTagGroup: any[] = [];
|
||||||
props.value.forEach((value) => {
|
props.type.forEach((type) => {
|
||||||
// 获取字典对象
|
props.value?.forEach((value) => {
|
||||||
const dict = getDictObj(props.type, String(value));
|
// 获取字典对象
|
||||||
if (!dict) {
|
const dict = getDictObj(type, String(value));
|
||||||
return null;
|
if (!dict) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// 处理颜色类型
|
// 处理颜色类型
|
||||||
let colorType = dict.colorType;
|
let colorType = dict.colorType;
|
||||||
switch (colorType) {
|
switch (colorType) {
|
||||||
case 'danger': {
|
case 'danger': {
|
||||||
colorType = 'error';
|
colorType = 'error';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'info': {
|
case 'info': {
|
||||||
colorType = 'default';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'primary': {
|
|
||||||
colorType = 'processing';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
if (!colorType) {
|
|
||||||
colorType = 'default';
|
colorType = 'default';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'primary': {
|
||||||
|
colorType = 'processing';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
if (!colorType) {
|
||||||
|
colorType = 'default';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
dictTagGroup.push({
|
||||||
dictTagGroup.push({
|
label: dict.label || '',
|
||||||
label: dict.label || '',
|
colorType,
|
||||||
colorType,
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user