Skip to content

Commit

Permalink
releases 4.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Nov 9, 2024
1 parent 8ec2145 commit 7faa5c1
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 68 deletions.
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.8.8",
"version": "4.8.9",
"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.2.46"
"vxe-pc-ui": "^4.2.49"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
12 changes: 4 additions & 8 deletions packages/table/src/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,9 @@ export default defineComponent({
setScrollTop(leftElem, scrollTop)
setScrollTop(rightElem, scrollTop)
}
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
type: renderType,
fixed: fixedType,
scrollTop,
scrollLeft
fixed: fixedType
})
}
if (xHandleEl) {
Expand All @@ -562,11 +560,9 @@ export default defineComponent({
tableInternalData.lastScrollLeft = scrollLeft
setScrollLeft(headerElem, scrollLeft)
setScrollLeft(footerElem, scrollLeft)
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
type: renderType,
fixed: fixedType,
scrollTop,
scrollLeft
fixed: fixedType
})
}
}
Expand Down
6 changes: 2 additions & 4 deletions packages/table/src/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ export default defineComponent({
tableReactData.lastScrollTime = Date.now()
setScrollLeft(headerElem, scrollLeft)
setScrollLeft(bodyElem, scrollLeft)
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
type: renderType,
fixed: fixedType,
scrollTop,
scrollLeft
fixed: fixedType
})
}
}
Expand Down
187 changes: 133 additions & 54 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2955,11 +2955,9 @@ export default defineComponent({
reactData.lastScrollTime = Date.now()
handleSyncScrollX(scrollLeft)
$xeTable.triggerScrollXEvent(evnt)
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
type: 'table',
fixed: '',
scrollTop,
scrollLeft
fixed: ''
})
}

Expand Down Expand Up @@ -2988,11 +2986,9 @@ export default defineComponent({
reactData.lastScrollTime = Date.now()
handleSyncScrollY(scrollTop)
$xeTable.triggerScrollYEvent(evnt)
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
type: 'table',
fixed: '',
scrollTop,
scrollLeft
fixed: ''
})
}

