diff --git a/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts b/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts index a697100..5d8dd63 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts @@ -39,6 +39,11 @@ export function useDragSort(props: JVxeTableProps, methods: JVxeTableMethods) { if (oldIndex === newIndex) { return; } + // 【VUEN-2505】获取当前行数据 + let rowNode = xTable.getRowNode(e.item); + if (!rowNode) { + return; + } let from = e.from; let element = startChildren[oldIndex]; let target = null; @@ -54,6 +59,12 @@ export function useDragSort(props: JVxeTableProps, methods: JVxeTableMethods) { from.removeChild(element); from.insertBefore(element, target); nextTick(() => { + // 【VUEN-2505】算出因虚拟滚动导致的偏移量 + let diffIndex = rowNode!.index - oldIndex; + if (diffIndex > 0) { + oldIndex = oldIndex + diffIndex; + newIndex = newIndex + diffIndex; + } methods.doSort(oldIndex, newIndex); methods.trigger('dragged', { oldIndex, newIndex }); }); diff --git a/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts b/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts index 7e69cf0..7bc5cbd 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts @@ -28,8 +28,8 @@ export function useJVxeComponent(props: JVxeComponent.Props) { const column = computed(() => props.params.column); // 用户配置的原始 column const originColumn = computed(() => column.value.params); - const rowIndex = computed(() => props.params.$rowIndex); - const columnIndex = computed(() => props.params.columnIndex); + const rowIndex = computed(() => props.params._rowIndex); + const columnIndex = computed(() => props.params._columnIndex); // 表格数据长度 const fullDataLength = computed(() => props.params.$table.internalData.tableFullData.length); // 是否正在滚动中