mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-11-29 22:12:11 +08:00
fix(form): table拖拽排序后重新渲染组件
This commit is contained in:
parent
b536eba81c
commit
2667981e4c
@ -133,16 +133,15 @@ const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentCh
|
||||
);
|
||||
|
||||
const { nextZIndex } = useZIndex();
|
||||
const updateKey = ref(1);
|
||||
|
||||
const { addable, newHandler } = useAdd(props, emit);
|
||||
const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
|
||||
useSortable(props, emit, tMagicTableRef, modelName);
|
||||
useSortable(props, emit, tMagicTableRef, modelName, updateKey);
|
||||
const { isFullscreen, toggleFullscreen } = useFullscreen();
|
||||
const { importable, excelHandler, clearHandler } = useImport(props, emit, newHandler);
|
||||
const { selectHandle, toggleRowSelection } = useSelection(props, emit, tMagicTableRef);
|
||||
|
||||
const updateKey = ref(1);
|
||||
|
||||
const data = computed(() => (props.config.pagination ? paginationData.value : props.model[modelName.value]));
|
||||
|
||||
const toggleMode = () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { inject, type Ref, type ShallowRef, watchEffect } from 'vue';
|
||||
import { inject, nextTick, type Ref, type ShallowRef, watchEffect } from 'vue';
|
||||
import Sortable, { type SortableEvent } from 'sortablejs';
|
||||
|
||||
import { type TMagicTable } from '@tmagic/design';
|
||||
@ -13,6 +13,7 @@ export const useSortable = (
|
||||
emit: (event: 'select' | 'change' | 'addDiffCount', ...args: any[]) => void,
|
||||
tMagicTableRef: ShallowRef<InstanceType<typeof TMagicTable> | null>,
|
||||
modelName: Ref<string | number>,
|
||||
updateKey: Ref<number>,
|
||||
) => {
|
||||
const mForm = inject<FormState | undefined>('mForm');
|
||||
|
||||
@ -36,6 +37,13 @@ export const useSortable = (
|
||||
|
||||
emit('change', newData);
|
||||
mForm?.$emit('field-change', newData);
|
||||
|
||||
sortable?.destroy();
|
||||
sortable = undefined;
|
||||
|
||||
nextTick(() => {
|
||||
updateKey.value += 1;
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -107,7 +107,7 @@ export const useTableColumns = (
|
||||
actionFixed = props.config.fixed;
|
||||
}
|
||||
|
||||
const actionClumn = {
|
||||
const actionColumn = {
|
||||
props: {
|
||||
label: '操作',
|
||||
fixed: actionFixed,
|
||||
@ -133,7 +133,7 @@ export const useTableColumns = (
|
||||
};
|
||||
|
||||
if (actionFixed !== 'right') {
|
||||
columns.push(actionClumn);
|
||||
columns.push(actionColumn);
|
||||
}
|
||||
|
||||
if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) {
|
||||
@ -237,7 +237,7 @@ export const useTableColumns = (
|
||||
}
|
||||
|
||||
if (actionFixed === 'right') {
|
||||
columns.push(actionClumn);
|
||||
columns.push(actionColumn);
|
||||
}
|
||||
|
||||
return columns;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user