Expand Down Expand Up @@ -3642,25 +3638,35 @@ export default defineComponent({
* 设置为固定列
*/
setColumnFixed (fieldOrColumn, fixed) {
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
const targetColumn = getRootColumn($xeTable, column as any)
const isMaxFixedColumn = computeIsMaxFixedColumn.value
let status = false
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
const columnOpts = computeColumnOpts.value
if (targetColumn && targetColumn.fixed !== fixed) {
// 是否超过最大固定列数量
if (!targetColumn.fixed && isMaxFixedColumn) {
if (VxeUI.modal) {
VxeUI.modal.message({
status: 'error',
content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
})
const isMaxFixedColumn = computeIsMaxFixedColumn.value
for (let i = 0; i < cols.length; i++) {
const item = cols[i]
const column = handleFieldOrColumn($xeTable, item)
const targetColumn = getRootColumn($xeTable, column as any)
if (targetColumn && targetColumn.fixed !== fixed) {
// 是否超过最大固定列数量
if (!targetColumn.fixed && isMaxFixedColumn) {
if (VxeUI.modal) {
VxeUI.modal.message({
status: 'error',
content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
})
}
return nextTick()
}
XEUtils.eachTree([targetColumn], (column) => {
column.fixed = fixed
})
tablePrivateMethods.saveCustomStore('update:fixed')
if (!status) {
status = true
}
return nextTick()
}
XEUtils.eachTree([targetColumn], (column) => {
column.fixed = fixed
})
tablePrivateMethods.saveCustomStore('update:fixed')
}
if (status) {
return tableMethods.refreshColumn()
}
return nextTick()
Expand All @@ -3669,13 +3675,22 @@ export default defineComponent({
* 取消指定固定列
*/
clearColumnFixed (fieldOrColumn) {
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
const targetColumn = getRootColumn($xeTable, column as any)
if (targetColumn && targetColumn.fixed) {
XEUtils.eachTree([targetColumn], (column) => {
column.fixed = null
})
tablePrivateMethods.saveCustomStore('update:fixed')
let status = false
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
cols.forEach(item => {
const column = handleFieldOrColumn($xeTable, item)
const targetColumn = getRootColumn($xeTable, column as any)
if (targetColumn && targetColumn.fixed) {
XEUtils.eachTree([targetColumn], (column) => {
column.fixed = null
})
tablePrivateMethods.saveCustomStore('update:fixed')
if (!status) {
status = true
}
}
})
if (status) {
return tableMethods.refreshColumn()
}
return nextTick()
Expand All @@ -3684,9 +3699,18 @@ export default defineComponent({
* 隐藏指定列
*/
hideColumn (fieldOrColumn) {
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
if (column && column.visible) {
column.visible = false
let status = false
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
cols.forEach(item => {
const column = handleFieldOrColumn($xeTable, item)
if (column && column.visible) {
column.visible = false
if (!status) {
status = true
}
}
})
if (status) {
return tablePrivateMethods.handleCustom()
}
return nextTick()
Expand All @@ -3695,25 +3719,43 @@ export default defineComponent({
* 显示指定列
*/
showColumn (fieldOrColumn) {
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
if (column && !column.visible) {
column.visible = true
let status = false
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
cols.forEach(item => {
const column = handleFieldOrColumn($xeTable, item)
if (column && !column.visible) {
column.visible = true
if (!status) {
status = true
}
}
})
if (status) {
return tablePrivateMethods.handleCustom()
}
return nextTick()
},
setColumnWidth (fieldOrColumn, width) {
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
if (column) {
const colWidth = XEUtils.toInteger(width)
let rdWidth = colWidth
if (isScale(width)) {
const tableBody = refTableBody.value
const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0
rdWidth = Math.floor(colWidth * bodyWidth)
}
column.resizeWidth = rdWidth
let status = false
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
cols.forEach(item => {
const column = handleFieldOrColumn($xeTable, item)
if (column) {
const colWidth = XEUtils.toInteger(width)
let rdWidth = colWidth
if (isScale(width)) {
const tableBody = refTableBody.value
const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0
rdWidth = Math.floor(colWidth * bodyWidth)
}
column.resizeWidth = rdWidth
if (!status) {
status = true
}
}
})
if (status) {
return tableMethods.refreshColumn()
}
return nextTick()
Expand Down Expand Up @@ -4668,16 +4710,34 @@ export default defineComponent({
*/
scrollTo (scrollLeft: number, scrollTop?: number) {
const tableBody = refTableBody.value
const tableHeader = refTableHeader.value
const tableFooter = refTableFooter.value
const leftBody = refTableLeftBody.value
const rightBody = refTableRightBody.value
const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
const leftBodyElem = leftBody ? leftBody.$el as HTMLDivElement : null
const rightBodyElem = rightBody ? rightBody.$el as HTMLDivElement : null
const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
const tableFooterElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
if (XEUtils.isNumber(scrollLeft)) {
setScrollLeft(tableFooterElem || tableBodyElem, scrollLeft)
const xHandleEl = refScrollXHandleElem.value
if (xHandleEl) {
setScrollLeft(xHandleEl, scrollLeft)
} else {
setScrollLeft(tableBodyElem, scrollLeft)
setScrollLeft(tableHeaderElem, scrollLeft)
setScrollLeft(tableFooterElem, scrollLeft)
}
}
if (XEUtils.isNumber(scrollTop)) {
setScrollTop(rightBodyElem || tableBodyElem, scrollTop)
const yHandleEl = refScrollYHandleElem.value
if (yHandleEl) {
setScrollTop(yHandleEl, scrollTop)
} else {
setScrollTop(tableBodyElem, scrollTop)
setScrollTop(leftBodyElem, scrollTop)
setScrollTop(rightBodyElem, scrollTop)
}
}
if (reactData.scrollXLoad || reactData.scrollYLoad) {
return new Promise(resolve => {
Expand Down Expand Up @@ -6811,7 +6871,7 @@ export default defineComponent({
triggerScrollXEvent () {
loadScrollXData()
},
handleScrollEvent (evnt, isRollY, isRollX, params) {
handleScrollEvent (evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
const { highlightHoverRow } = props
const tableBody = refTableBody.value
const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
Expand All @@ -6827,20 +6887,39 @@ export default defineComponent({
if (tooltip && tooltip.reactData.visible) {
tooltip.close()
}
if (isRollX) {
tablePrivateMethods.checkScrolling()
}
const bodyHeight = bodyElem ? bodyElem.clientHeight : 0
const bodyWidth = bodyElem ? bodyElem.clientWidth : 0
const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0
const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0
let isTop = false
let isBottom = false
let isLeft = false
let isRight = false
if (isRollX) {
isLeft = scrollLeft <= 0
if (!isTop) {
isRight = scrollLeft + bodyWidth >= scrollWidth
}
tablePrivateMethods.checkScrolling()
} else {
isTop = scrollTop <= 0
if (!isTop) {
isBottom = scrollTop + bodyHeight >= scrollHeight
}
}
const evntParams = {
scrollTop,
scrollLeft,
bodyHeight,
bodyWidth,
scrollHeight,
scrollWidth,
isX: isRollX,
isY: isRollY,
isTop,
isBottom,
isLeft,
isRight,
...params
}
dispatchEvent('scroll', evntParams, evnt)
Expand Down

0 comments on commit 7faa5c1

Please sign in to comment.