在线表单》数据库属性模块,对字段跨多字段进行拖拽排序时,无法成功。 #191

This commit is contained in:
zhangdaiscott 2022-10-28 21:08:24 +08:00
parent 166f7e1888
commit e581f7f7eb
2 changed files with 13 additions and 2 deletions

View File

@ -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 });
});

View File

@ -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);
// 是否正在滚动中