mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
修复滚动加载数据滚动条异常问题
This commit is contained in:
@@ -627,6 +627,9 @@ const gridAPI: any = XEUtils.clone(tableAPI, true).map((item: any) => {
|
||||
})
|
||||
|
||||
XEUtils.eachTree(gridAPI, (item: any, index, obj, paths, parent) => {
|
||||
if (parent && ['export-config', 'print-config'].includes(parent.name) && item.name === 'modes') {
|
||||
item.desc = '输出数据的方式列表,如果为 all,则会通过 proxy-config.ajax.queryAll 获取数据之后进行导出'
|
||||
}
|
||||
if (parent && parent.name === 'buttons' && item.name === 'code') {
|
||||
item.list = [
|
||||
{
|
||||
|
||||
@@ -3976,7 +3976,7 @@ const apis = [
|
||||
},
|
||||
{
|
||||
name: 'setCellAreas(areaConfigs, activeArea)',
|
||||
desc: '如果功能被支持,用于 mouse-config.area,选择指定区域的单元格',
|
||||
desc: '如果功能被支持,用于 mouse-config.area,选择指定区域的单元格(示例:setCellAreas([{ startRow, endRow, startColumn, endColumn }]))',
|
||||
version: 'pro',
|
||||
type: 'Promise<any>',
|
||||
enum: '',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createCommentVNode, defineComponent, h, ref, Ref, PropType, inject, nex
|
||||
import XEUtils from 'xe-utils'
|
||||
import GlobalConfig from '../../v-x-e-table/src/conf'
|
||||
import { VXETable } from '../../v-x-e-table'
|
||||
import { mergeBodyMethod, getRowid, getPropClass } from './util'
|
||||
import { mergeBodyMethod, getRowid, getPropClass, removeScrollListener, restoreScrollListener, XEBodyScrollElement } from './util'
|
||||
import { browse, updateCellTitle } from '../../tools/dom'
|
||||
import { isEnableConf } from '../../tools/utils'
|
||||
|
||||
@@ -16,10 +16,6 @@ const lineOffsetSizes = {
|
||||
medium: 1
|
||||
}
|
||||
|
||||
interface XEBodyScrollElement extends HTMLDivElement {
|
||||
_onscroll: ((evnt: Event) => void) | null;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VxeTableBody',
|
||||
props: {
|
||||
@@ -390,24 +386,20 @@ export default defineComponent({
|
||||
* 同步滚动条
|
||||
*/
|
||||
let scrollProcessTimeout: any
|
||||
const syncBodyScroll = (scrollTop: number, elem1?: XEBodyScrollElement | null, elem2?: XEBodyScrollElement | null) => {
|
||||
const syncBodyScroll = (scrollTop: number, elem1: XEBodyScrollElement | null, elem2: XEBodyScrollElement | null) => {
|
||||
if (elem1 || elem2) {
|
||||
if (elem1) {
|
||||
elem1.onscroll = null
|
||||
removeScrollListener(elem1)
|
||||
elem1.scrollTop = scrollTop
|
||||
}
|
||||
if (elem2) {
|
||||
elem2.onscroll = null
|
||||
removeScrollListener(elem2)
|
||||
elem2.scrollTop = scrollTop
|
||||
}
|
||||
clearTimeout(scrollProcessTimeout)
|
||||
scrollProcessTimeout = setTimeout(function () {
|
||||
if (elem1) {
|
||||
elem1.onscroll = elem1._onscroll
|
||||
}
|
||||
if (elem2) {
|
||||
elem2.onscroll = elem2._onscroll
|
||||
}
|
||||
restoreScrollListener(elem1)
|
||||
restoreScrollListener(elem2)
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import Cell from './cell'
|
||||
import TableBodyComponent from './body'
|
||||
import tableProps from './props'
|
||||
import tableEmits from './emits'
|
||||
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, restoreScroll } from './util'
|
||||
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, restoreScrollLocation, restoreScrollListener, XEBodyScrollElement } from './util'
|
||||
|
||||
import { VxeGridConstructor, VxeGridPrivateMethods, VxeTableConstructor, TableReactData, TableInternalData, VxeTablePropTypes, VxeToolbarConstructor, VxeTooltipInstance, TablePrivateMethods, TablePrivateRef, VxeTablePrivateComputed, VxeTablePrivateMethods, VxeTableMethods, TableMethods, VxeMenuPanelInstance, VxeTableDefines, VxeTableProps } from '../../../types/all'
|
||||
|
||||
@@ -1859,9 +1859,9 @@ export default defineComponent({
|
||||
.then(() => {
|
||||
// 是否变更虚拟滚动
|
||||
if (oldScrollYLoad === scrollYLoad) {
|
||||
restoreScroll($xetable, lastScrollLeft, lastScrollTop).then(resolve)
|
||||
restoreScrollLocation($xetable, lastScrollLeft, lastScrollTop).then(resolve)
|
||||
} else {
|
||||
setTimeout(() => restoreScroll($xetable, lastScrollLeft, lastScrollTop).then(resolve))
|
||||
setTimeout(() => restoreScrollLocation($xetable, lastScrollLeft, lastScrollTop).then(resolve))
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -2690,7 +2690,7 @@ export default defineComponent({
|
||||
const tableFooterElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
|
||||
// 还原滚动条位置
|
||||
if (lastScrollLeft || lastScrollTop) {
|
||||
return restoreScroll($xetable, lastScrollLeft, lastScrollTop)
|
||||
return restoreScrollLocation($xetable, lastScrollLeft, lastScrollTop)
|
||||
}
|
||||
// 重置
|
||||
setScrollTop(tableBodyElem, lastScrollTop)
|
||||
@@ -3582,16 +3582,18 @@ export default defineComponent({
|
||||
const tableBody = refTableBody.value
|
||||
const tableFooter = refTableFooter.value
|
||||
const rightBody = refTableRightBody.value
|
||||
const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
|
||||
const rightBodyElem = rightBody ? rightBody.$el as HTMLDivElement : null
|
||||
const tableBodyElem = tableBody ? tableBody.$el as XEBodyScrollElement : null
|
||||
const rightBodyElem = rightBody ? rightBody.$el as XEBodyScrollElement : null
|
||||
const tableFooterElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
|
||||
if (rightBodyElem) {
|
||||
restoreScrollListener(rightBodyElem)
|
||||
rightBodyElem.scrollTop = 0
|
||||
}
|
||||
if (tableFooterElem) {
|
||||
tableFooterElem.scrollLeft = 0
|
||||
}
|
||||
if (tableBodyElem) {
|
||||
restoreScrollListener(tableBodyElem)
|
||||
tableBodyElem.scrollTop = 0
|
||||
tableBodyElem.scrollLeft = 0
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ import { isPx, isScale } from '../../tools/dom'
|
||||
|
||||
import { VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines, VxeColumnProps } from '../../../types/all'
|
||||
|
||||
export function restoreScroll ($xetable: VxeTableConstructor, scrollLeft: number, scrollTop: number) {
|
||||
export interface XEBodyScrollElement extends HTMLDivElement {
|
||||
_onscroll: ((evnt: Event) => void) | null;
|
||||
}
|
||||
|
||||
export function restoreScrollLocation ($xetable: VxeTableConstructor, scrollLeft: number, scrollTop: number) {
|
||||
const { internalData } = $xetable
|
||||
return $xetable.clearScroll().then(() => {
|
||||
if (scrollLeft || scrollTop) {
|
||||
@@ -18,6 +22,18 @@ export function restoreScroll ($xetable: VxeTableConstructor, scrollLeft: number
|
||||
})
|
||||
}
|
||||
|
||||
export function removeScrollListener (scrollElem: XEBodyScrollElement | null) {
|
||||
if (scrollElem && scrollElem._onscroll) {
|
||||
scrollElem.onscroll = null
|
||||
}
|
||||
}
|
||||
|
||||
export function restoreScrollListener (scrollElem: XEBodyScrollElement | null) {
|
||||
if (scrollElem && scrollElem._onscroll) {
|
||||
scrollElem.onscroll = scrollElem._onscroll
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成行的唯一主键
|
||||
*/
|
||||
|
||||
6
types/plugins/pro.d.ts
vendored
6
types/plugins/pro.d.ts
vendored
@@ -141,15 +141,15 @@ export namespace VxeTableProDefines {
|
||||
|
||||
export interface CellAreaConfig {
|
||||
type?: CELL_AREA_TYPE;
|
||||
startColumn: VxeTableDefines.ColumnInfo;
|
||||
endColumn: VxeTableDefines.ColumnInfo;
|
||||
startColumn: VxeTableDefines.ColumnInfo | number;
|
||||
endColumn: VxeTableDefines.ColumnInfo | number;
|
||||
startRow: any;
|
||||
endRow: any;
|
||||
}
|
||||
|
||||
export interface ActiveCellAreaConfig {
|
||||
area: VxeTableProDefines.MouseCellArea;
|
||||
column: VxeTableDefines.ColumnInfo;
|
||||
column: VxeTableDefines.ColumnInfo | number;
|
||||
row: any;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user