Commit f6e27aee16e80bd78363387d91b5404777bb73a8
Committed by
GitHub
1 parent
23b5538e
Update ColumnSetting.vue (#1451)
修复配置项中,拖拽后 点击 重置按钮 table 恢复还原,但 拖拽列表并未还原bug
Showing
1 changed file
with
11 additions
and
4 deletions
src/components/Table/src/components/settings/ColumnSetting.vue
@@ -267,7 +267,9 @@ | @@ -267,7 +267,9 @@ | ||
267 | }); | 267 | }); |
268 | setColumns(checkedList); | 268 | setColumns(checkedList); |
269 | } | 269 | } |
270 | - | 270 | + |
271 | + let sortable = null; | ||
272 | + let sortableOrder = []; | ||
271 | // reset columns | 273 | // reset columns |
272 | function reset() { | 274 | function reset() { |
273 | state.checkedList = [...state.defaultCheckList]; | 275 | state.checkedList = [...state.defaultCheckList]; |
@@ -275,6 +277,7 @@ | @@ -275,6 +277,7 @@ | ||
275 | plainOptions.value = unref(cachePlainOptions); | 277 | plainOptions.value = unref(cachePlainOptions); |
276 | plainSortOptions.value = unref(cachePlainOptions); | 278 | plainSortOptions.value = unref(cachePlainOptions); |
277 | setColumns(table.getCacheColumns()); | 279 | setColumns(table.getCacheColumns()); |
280 | + sortable.sort(sortableOrder); | ||
278 | } | 281 | } |
279 | 282 | ||
280 | // Open the pop-up window for drag and drop initialization | 283 | // Open the pop-up window for drag and drop initialization |
@@ -286,8 +289,11 @@ | @@ -286,8 +289,11 @@ | ||
286 | const el = columnListEl.$el as any; | 289 | const el = columnListEl.$el as any; |
287 | if (!el) return; | 290 | if (!el) return; |
288 | // Drag and drop sort | 291 | // Drag and drop sort |
289 | - const { initSortable } = useSortable(el, { | ||
290 | - handle: '.table-column-drag-icon', | 292 | + sortable = Sortable.create(unref(el), { |
293 | + animation: 500, | ||
294 | + delay: 400, | ||
295 | + delayOnTouchOnly: true, | ||
296 | + handle: '.table-column-drag-icon ', | ||
291 | onEnd: (evt) => { | 297 | onEnd: (evt) => { |
292 | const { oldIndex, newIndex } = evt; | 298 | const { oldIndex, newIndex } = evt; |
293 | if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { | 299 | if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { |
@@ -308,7 +314,8 @@ | @@ -308,7 +314,8 @@ | ||
308 | setColumns(columns); | 314 | setColumns(columns); |
309 | }, | 315 | }, |
310 | }); | 316 | }); |
311 | - initSortable(); | 317 | + // 记录原始order 序列 |
318 | + sortableOrder = sortable.toArray(); | ||
312 | inited = true; | 319 | inited = true; |
313 | }); | 320 | }); |
314 | } | 321 | } |