Commit 2e280380 by wangzhihui

修复不显示的问题

1 parent f9ed4f62
......@@ -11,13 +11,19 @@
label-width="150px"
:inline="true">
<el-form-item label="订单编号:" class="form-item-half">
<ellipsisText :content="detailInfo.orderCode"></ellipsisText>
<ellipsisText :popover-content="displayValue(detailInfo.orderCode)">
{{ displayValue(detailInfo.orderCode) }}
</ellipsisText>
</el-form-item>
<el-form-item v-if="detailInfo.oldOrderCode" label="原错误订单编号:" class="form-item-half">
<ellipsisText :content="detailInfo.oldOrderCode"></ellipsisText>
<ellipsisText :popover-content="displayValue(detailInfo.oldOrderCode)">
{{ displayValue(detailInfo.oldOrderCode) }}
</ellipsisText>
</el-form-item>
<el-form-item label="订单类型:" class="form-item-half">
<ellipsisText :content="djOrderTypeMap[detailInfo.djOrderType]"></ellipsisText>
<ellipsisText :popover-content="displayValue(djOrderTypeMap[detailInfo.djOrderType])">
{{ displayValue(djOrderTypeMap[detailInfo.djOrderType]) }}
</ellipsisText>
</el-form-item>
<el-form-item label="总价:" class="form-item-half">{{ detailInfo.finalPrice }}</el-form-item>
<el-form-item label="提单人:" class="form-item-half">
......@@ -28,10 +34,14 @@
</ellipsisText>
</el-form-item>
<el-form-item label="备注:" class="form-item-half">
<ellipsisText :content="detailInfo.orderRemark"></ellipsisText>
<ellipsisText :popover-content="displayValue(detailInfo.orderRemark)">
{{ displayValue(detailInfo.orderRemark) }}
</ellipsisText>
</el-form-item>
<el-form-item label="交易流水号:" :class="detailInfo.oldOrderCode ? '' : 'form-item-half'">
<ellipsisText :content="detailInfo.outTradeNo"></ellipsisText>
<ellipsisText :popover-content="displayValue(detailInfo.outTradeNo, '-')">
{{ displayValue(detailInfo.outTradeNo, '-') }}
</ellipsisText>
</el-form-item>
<el-form-item label="凭证:">
<div class="image-box" v-if="detailInfo.payVoucherList && detailInfo.payVoucherList.length">
......@@ -274,6 +284,10 @@ export default {
},
methods: {
displayValue(val, fallback = '--') {
if (val === null || val === undefined || val === '') return fallback
return val
},
getDetail() {
let params = {
orderCode: this.info.orderCode
......
......@@ -12,9 +12,7 @@
class="ellipsis"
@mouseenter="checkOverflow"
>
<slot>
{{ content || '--' }}
</slot>
<slot></slot>
</span>
</el-popover>
</template>
......@@ -32,55 +30,90 @@ export default {
data() {
return {
isOverflow: false
};
}
},
computed: {
hasDefaultSlot() {
const slot = this.$slots.default
if (!slot || !slot.length) return false
return slot.some(vnode => {
if (vnode.text !== undefined) return vnode.text.trim().length > 0
return !!(vnode.tag || vnode.componentOptions)
})
},
displayText() {
const val = this.content
if (val === null || val === undefined || val === '') return '--'
return String(val)
},
finalPopoverContent() {
if (this.popoverContent) return this.popoverContent;
if (this.$slots.default) {
return this.$slots.default[0].text || this.content || '--';
}
return this.content || '--';
if (this.popoverContent) return this.popoverContent
if (this.hasDefaultSlot) return this.getSlotText() || this.displayText
return this.displayText
}
},
methods: {
checkOverflow() {
const el = this.$refs.text;
if (el) {
this.isOverflow = el.scrollWidth > el.clientWidth;
}
}
},
mounted() {
this.checkOverflow();
},
watch: {
content() {
this.$nextTick(this.checkOverflow);
this.updateReferenceText()
this.$nextTick(this.checkOverflow)
},
popoverContent() {
this.$nextTick(this.checkOverflow)
},
'$slots.default': {
handler() {
this.$nextTick(this.checkOverflow);
this.updateReferenceText()
this.$nextTick(this.checkOverflow)
},
deep: true
}
},
mounted() {
this.updateReferenceText()
this.checkOverflow()
},
updated() {
this.updateReferenceText()
},
methods: {
getSlotText() {
const slot = this.$slots.default
if (!slot || !slot.length) return ''
return slot.map(vnode => {
if (vnode.text) return vnode.text
return (vnode.elm && vnode.elm.textContent) || ''
}).join('').trim()
},
updateReferenceText() {
this.$nextTick(() => {
const el = this.$refs.text
if (!el || this.hasDefaultSlot) return
el.textContent = this.displayText
})
},
checkOverflow() {
const el = this.$refs.text
if (el) {
this.isOverflow = el.scrollWidth > el.clientWidth
}
}
}
};
}
</script>
<style scoped>
.dark-popover {
background-color: #333 !important; /* 深色背景 */
color: #fff !important; /* 白色文字 */
border-color: #333 !important; /* 边框与背景同色 */
max-width: 300px !important; /* 设置最大宽度,可按需调整 */
word-wrap: break-word; /* 长单词换行 */
font-size: 14px; /* 调整字体大小(可选) */
line-height: 1.5; /* 调整行高(可选) */
background-color: #333 !important;
color: #fff !important;
border-color: #333 !important;
max-width: 300px !important;
word-wrap: break-word;
font-size: 14px;
line-height: 1.5;
}
.dark-popover .popper__arrow,
.dark-popover .popper__arrow::after {
border-top-color: #333 !important; /* 箭头颜色(根据 placement 调整方向) */
border-top-color: #333 !important;
}
.ellipsis {
display: inline-block;
......@@ -90,4 +123,4 @@ export default {
white-space: nowrap;
vertical-align: middle;
}
</style>
\ No newline at end of file
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!