Compare commits

..

No commits in common. "0dd7f54ebc3518404653d6e43ee428e05566dd28" and "2667981e4c0c451ded88e06f412dd4bcb5ec41dc" have entirely different histories.

6 changed files with 9 additions and 30 deletions

View File

@ -721,10 +721,6 @@ export interface TableConfig extends FormItem {
defaultSort?: SortProp;
/** 是否支持拖拽排序 */
dropSort?: boolean;
dropSortHandle?: boolean;
dropActionButtonIcon?: any;
copyActionButtonIcon?: any;
deleteActionButtonIcon?: any;
/** 是否显示全屏按钮 */
enableFullscreen?: boolean;
fixed?: boolean | 'left' | 'right';

View File

@ -1,21 +1,12 @@
<template>
<slot name="operateCol" :scope="{ $index: index, row: row }"></slot>
<TMagicTooltip v-if="config.dropSort && config.dropSortHandle" content="拖动排序" placement="left-start">
<TMagicButton
size="small"
link
:class="{ 'tmagic-form-table-drag-target': config.dropSortHandle }"
:icon="config.dropActionButtonIcon || Sort"
>
</TMagicButton>
</TMagicTooltip>
<TMagicButton
v-show="showDelete(index + 1 + currentPage * pageSize - 1)"
size="small"
type="danger"
link
title="删除"
:icon="config.deleteActionButtonIcon || Delete"
:icon="Delete"
@click="removeHandler(index + 1 + currentPage * pageSize - 1)"
></TMagicButton>
@ -25,7 +16,7 @@
size="small"
type="primary"
title="复制"
:icon="config.copyActionButtonIcon || DocumentCopy"
:icon="DocumentCopy"
:disabled="disabled"
@click="copyHandler(index + 1 + currentPage * pageSize - 1)"
></TMagicButton>
@ -33,10 +24,10 @@
<script setup lang="ts">
import { inject } from 'vue';
import { Delete, DocumentCopy, Sort } from '@element-plus/icons-vue';
import { Delete, DocumentCopy } from '@element-plus/icons-vue';
import { cloneDeep } from 'lodash-es';
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
import { TMagicButton } from '@tmagic/design';
import type { FormState, TableConfig } from '../schema';

View File

@ -8,11 +8,7 @@
>
<div class="m-fields-table" :class="{ 'm-fields-table-item-extra': config.itemExtra }">
<span v-if="config.extra" style="color: rgba(0, 0, 0, 0.45)" v-html="config.extra"></span>
<TMagicTooltip
content="拖拽可排序"
placement="left-start"
:disabled="config.dropSort !== true || config.dropSortHandle"
>
<TMagicTooltip content="拖拽可排序" placement="left-start" :disabled="config.dropSort !== true">
<TMagicTable
v-if="model[modelName]"
ref="tMagicTable"

View File

@ -30,7 +30,6 @@ export const useSortable = (
filter: 'input', // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
preventOnFilter: false, // 允许选字
direction: 'vertical',
handle: props.config.dropSortHandle ? '.tmagic-form-table-drag-target' : undefined,
onEnd: ({ newIndex, oldIndex }: SortableEvent) => {
if (typeof newIndex === 'undefined') return;
if (typeof oldIndex === 'undefined') return;
@ -39,9 +38,10 @@ export const useSortable = (
emit('change', newData);
mForm?.$emit('field-change', newData);
sortable?.destroy();
sortable = undefined;
nextTick(() => {
sortable?.destroy();
sortable = undefined;
updateKey.value += 1;
});
},

View File

@ -111,7 +111,7 @@ export const useTableColumns = (
props: {
label: '操作',
fixed: actionFixed,
width: props.config.operateColWidth ?? (props.config.dropSortHandle && props.config.dropSort ? 132 : 112),
width: props.config.operateColWidth || 112,
align: 'center',
},
cell: ({ row, $index }: any) =>

View File

@ -65,8 +65,4 @@
.el-form-item {
margin-bottom: 0;
}
.tmagic-form-table-drag-target {
cursor: move;
}
}