更新计费失败状态,新增销售价和产品价未匹配的错误信息,调整相关代码逻辑以支持新的状态处理。
This commit is contained in:
@@ -588,6 +588,55 @@ function renderVirtualText(col, row, rowIndex) {
|
||||
return String(text)
|
||||
}
|
||||
|
||||
/** Flatten slot VNode text for virtual-table overflow tooltip. */
|
||||
function extractSlotText(nodes) {
|
||||
if (nodes == null || nodes === false) return ''
|
||||
if (typeof nodes === 'string' || typeof nodes === 'number') return String(nodes)
|
||||
if (Array.isArray(nodes)) return nodes.map(extractSlotText).join('')
|
||||
if (typeof nodes === 'object') {
|
||||
if (typeof nodes.children === 'string' || typeof nodes.children === 'number') {
|
||||
return String(nodes.children)
|
||||
}
|
||||
if (Array.isArray(nodes.children)) return extractSlotText(nodes.children)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
/** True when slot tree contains a component (button/tag/...), skip auto tooltip. */
|
||||
function slotHasComponent(nodes) {
|
||||
if (nodes == null || nodes === false) return false
|
||||
if (Array.isArray(nodes)) return nodes.some(slotHasComponent)
|
||||
if (typeof nodes !== 'object') return false
|
||||
if (typeof nodes.type === 'object' || typeof nodes.type === 'function') return true
|
||||
if (Array.isArray(nodes.children)) return slotHasComponent(nodes.children)
|
||||
return false
|
||||
}
|
||||
|
||||
function resolveVirtualTooltip(col, rowData, rowIndex, slotNodes) {
|
||||
if (col.showOverflowTooltip === false) return ''
|
||||
if (typeof col.tooltipFormatter === 'function') {
|
||||
const tip = col.tooltipFormatter(rowData, col, rowData ? rowData[col.prop] : undefined, rowIndex)
|
||||
return tip == null || tip === '' ? '' : String(tip)
|
||||
}
|
||||
if (slotNodes != null) {
|
||||
if (slotHasComponent(slotNodes)) return ''
|
||||
return extractSlotText(slotNodes).trim()
|
||||
}
|
||||
return renderVirtualText(col, rowData, rowIndex)
|
||||
}
|
||||
|
||||
function wrapVirtualTooltip(tip, cell) {
|
||||
if (!tip) return cell
|
||||
return h(ElTooltip, {
|
||||
content: tip,
|
||||
placement: 'top',
|
||||
showAfter: 300,
|
||||
enterable: false
|
||||
}, {
|
||||
default: () => cell
|
||||
})
|
||||
}
|
||||
|
||||
const virtualColumns = computed(() => {
|
||||
const cols = []
|
||||
if (props.selection) {
|
||||
@@ -629,18 +678,13 @@ const virtualColumns = computed(() => {
|
||||
})
|
||||
}
|
||||
if (slotFn) {
|
||||
return h('div', { class: 'basic-table-vcell' }, slotFn({ row: rowData, $index: rowIndex }))
|
||||
const nodes = slotFn({ row: rowData, $index: rowIndex })
|
||||
const cell = h('div', { class: 'basic-table-vcell' }, nodes)
|
||||
return wrapVirtualTooltip(resolveVirtualTooltip(col, rowData, rowIndex, nodes), cell)
|
||||
}
|
||||
const text = renderVirtualText(col, rowData, rowIndex)
|
||||
if (!text) return h('div', { class: 'basic-table-vcell' }, '')
|
||||
return h(ElTooltip, {
|
||||
content: text,
|
||||
placement: 'top',
|
||||
showAfter: 300,
|
||||
enterable: false
|
||||
}, {
|
||||
default: () => h('div', { class: 'basic-table-vcell' }, text)
|
||||
})
|
||||
const cell = h('div', { class: 'basic-table-vcell' }, text || '')
|
||||
return wrapVirtualTooltip(resolveVirtualTooltip(col, rowData, rowIndex), cell)
|
||||
}
|
||||
}
|
||||
if (headerSlot) column.headerCellRenderer = () => headerSlot({ column: col })
|
||||
|
||||
Reference in New Issue
Block a user