mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-12-10 18:02:53 +00:00
Compare commits
2 Commits
2667981e4c
...
0dd7f54ebc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dd7f54ebc | ||
|
|
69ac90fe22 |
@ -721,6 +721,10 @@ export interface TableConfig extends FormItem {
|
||||
defaultSort?: SortProp;
|
||||
/** 是否支持拖拽排序 */
|
||||
dropSort?: boolean;
|
||||
dropSortHandle?: boolean;
|
||||
dropActionButtonIcon?: any;
|
||||
copyActionButtonIcon?: any;
|
||||
deleteActionButtonIcon?: any;
|
||||
/** 是否显示全屏按钮 */
|
||||
enableFullscreen?: boolean;
|
||||
fixed?: boolean | 'left' | 'right';
|
||||
|
||||
@ -1,12 +1,21 @@
|
||||
<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="Delete"
|
||||
:icon="config.deleteActionButtonIcon || Delete"
|
||||
@click="removeHandler(index + 1 + currentPage * pageSize - 1)"
|
||||
></TMagicButton>
|
||||
|
||||
@ -16,7 +25,7 @@
|
||||
size="small"
|
||||
type="primary"
|
||||
title="复制"
|
||||
:icon="DocumentCopy"
|
||||
:icon="config.copyActionButtonIcon || DocumentCopy"
|
||||
:disabled="disabled"
|
||||
@click="copyHandler(index + 1 + currentPage * pageSize - 1)"
|
||||
></TMagicButton>
|
||||
@ -24,10 +33,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject } from 'vue';
|
||||
import { Delete, DocumentCopy } from '@element-plus/icons-vue';
|
||||
import { Delete, DocumentCopy, Sort } from '@element-plus/icons-vue';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
import { TMagicButton } from '@tmagic/design';
|
||||
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
||||
|
||||
import type { FormState, TableConfig } from '../schema';
|
||||
|
||||
|
||||
@ -8,7 +8,11 @@
|
||||
>
|
||||
<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">
|
||||
<TMagicTooltip
|
||||
content="拖拽可排序"
|
||||
placement="left-start"
|
||||
:disabled="config.dropSort !== true || config.dropSortHandle"
|
||||
>
|
||||
<TMagicTable
|
||||
v-if="model[modelName]"
|
||||
ref="tMagicTable"
|
||||
|
||||
@ -30,6 +30,7 @@ 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;
|
||||
@ -38,10 +39,9 @@ export const useSortable = (
|
||||
emit('change', newData);
|
||||
mForm?.$emit('field-change', newData);
|
||||
|
||||
sortable?.destroy();
|
||||
sortable = undefined;
|
||||
|
||||
nextTick(() => {
|
||||
sortable?.destroy();
|
||||
sortable = undefined;
|
||||
updateKey.value += 1;
|
||||
});
|
||||
},
|
||||
|
||||
@ -111,7 +111,7 @@ export const useTableColumns = (
|
||||
props: {
|
||||
label: '操作',
|
||||
fixed: actionFixed,
|
||||
width: props.config.operateColWidth || 112,
|
||||
width: props.config.operateColWidth ?? (props.config.dropSortHandle && props.config.dropSort ? 132 : 112),
|
||||
align: 'center',
|
||||
},
|
||||
cell: ({ row, $index }: any) =>
|
||||
|
||||
@ -65,4 +65,8 @@
|
||||
.el-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.tmagic-form-table-drag-target {
|
||||
cursor: move;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user