Skip to content

Commit

Permalink
releases 4.9.35
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 24, 2024
1 parent 1db7258 commit c8c2f4d
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 93 deletions.
2 changes: 1 addition & 1 deletion examples/views/table/TableTest8.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const imgList1CellRender = reactive<VxeColumnPropTypes.CellRender>({
moreConfig: {
maxCount: 2
},
imageStyle: {
imageConfig: {
width: 40,
height: 40
}
Expand Down
2 changes: 1 addition & 1 deletion examples/views/table/TableTest9.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const imgList1CellRender = reactive<VxeColumnPropTypes.CellRender>({
moreConfig: {
maxCount: 2
},
imageStyle: {
imageConfig: {
width: 40,
height: 40
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.9.34",
"version": "4.9.35",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -28,7 +28,7 @@
"style": "lib/style.css",
"typings": "types/index.d.ts",
"dependencies": {
"vxe-pc-ui": "^4.3.42"
"vxe-pc-ui": "^4.3.43"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
56 changes: 45 additions & 11 deletions packages/table/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const componentDefaultModelProp = 'modelValue'

const defaultCompProps = {}

function handleDefaultValue (value: any, defaultVal: any, initVal: any) {
return XEUtils.eqNull(value) ? (XEUtils.eqNull(defaultVal) ? initVal : defaultVal) : value
}

function parseDate (value: any, props: any) {
return value && props.valueFormat ? XEUtils.toStringDate(value, props.valueFormat) : value
}
Expand Down Expand Up @@ -612,13 +616,25 @@ renderer.mixin({
if (cellValue) {
const numberInputConfig = getConfig().numberInput || {}
if (type === 'float') {
const digits = props.digits || numberInputConfig.digits || 1
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
cellValue = XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
if (!autoFill) {
cellValue = XEUtils.toNumber(cellValue)
}
} else if (type === 'amount') {
const digits = props.digits || numberInputConfig.digits || 2
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
cellValue = XEUtils.commafy(XEUtils.toNumber(cellValue), { digits })
const showCurrency = props.showCurrency
if (XEUtils.isBoolean(showCurrency) ? showCurrency : numberInputConfig.showCurrency) {
if (!autoFill) {
const [iStr, dStr] = cellValue.split('.')
if (dStr) {
const dRest = dStr.replace(/0+$/, '')
cellValue = dRest ? [iStr, '.', dRest].join('') : iStr
}
}
if (showCurrency) {
cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${cellValue}`
}
}
Expand All @@ -630,18 +646,36 @@ renderer.mixin({
const { row, column, _columnIndex } = params
const { type } = props
// 兼容老模式
const cellValue = XEUtils.isArray(row) ? row[_columnIndex] : XEUtils.get(row, column.field)
if (XEUtils.isNumber(cellValue)) {
const itemValue = XEUtils.isArray(row) ? row[_columnIndex] : XEUtils.get(row, column.field)
if (XEUtils.isNumber(itemValue)) {
const numberInputConfig = getConfig().numberInput || {}
if (type === 'float') {
const digits = props.digits || numberInputConfig.digits || 1
return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1)
let amountLabel = XEUtils.toFixed(XEUtils.floor(itemValue, digits), digits)
if (!autoFill) {
amountLabel = XEUtils.toNumber(amountLabel)
}
return amountLabel
} else if (type === 'amount') {
const digits = props.digits || numberInputConfig.digits || 2
return XEUtils.commafy(XEUtils.toNumber(cellValue), { digits })
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true)
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2)
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false)
let amountLabel = XEUtils.commafy(XEUtils.toNumber(itemValue), { digits })
if (!autoFill) {
const [iStr, dStr] = amountLabel.split('.')
if (dStr) {
const dRest = dStr.replace(/0+$/, '')
amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr
}
}
if (showCurrency) {
amountLabel = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${amountLabel}`
}
return amountLabel
}
}
return getFuncText(cellValue, 1)
return getFuncText(itemValue, 1)
},
renderTableDefault: defaultEditRender,
renderTableFilter: defaultFilterRender,
Expand Down
48 changes: 20 additions & 28 deletions packages/table/src/body.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createCommentVNode, defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, ComputedRef, onBeforeUnmount, onMounted, onUnmounted } from 'vue'
import { defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, ComputedRef, onBeforeUnmount, onMounted, onUnmounted } from 'vue'
import XEUtils from 'xe-utils'
import { VxeUI } from '../../ui'
import { mergeBodyMethod, getRowid, getRefElem } from './util'
Expand Down Expand Up @@ -36,7 +36,7 @@ export default defineComponent({

const { xID, props: tableProps, context: tableContext, reactData: tableReactData, internalData: tableInternalData } = $xeTable
const { refTableBody, refTableHeader, refTableFooter, refTableLeftBody, refTableRightBody, refScrollXHandleElem, refScrollYHandleElem } = $xeTable.getRefMaps()
const { computeEditOpts, computeMouseOpts, computeAreaOpts, computeSYOpts, computeEmptyOpts, computeKeyboardOpts, computeTooltipOpts, computeRadioOpts, computeExpandOpts, computeTreeOpts, computeCheckboxOpts, computeCellOpts, computeValidOpts, computeRowOpts, computeColumnOpts, computeRowDragOpts, computeColumnDragOpts } = $xeTable.getComputeMaps()
const { computeEditOpts, computeMouseOpts, computeAreaOpts, computeSYOpts, computeEmptyOpts, computeTooltipOpts, computeRadioOpts, computeExpandOpts, computeTreeOpts, computeCheckboxOpts, computeCellOpts, computeValidOpts, computeRowOpts, computeColumnOpts, computeRowDragOpts, computeColumnDragOpts } = $xeTable.getComputeMaps()

const refElem = ref() as Ref<HTMLDivElement>
const refBodyTable = ref() as Ref<HTMLTableElement>
Expand Down Expand Up @@ -762,40 +762,32 @@ export default defineComponent({
})

const renderVN = () => {
let { fixedColumn, fixedType, tableColumn } = props
const { keyboardConfig, showOverflow: allColumnOverflow, spanMethod, mouseConfig } = tableProps
const { tableData, mergeList, scrollYLoad, isAllOverflow, isDragRowMove } = tableReactData
const { fixedColumn, fixedType, tableColumn } = props
const { showOverflow: allColumnOverflow, spanMethod, footerSpanMethod, mouseConfig } = tableProps
const { tableData, scrollXLoad, scrollYLoad, isAllOverflow, isDragRowMove, expandColumn } = tableReactData
const { visibleColumn } = tableInternalData
const { slots } = tableContext
const rowOpts = computeRowOpts.value
const sYOpts = computeSYOpts.value
const emptyOpts = computeEmptyOpts.value
const keyboardOpts = computeKeyboardOpts.value
const mouseOpts = computeMouseOpts.value
const rowDragOpts = computeRowDragOpts.value
// const isMergeLeftFixedExceeded = computeIsMergeLeftFixedExceeded.value
// const isMergeRightFixedExceeded = computeIsMergeRightFixedExceeded.value
// 如果是使用优化模式

let renderColumnList = tableColumn

if (fixedType) {
// 如果存在展开行使用全量渲染
if (!tableReactData.expandColumn && (scrollYLoad || (allColumnOverflow ? isAllOverflow : allColumnOverflow))) {
if (!mergeList.length && !spanMethod && !(keyboardConfig && keyboardOpts.isMerge)) {
tableColumn = fixedColumn
renderColumnList = visibleColumn
// 如果是使用优化模式
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
// 如果不支持优化模式
if (expandColumn || spanMethod || footerSpanMethod) {
renderColumnList = visibleColumn
} else {
tableColumn = visibleColumn
// 检查固定列是否被合并,合并范围是否超出固定列
// if (mergeList.length && !isMergeLeftFixedExceeded && fixedType === 'left') {
// tableColumn = fixedColumn
// } else if (mergeList.length && !isMergeRightFixedExceeded && fixedType === 'right') {
// tableColumn = fixedColumn
// } else {
// tableColumn = visibleColumn
// }
renderColumnList = fixedColumn || []
}
} else {
tableColumn = visibleColumn
}
}

let emptyContent: string | VxeComponentSlotType | VxeComponentSlotType[]
const emptySlot = slots ? slots.empty : null
if (emptySlot) {
Expand Down Expand Up @@ -824,7 +816,7 @@ export default defineComponent({
...ons
}, [
fixedType
? createCommentVNode()
? renderEmptyElement($xeTable)
: h('div', {
ref: refBodyXSpace,
class: 'vxe-body--x-space'
Expand All @@ -846,7 +838,7 @@ export default defineComponent({
*/
h('colgroup', {
ref: refBodyColgroup
}, (tableColumn as any[]).map((column, $columnIndex) => {
}, (renderColumnList as any[]).map((column, $columnIndex) => {
return h('col', {
name: column.id,
key: $columnIndex
Expand All @@ -861,11 +853,11 @@ export default defineComponent({
name: `vxe-body--row-list${isDragRowMove ? '' : '-disabled'}`,
tag: 'tbody'
}, {
default: () => renderRows(fixedType, tableData, tableColumn)
default: () => renderRows(fixedType, tableData, renderColumnList)
})
: h('tbody', {
ref: refBodyTBody
}, renderRows(fixedType, tableData, tableColumn))
}, renderRows(fixedType, tableData, renderColumnList))
]),
h('div', {
class: 'vxe-table--checkbox-range'
Expand Down
41 changes: 21 additions & 20 deletions packages/table/src/footer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createCommentVNode, defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
import { defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
import XEUtils from 'xe-utils'
import { VxeUI } from '../../ui'
import { updateCellTitle, getPropClass, setScrollLeft } from '../../ui/src/dom'

import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeColumnPropTypes, VxeTableDefines } from '../../../types'

const { renderer } = VxeUI
const { renderer, renderEmptyElement } = VxeUI

const renderType = 'footer'

Expand Down Expand Up @@ -228,8 +228,8 @@ export default defineComponent({
: [])
}

const renderHeads = (footerTableData: any[]) => {
const { fixedType, tableColumn } = props
const renderHeads = (renderColumnList: VxeTableDefines.ColumnInfo[]) => {
const { fixedType, footerTableData } = props
const { footerRowClassName, footerRowStyle } = tableProps
const { isDragColMove } = tableReactData
const columnOpts = computeColumnOpts.value
Expand All @@ -250,7 +250,7 @@ export default defineComponent({
],
style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
}, {
default: () => renderRows(tableColumn, footerTableData, row, $rowIndex, _rowIndex)
default: () => renderRows(renderColumnList, footerTableData, row, $rowIndex, _rowIndex)
})
}
return h('tr', {
Expand All @@ -260,27 +260,28 @@ export default defineComponent({
footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
],
style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
}, renderRows(tableColumn, footerTableData, row, $rowIndex, _rowIndex))
}, renderRows(renderColumnList, footerTableData, row, $rowIndex, _rowIndex))
})
}

const renderVN = () => {
let { fixedType, fixedColumn, tableColumn, footerTableData } = props
const { footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps
const { fixedType, fixedColumn, tableColumn } = props
const { spanMethod, footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps
const { visibleColumn } = tableInternalData
const { scrollXLoad, scrollbarWidth, mergeFooterList } = tableReactData
const { scrollbarWidth } = tableReactData

let renderColumnList = tableColumn

// 如果是使用优化模式
if (fixedType) {
// 如果存在展开行使用全量渲染
if (!tableReactData.expandColumn && (scrollXLoad || allColumnFooterOverflow)) {
if (!mergeFooterList.length || !footerSpanMethod) {
tableColumn = fixedColumn
renderColumnList = visibleColumn
// 如果是使用优化模式
if (allColumnFooterOverflow) {
// 如果不支持优化模式
if (spanMethod || footerSpanMethod) {
renderColumnList = visibleColumn
} else {
tableColumn = visibleColumn
renderColumnList = fixedColumn || []
}
} else {
tableColumn = visibleColumn
}
}

Expand All @@ -296,7 +297,7 @@ export default defineComponent({
...ons
}, [
fixedType
? createCommentVNode()
? renderEmptyElement($xeTable)
: h('div', {
ref: refFooterXSpace,
class: 'vxe-body--x-space'
Expand All @@ -314,7 +315,7 @@ export default defineComponent({
*/
h('colgroup', {
ref: refFooterColgroup
}, tableColumn.map((column, $columnIndex) => {
}, renderColumnList.map((column, $columnIndex) => {
return h('col', {
name: column.id,
key: $columnIndex
Expand All @@ -331,7 +332,7 @@ export default defineComponent({
*/
h('tfoot', {
ref: refFooterTFoot
}, renderHeads(footerTableData))
}, renderHeads(renderColumnList))
])
])
}
Expand Down
22 changes: 14 additions & 8 deletions packages/table/src/header.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createCommentVNode, defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted } from 'vue'
import { defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted } from 'vue'
import XEUtils from 'xe-utils'
import { VxeUI } from '../../ui'
import { convertHeaderColumnToRows, getColReMinWidth } from './util'
import { hasClass, getOffsetPos, addClass, removeClass } from '../../ui/src/dom'

import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeTableDefines, VxeColumnPropTypes } from '../../../types'

const { renderer } = VxeUI
const { renderer, renderEmptyElement } = VxeUI

const renderType = 'header'

Expand Down Expand Up @@ -311,18 +311,24 @@ export default defineComponent({

const renderVN = () => {
const { fixedType, fixedColumn, tableColumn } = props
const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps
const { isGroup, scrollXLoad, scrollbarWidth } = tableReactData
const { showHeaderOverflow: allColumnHeaderOverflow, spanMethod, footerSpanMethod } = tableProps
const { isGroup, scrollbarWidth } = tableReactData
const { visibleColumn } = tableInternalData
let headerGroups: VxeTableDefines.ColumnInfo[][] = headerColumn.value
let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
if (isGroup) {
renderColumnList = visibleColumn
} else {
// 如果是使用优化模式
if (fixedType) {
if (scrollXLoad || allColumnHeaderOverflow) {
renderColumnList = fixedColumn as VxeTableDefines.ColumnInfo[]
renderColumnList = visibleColumn
// 如果是使用优化模式
if (allColumnHeaderOverflow) {
// 如果不支持优化模式
if (spanMethod || footerSpanMethod) {
renderColumnList = visibleColumn
} else {
renderColumnList = fixedColumn || []
}
}
}
headerGroups = [renderColumnList]
Expand All @@ -333,7 +339,7 @@ export default defineComponent({
xid: xID
}, [
fixedType
? createCommentVNode()
? renderEmptyElement($xeTable)
: h('div', {
ref: refHeaderXSpace,
class: 'vxe-body--x-space'
Expand Down
Loading

0 comments on commit c8c2f4d

Please sign in to comment.