Commit 2e280380 by wangzhihui

修复不显示的问题

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