fix(BasicTable): ColumnSetting mistake when use setColumns (#3408)

This commit is contained in:
xachary 2023-12-13 09:10:17 +08:00 committed by GitHub
parent d3600daf5c
commit fec67b4d53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 28 deletions

View File

@ -113,7 +113,6 @@
import { getPopupContainer as getParentContainer } from '@/utils';
import { cloneDeep } from 'lodash-es';
import Sortablejs from 'sortablejs';
import type Sortable from 'sortablejs';
//
import { useTableSettingStore } from '@/store/modules/tableSetting';
@ -251,10 +250,6 @@
} as CheckboxChangeEvent);
//
columnOptions.value = cloneDeep(defaultColumnOptions);
//
sortableOrder = defaultSortableOrder;
//
sortable?.sort(defaultSortableOrder);
//
formUpdate();
};
@ -307,11 +302,6 @@
return false;
};
// sortable
let sortable: Sortable;
//
let sortableOrder: string[] = [];
//
const getTableColumns = () => {
return table
@ -365,7 +355,7 @@
if (columnOptionsRef.value) {
//
const el = (columnOptionsRef.value as InstanceType<typeof Checkbox.Group>).$el;
sortable = Sortablejs.create(unref(el), {
Sortablejs.create(unref(el), {
animation: 500,
delay: 400,
delayOnTouchOnly: true,
@ -397,9 +387,6 @@
columnOptionsSave();
},
});
//
sortable.sort(sortableOrder);
}
};
@ -473,10 +460,6 @@
const isColumnAllSelectedUpdate = () => {
isColumnAllSelected.value = columnOptions.value.length === columnCheckedOptions.value.length;
};
//
const sortableOrderUpdateByOptions = (options: ColumnOptionsType[]) => {
sortableOrder = options.map((o) => o.value);
};
// showIndexColumn
const showIndexColumnUpdate = (showIndexColumn) => {
isInnerChange = true;
@ -505,9 +488,6 @@
//
isColumnAllSelectedUpdate();
//
sortableOrderUpdateByOptions(columnOptions.value);
// showIndexColumn
showIndexColumnUpdate(isIndexColumnShow.value);
@ -523,12 +503,9 @@
let defaultIsRowSelectionShow: boolean = false;
let defaultRowSelection: TableRowSelection<Recordable<any>>;
let defaultColumnOptions: ColumnOptionsType[] = [];
let defaultSortableOrder: string[] = [];
const init = async () => {
if (!isRestored) {
await sortableFix();
//
const columns = getTableColumns();
@ -559,9 +536,6 @@
});
}
// 使
defaultSortableOrder = options.map((o) => o.value);
//
defaultIsIndexColumnShow = table.getBindValues.value.showIndexColumn || false;
defaultRowSelection = table.getRowSelection();
@ -587,7 +561,12 @@
};
//
init();
const once = async () => {
//
await sortableFix();
init();
};
once();
//
const getColumns = computed(() => {