优化
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user