2026-03-27 12:29:36 +08:00
|
|
|
<template>
|
|
|
|
|
<span v-if="!displayText" class="empty-text">{{ emptyText }}</span>
|
|
|
|
|
<a-tooltip v-else :title="displayText" placement="topLeft">
|
|
|
|
|
<div class="ellipsis-text" :class="lineClass">
|
|
|
|
|
{{ displayText }}
|
|
|
|
|
</div>
|
|
|
|
|
</a-tooltip>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* TableEllipsisText page script.
|
|
|
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
|
|
|
*/
|
2026-03-27 12:29:36 +08:00
|
|
|
import { computed } from 'vue'
|
|
|
|
|
|
2026-05-23 18:44:57 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: props supports TableEllipsisText.vue by holding or executing the props page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-03-27 12:29:36 +08:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
|
text?: string | number | null
|
|
|
|
|
lines?: 1 | 2 | 3
|
|
|
|
|
emptyText?: string
|
|
|
|
|
}>(), {
|
|
|
|
|
lines: 1,
|
|
|
|
|
emptyText: '--'
|
|
|
|
|
})
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
/** displayText is a reactive state variable used by the template and event handlers. */
|
2026-03-27 12:29:36 +08:00
|
|
|
const displayText = computed(() => {
|
|
|
|
|
if (props.text === undefined || props.text === null) {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
const value = String(props.text).trim()
|
|
|
|
|
return value
|
|
|
|
|
})
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
/** lineClass is a reactive state variable used by the template and event handlers. */
|
2026-03-27 12:29:36 +08:00
|
|
|
const lineClass = computed(() => {
|
|
|
|
|
return props.lines > 1 ? `lines-${props.lines}` : ''
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.ellipsis-text {
|
|
|
|
|
width: 100%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.lines-2,
|
|
|
|
|
.lines-3 {
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
white-space: normal;
|
|
|
|
|
word-break: break-word;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.lines-2 {
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.lines-3 {
|
|
|
|
|
-webkit-line-clamp: 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.empty-text {
|
|
|
|
|
color: #bfbfbf;
|
|
|
|
|
}
|
|
|
|
|
</style>
|