Skip to content

Commit

Permalink
Update ColumnSetting.vue (vbenjs#1451)
Browse files Browse the repository at this point in the history
修复配置项中,拖拽后  点击   重置按钮   table 恢复还原,但 拖拽列表并未还原bug
  • Loading branch information
qq34347476 authored Dec 12, 2021
1 parent 23b5538 commit f6e27ae
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/Table/src/components/settings/ColumnSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,17 @@
});
setColumns(checkedList);
}
let sortable = null;
let sortableOrder = [];
// reset columns
function reset() {
state.checkedList = [...state.defaultCheckList];
state.checkAll = true;
plainOptions.value = unref(cachePlainOptions);
plainSortOptions.value = unref(cachePlainOptions);
setColumns(table.getCacheColumns());
sortable.sort(sortableOrder);
}
// Open the pop-up window for drag and drop initialization
Expand All @@ -286,8 +289,11 @@
const el = columnListEl.$el as any;
if (!el) return;
// Drag and drop sort
const { initSortable } = useSortable(el, {
handle: '.table-column-drag-icon',
sortable = Sortable.create(unref(el), {
animation: 500,
delay: 400,
delayOnTouchOnly: true,
handle: '.table-column-drag-icon ',
onEnd: (evt) => {
const { oldIndex, newIndex } = evt;
if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) {
Expand All @@ -308,7 +314,8 @@
setColumns(columns);
},
});
initSortable();
// 记录原始order 序列
sortableOrder = sortable.toArray();
inited = true;
});
}
Expand Down

0 comments on commit f6e27ae

Please sign in to comment.