fix: 修复table列表tooltip展示不全

This commit is contained in:
xinxin.wu 2024-09-23 14:36:45 +08:00 committed by Craftsman
parent 18997cdda7
commit f6efb24040
2 changed files with 11 additions and 5 deletions

View File

@ -7,12 +7,15 @@
<MsTag <MsTag
v-for="tag of showTagList" v-for="tag of showTagList"
:key="tag.id" :key="tag.id"
class="ms-tag-group" :class="`${props.showTable ? 'ms-tag-group' : ''}`"
:width="getTagWidth(tag)" :width="getTagWidth(tag)"
:size="props.size" :size="props.size"
v-bind="attrs" v-bind="attrs"
> >
{{ getTagContent(tag) }} {{ getTagContent(tag) }}
<template v-if="props.showTable" #tooltipContent>
{{ props.isStringTag ? tag : tag[props.nameKey] }}
</template>
</MsTag> </MsTag>
<a-tooltip <a-tooltip
:disabled="!(props.tagList.length > props.showNum)" :disabled="!(props.tagList.length > props.showNum)"
@ -114,9 +117,9 @@
}); });
function getTagContent(tag: { [x: string]: any }) { function getTagContent(tag: { [x: string]: any }) {
let tagContent = props.isStringTag ? tag : tag[props.nameKey]; const tagContent = props.isStringTag ? tag : tag[props.nameKey];
if (tagContent.length > 16) { if (props.showTable) {
tagContent = characterLimit(tagContent, 9); return tagContent.length > 16 ? characterLimit(tagContent, 9) : tagContent;
} }
return tagContent; return tagContent;
} }

View File

@ -18,7 +18,10 @@
<div :class="`one-line-text min-w-[20px] ${props.maxWidth || '144px'}`"> <div :class="`one-line-text min-w-[20px] ${props.maxWidth || '144px'}`">
<slot></slot> <slot></slot>
</div> </div>
<template #content> <template v-if="$slots.tooltipContent" #content>
<slot name="tooltipContent"></slot>
</template>
<template v-else #content>
<slot></slot> <slot></slot>
</template> </template>
</a-tooltip> </a-tooltip>