Skip to content

Commit

Permalink
releases 4.9.16
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 5, 2024
1 parent cc8dcee commit 194df36
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 41 deletions.
14 changes: 13 additions & 1 deletion examples/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp } from 'vue'
import { createApp, h } from 'vue'
import App from './App.vue'
import router from './router'

Expand All @@ -14,6 +14,18 @@ import './style/index.scss'

VxeUI.setI18n('en-US', enUS)

VxeUI.renderer.add('CellImage', {
renderTableDefault (_renderOpts, params) {
const { props } = _renderOpts
const { column, row } = params
return h(VxeUI.VxeImage, {
width: '100%',
...props,
src: row[column.field]
})
}
})

createApp(App)
.use(router)
.use(VxeUI)
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.15",
"version": "4.9.16",
"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.15"
"vxe-pc-ui": "^4.3.16"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ export default defineComponent({
const showEllipsis = cellOverflow === 'ellipsis'
const showTitle = cellOverflow === 'title'
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
const hasEllipsis = showTitle || showTooltip || showEllipsis
// 如果表格加上 showOverflow 则不再支持列单独设置
const hasEllipsis = allColumnOverflow || showTitle || showTooltip || showEllipsis
let isDirty
const tdOns: any = {}
const rest = fullAllDataRowIdData[rowid]
Expand Down
102 changes: 65 additions & 37 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ export default defineComponent({
const isCustomVisible = isAllCustom || storageOpts.visible
const isCustomFixed = isAllCustom || storageOpts.fixed
const isCustomSort = isAllCustom || storageOpts.sort
if (customConfig && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
if ((customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
if (!tableId) {
errLog('vxe.error.reqProp', ['id'])
return
Expand Down Expand Up @@ -1218,12 +1218,7 @@ export default defineComponent({
}

const calcCellWidth = () => {
const { tableData } = reactData
const autoWidthColumnList = computeAutoWidthColumnList.value
if (!tableData.length || !autoWidthColumnList.length) {
reactData.isCalcColumn = false
return nextTick()
}
reactData.isCalcColumn = true
return nextTick().then(() => {
const { fullColumnIdData } = internalData
Expand Down Expand Up @@ -2523,6 +2518,7 @@ export default defineComponent({
const { editStore, scrollYLoad: oldScrollYLoad } = reactData
const { scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop } = internalData
const treeOpts = computeTreeOpts.value
const rowOpts = computeRowOpts.value
const { transform } = treeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
let treeData = []
Expand Down Expand Up @@ -2586,9 +2582,11 @@ export default defineComponent({
}
if (sYLoad) {
if (showOverflow) {
const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
if (errColumn) {
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
if (!rowOpts.height) {
const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
if (errColumn) {
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
}
}
}

Expand Down Expand Up @@ -2717,6 +2715,8 @@ export default defineComponent({
}

const parseColumns = () => {
const { showOverflow } = props
const rowOpts = computeRowOpts.value
const leftList: VxeTableDefines.ColumnInfo[] = []
const centerList: VxeTableDefines.ColumnInfo[] = []
const rightList: VxeTableDefines.ColumnInfo[] = []
Expand Down Expand Up @@ -2781,6 +2781,14 @@ export default defineComponent({
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
Object.assign(columnStore, { leftList, centerList, rightList })
if (scrollXLoad) {
if (showOverflow) {
if (!rowOpts.height) {
const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
if (errColumn) {
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
}
}
}
if (process.env.VUE_APP_VXE_ENV === 'development') {
// if (props.showHeader && !props.showHeaderOverflow) {
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
Expand Down Expand Up @@ -3066,7 +3074,7 @@ export default defineComponent({
}

const scrollXEvent = (evnt: Event) => {
const { inFooterScroll, inBodyScroll } = internalData
const { inFooterScroll, inBodyScroll, lastScrollTop } = internalData
if (inFooterScroll) {
return
}
Expand All @@ -3079,10 +3087,17 @@ export default defineComponent({
const bodyElem = tableBody.$el as HTMLDivElement
const headerElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
const footerElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
const yHandleEl = refScrollYHandleElem.value
const wrapperEl = evnt.currentTarget as HTMLDivElement
const { scrollTop, scrollLeft } = wrapperEl
const { scrollLeft } = wrapperEl
const yBodyEl = yHandleEl || bodyElem
let scrollTop = 0
if (yBodyEl) {
scrollTop = yBodyEl.scrollTop
}
const isRollX = true
const isRollY = false
const isRollY = scrollTop !== lastScrollTop

internalData.inVirtualScroll = true
setScrollLeft(bodyElem, scrollLeft)
setScrollLeft(headerElem, scrollLeft)
Expand All @@ -3095,7 +3110,7 @@ export default defineComponent({
}

const scrollYEvent = (evnt: Event) => {
const { inFooterScroll, inBodyScroll } = internalData
const { inFooterScroll, inBodyScroll, lastScrollLeft } = internalData
if (inFooterScroll) {
return
}
Expand All @@ -3109,9 +3124,15 @@ export default defineComponent({
const bodyElem = tableBody.$el as HTMLDivElement
const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
const xHandleEl = refScrollXHandleElem.value
const wrapperEl = evnt.currentTarget as HTMLDivElement
const { scrollTop, scrollLeft } = wrapperEl
const isRollX = false
const { scrollTop } = wrapperEl
const xBodyEl = xHandleEl || bodyElem
let scrollLeft = 0
if (xBodyEl) {
scrollLeft = xBodyEl.scrollLeft
}
const isRollX = scrollLeft !== lastScrollLeft
const isRollY = true

internalData.inVirtualScroll = true
Expand Down Expand Up @@ -4957,7 +4978,7 @@ export default defineComponent({
nextTick(() => {
resolve()
})
}, 50)
}, 30)
})
}
return nextTick()
Expand Down Expand Up @@ -5574,48 +5595,52 @@ export default defineComponent({
$xeTable.handleClearEdit(evnt)
// 如果配置了选中功能,则为选中状态
if (mouseOpts.selected) {
nextTick(() => $xeTable.handleSelected(params, evnt))
nextTick(() => {
$xeTable.handleSelected(params, evnt)
})
}
}
} else {
// 如果是激活状态,退则出到上一行/下一行
if (selected.row || actived.row) {
const targetArgs = selected.row ? selected.args : actived.args
const activeParams = selected.row ? selected.args : actived.args
if (hasShiftKey) {
if (keyboardOpts.enterToTab) {
$xeTable.moveTabSelected(targetArgs, hasShiftKey, evnt)
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt)
} else {
$xeTable.moveSelected(targetArgs, isLeftArrow, true, isRightArrow, false, evnt)
$xeTable.moveSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt)
}
} else {
if (keyboardOpts.enterToTab) {
$xeTable.moveTabSelected(targetArgs, hasShiftKey, evnt)
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt)
} else {
const _rowIndex = $xeTable.getVTRowIndex(selected.row)
const activeRow = selected.row || actived.row
const activeColumn = selected.column || actived.column
const _rowIndex = $xeTable.getVTRowIndex(activeRow)
const etrParams = {
row: selected.row,
rowIndex: $xeTable.getRowIndex(selected.row),
$rowIndex: $xeTable.getVMRowIndex(selected.row),
row: activeRow,
rowIndex: $xeTable.getRowIndex(activeRow),
$rowIndex: $xeTable.getVMRowIndex(activeRow),
_rowIndex,
column: selected.column,
columnIndex: $xeTable.getColumnIndex(selected.column),
$columnIndex: $xeTable.getVMColumnIndex(selected.column),
_columnIndex: $xeTable.getVTColumnIndex(selected.column),
column: activeColumn,
columnIndex: $xeTable.getColumnIndex(activeColumn),
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
_columnIndex: $xeTable.getVTColumnIndex(activeColumn),
$table: $xeTable
}
if (!beforeEnterMethod || beforeEnterMethod(etrParams) !== false) {
// 最后一行按下回车键,自动追加一行
if (isLastEnterAppendRow) {
if (_rowIndex >= afterFullData.length - 1) {
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
$xeTable.scrollToRow(newRow, selected.column)
$xeTable.setSelectCell(newRow, selected.column)
$xeTable.scrollToRow(newRow, activeColumn)
$xeTable.handleSelected({ ...activeParams, row: newRow }, evnt)
})
$xeTable.dispatchEvent('enter-append-row', etrParams, evnt)
return
}
}
$xeTable.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt)
$xeTable.moveSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
if (enterMethod) {
enterMethod(etrParams)
}
Expand Down Expand Up @@ -6234,6 +6259,7 @@ export default defineComponent({
Object.assign(reactData.columnStore, { resizeList, pxList, pxMinList, autoMinList, scaleList, scaleMinList, autoList, remainList })
},
saveCustomStore (type) {
const { customConfig } = props
const tableId = computeTableId.value
const customOpts = computeCustomOpts.value
const { updateStore, storage } = customOpts
Expand All @@ -6243,7 +6269,7 @@ export default defineComponent({
const isCustomVisible = isAllCustom || storageOpts.visible
const isCustomFixed = isAllCustom || storageOpts.fixed
const isCustomSort = isAllCustom || storageOpts.sort
if (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort) {
if ((customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
if (!tableId) {
errLog('vxe.error.reqProp', ['id'])
return nextTick()
Expand Down Expand Up @@ -7133,7 +7159,6 @@ export default defineComponent({
const trEl = evnt.currentTarget as HTMLElement
const rowid = trEl.getAttribute('rowid')
const row = $xeTable.getRowById(rowid)
console.log(rowid)
if (row) {
evnt.preventDefault()
evnt.preventDefault()
Expand Down Expand Up @@ -7370,7 +7395,8 @@ export default defineComponent({
}
tablePrivateMethods.checkScrolling()
internalData.lastScrollLeft = scrollLeft
} else {
}
if (isRollY) {
const yThreshold = computeScrollYThreshold.value
isTop = scrollTop <= 0
if (!isTop) {
Expand Down Expand Up @@ -8322,8 +8348,10 @@ export default defineComponent({
const customOpts = computeCustomOpts.value
const mouseOpts = computeMouseOpts.value
const rowOpts = computeRowOpts.value
if (!props.id && props.customConfig && (customOpts.storage === true || (customOpts.storage && customOpts.storage.resizable) || (customOpts.storage && customOpts.storage.visible))) {
errLog('vxe.error.reqProp', ['id'])
if (!props.id) {
if ((props.customConfig ? isEnableConf(customOpts) : customOpts.enabled) && customOpts.storage) {
errLog('vxe.error.reqProp', ['id'])
}
}
if (props.treeConfig && checkboxOpts.range) {
errLog('vxe.error.noTree', ['checkbox-config.range'])
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ VxeUI.setConfig({
// visibleMethod () {}
// },
customConfig: {
// enabled: false,
storage: true,
allowVisible: true,
allowResizable: true,
allowFixed: true,
Expand Down

0 comments on commit 194df36

Please sign in to comment.