Update ColumnSetting.vue (#1451)

修复配置项中,拖拽后  点击   重置按钮   table 恢复还原,但 拖拽列表并未还原bug
This commit is contained in:
Jiang 2021-12-12 22:09:29 +08:00 committed by GitHub
parent 23b5538eae
commit f6e27aee16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -267,7 +267,9 @@
}); });
setColumns(checkedList); setColumns(checkedList);
} }
let sortable = null;
let sortableOrder = [];
// reset columns // reset columns
function reset() { function reset() {
state.checkedList = [...state.defaultCheckList]; state.checkedList = [...state.defaultCheckList];
@ -275,6 +277,7 @@
plainOptions.value = unref(cachePlainOptions); plainOptions.value = unref(cachePlainOptions);
plainSortOptions.value = unref(cachePlainOptions); plainSortOptions.value = unref(cachePlainOptions);
setColumns(table.getCacheColumns()); setColumns(table.getCacheColumns());
sortable.sort(sortableOrder);
} }
// Open the pop-up window for drag and drop initialization // Open the pop-up window for drag and drop initialization
@ -286,8 +289,11 @@
const el = columnListEl.$el as any; const el = columnListEl.$el as any;
if (!el) return; if (!el) return;
// Drag and drop sort // Drag and drop sort
const { initSortable } = useSortable(el, { sortable = Sortable.create(unref(el), {
handle: '.table-column-drag-icon', animation: 500,
delay: 400,
delayOnTouchOnly: true,
handle: '.table-column-drag-icon ',
onEnd: (evt) => { onEnd: (evt) => {
const { oldIndex, newIndex } = evt; const { oldIndex, newIndex } = evt;
if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) {
@ -308,7 +314,8 @@
setColumns(columns); setColumns(columns);
}, },
}); });
initSortable(); // order
sortableOrder = sortable.toArray();
inited = true; inited = true;
}); });
} }