This commit is contained in:
2026-08-12 17:45:49 +08:00
parent 5b441626e9
commit 2a889a7d91
25 changed files with 154 additions and 29 deletions
+13 -1
View File
@@ -232,7 +232,19 @@ watch([page, pageCount], ([value, count]) => {
}, { immediate: true })
function columnAttrs({ key, slotName, headerSlotName, hideable, movable, defaultVisible, ...attrs }: DataTableColumn) {
return attrs
const hasDataProperty = attrs.prop !== undefined || attrs.property !== undefined
const isSpecialColumn = slotName || ['selection', 'expand', 'index'].includes(String(attrs.type || ''))
if (hasDataProperty || isSpecialColumn || key === undefined || key === null || key === '') return attrs
const label = String(attrs.label || '')
return {
...attrs,
prop: String(key),
formatter: attrs.formatter || ((_row: unknown, _column: unknown, value: unknown) => {
if (value === null || value === undefined || value === '') return '—'
if (typeof value === 'number' && /CNY|金额|应收|应付|已收|已付|未收|待收|待付|开账/.test(label)) return value.toFixed(2)
return String(value)
}),
}
}
function columnRenderKey(column: DataTableColumn, index: number) {