fix : 修复pointTag组件
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div style="display: flex;justify-content: center">
|
<div style="display: flex;justify-content: center">
|
||||||
<span class="stateIcon" :style="{backgroundColor: filterDictClass(cacheStore.getDict(dictType), value)}"></span>
|
<span class="stateIcon" :style="{backgroundColor: filterDictClass(cacheStore.getDict(dictType), value)}"></span>
|
||||||
<span>{{tag.label}}</span>
|
<span>{{ tagConfig.label }}</span>
|
||||||
<span> {{ filterDict(cacheStore.getDict(dictType), value) }}</span>
|
<span> {{ filterDict(cacheStore.getDict(dictType), value) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -21,37 +21,42 @@ const props = defineProps({
|
|||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const tag = reactive({
|
const tagConfig = reactive({
|
||||||
listClass: "green",
|
listClass: "green",
|
||||||
isType: true,
|
isType: true,
|
||||||
label: ""
|
label: ""
|
||||||
});
|
});
|
||||||
// const dictList = cacheStore.getDict(props.dictType);
|
|
||||||
// const dictFormat = () => {
|
|
||||||
// if(dictList===undefined) return;
|
|
||||||
// for (let i = 0; i < dictList.length; i++) {
|
|
||||||
// if(dictList[i].value=== props.value){
|
|
||||||
// tag.label = dictList[i].label;
|
|
||||||
// tag.listClass=changeParams(dictList[i].listClass)
|
|
||||||
// tag.isType = dictList[i].isType;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
const filterDictClass = (data, value) => {
|
const filterDictClass = (data, value) => {
|
||||||
if(!data) return
|
if (!data) return
|
||||||
|
if (data instanceof Array) {
|
||||||
if(data instanceof Array) {
|
tagConfig.value = data.find(item => item.value == value)
|
||||||
tag.value = data.find(item => item.value == value)
|
if (!tagConfig.value) {
|
||||||
|
return '#409EFF'
|
||||||
|
} else {
|
||||||
|
if (tagConfig.value?.isType) {
|
||||||
|
return changeParams(tagConfig.value.listClass)
|
||||||
|
} else {
|
||||||
|
return tagConfig.value.listClass
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changeParams(tag.value.listClass)
|
|
||||||
}
|
}
|
||||||
const filterDict = (data, value) => {
|
const filterDict = (data, value) => {
|
||||||
if(!data) return
|
if (!data || value == null) return
|
||||||
|
if (data instanceof Array) {
|
||||||
if(data instanceof Array) {
|
if (value == true || value == false) {
|
||||||
tag.value = data.find(item => item.value == value)
|
tagConfig.value = data.find(item => item.value == value.toString())
|
||||||
|
} else if (typeof value === "object") {
|
||||||
|
if (value !== null) {
|
||||||
|
tagConfig.value = data.find(item => item.value == value[0])
|
||||||
|
} else {
|
||||||
|
tagConfig.value = {}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tagConfig.value = data.find(item => item.value == value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tag.value.label
|
return tagConfig.value?.label || '未知'
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 根据接口返回的listClass切换成对应的颜色
|
* 根据接口返回的listClass切换成对应的颜色
|
||||||
@@ -63,18 +68,17 @@ const changeParams = (listClass) => {
|
|||||||
case 'danger':
|
case 'danger':
|
||||||
return 'red'
|
return 'red'
|
||||||
case 'success':
|
case 'success':
|
||||||
return '#67C23A'
|
return '#67C23A'
|
||||||
case 'info':
|
case 'info':
|
||||||
return '#909399'
|
return '#909399'
|
||||||
case 'primary':
|
case 'primary':
|
||||||
return '#409EFF'
|
return '#409EFF'
|
||||||
case 'warning':
|
case 'warning':
|
||||||
return '#E6A23C'
|
return '#E6A23C'
|
||||||
default:
|
default:
|
||||||
return listClass
|
return listClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// dictFormat()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -85,7 +89,7 @@ const changeParams = (listClass) => {
|
|||||||
// background-color: green;
|
// background-color: green;
|
||||||
// z-index: 99999;
|
// z-index: 99999;
|
||||||
//}
|
//}
|
||||||
:deep(.el-tag){
|
:deep(.el-tag) {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-top: 9px;
|
margin-top: 9px;
|
||||||
margin-right: 7px;
|
margin-right: 7px;
|
||||||
|
|||||||
Reference in New Issue
Block a user