|
@@ -13,21 +13,9 @@
|
|
|
<slot :name="item" v-bind="data"></slot>
|
|
|
</template>
|
|
|
</BasicForm>
|
|
|
-
|
|
|
- <!-- <draggable
|
|
|
- v-model="getBindValues.dataSource"
|
|
|
- group="title"
|
|
|
- @start="drag = true"
|
|
|
- @end="drag = false"
|
|
|
- item-key="id"
|
|
|
- >
|
|
|
- <template #item="{ element }">
|
|
|
- <div>{{ element }}</div>
|
|
|
- </template>
|
|
|
- </draggable> -->
|
|
|
-
|
|
|
<Table
|
|
|
ref="tableElRef"
|
|
|
+ class="mytable"
|
|
|
v-bind="getBindValues"
|
|
|
:rowClassName="getRowClassName"
|
|
|
v-show="getEmptyDataIsShowTable"
|
|
@@ -51,7 +39,7 @@
|
|
|
ColumnChangeParam,
|
|
|
} from './types/table';
|
|
|
|
|
|
- import { defineComponent, ref, computed, unref, toRaw } from 'vue';
|
|
|
+ import { defineComponent, ref, computed, unref, toRaw, onMounted } from 'vue';
|
|
|
import { Table } from 'ant-design-vue';
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
import expandIcon from './components/ExpandIcon';
|
|
@@ -73,7 +61,7 @@
|
|
|
import { useTableForm } from './hooks/useTableForm';
|
|
|
import { useExpose } from '/@/hooks/core/useExpose';
|
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
|
- import draggable from 'vuedraggable/src/vuedraggable';
|
|
|
+ import Sortable from 'sortablejs';
|
|
|
import { omit } from 'lodash-es';
|
|
|
import { basicProps } from './props';
|
|
|
import { isFunction } from '/@/utils/is';
|
|
@@ -83,7 +71,6 @@
|
|
|
Table,
|
|
|
BasicForm,
|
|
|
HeaderCell,
|
|
|
- draggable,
|
|
|
},
|
|
|
props: basicProps,
|
|
|
emits: [
|
|
@@ -91,6 +78,7 @@
|
|
|
'fetch-error',
|
|
|
'selection-change',
|
|
|
'register',
|
|
|
+ 'dragRow',
|
|
|
'row-click',
|
|
|
'row-dbClick',
|
|
|
'row-contextmenu',
|
|
@@ -307,6 +295,53 @@
|
|
|
|
|
|
emit('register', tableAction, formActions);
|
|
|
|
|
|
+ console.log('===============分割线=============');
|
|
|
+
|
|
|
+ // 初始化 sortable 实现拖动
|
|
|
+ function initSortable() {
|
|
|
+ const el = document.querySelector('.mytable tbody') as any;
|
|
|
+ console.log(el);
|
|
|
+ Sortable.create(el, {
|
|
|
+ handle: '.ant-table-row',
|
|
|
+ sort: true, // boolean 定义是否列表单元是否可以在列表容器内进行拖拽排序
|
|
|
+ delay: 0, // number 定义鼠标选中列表单元可以开始拖动的延迟时间;
|
|
|
+ touchStartThreshold: 0, // px, how many pixels the point should move before cancelling a delayed drag event
|
|
|
+ disabled: false, // boolean 定义是否此sortable对象是否可用,为true时sortable对象不能拖放排序等功能,为false时为可以进行排序,相当于一个开关;
|
|
|
+ animation: 150, // ms, number 单位:ms,定义排序动画的时间
|
|
|
+ easing: 'cubic-bezier(1, 0, 0, 1)', // Easing for animation. Defaults to null. See https://easings.net/ for examples.
|
|
|
+ ghostClass: 'sortable-ghost', // drop placeholder的css类名
|
|
|
+ draggable: '.ant-table-row', // 允许拖拽的项目类名
|
|
|
+ chosenClass: 'sortable-chosen', // 被选中项的css 类名
|
|
|
+ dragClass: 'sortable-drag', // 正在被拖拽中的css类名
|
|
|
+ dataIdAttr: 'data-id',
|
|
|
+ group: { name: 'name', pull: true, put: true },
|
|
|
+
|
|
|
+ // 拖拽完成
|
|
|
+ onUpdate: function (evt) {
|
|
|
+ console.log('onUpdate', evt);
|
|
|
+ emit('dragRow', evt);
|
|
|
+ },
|
|
|
+ // 开始拖拽的时候
|
|
|
+ // onStart: function (evt) {
|
|
|
+ // console.log('onStart', evt);
|
|
|
+ // },
|
|
|
+ // onAdd: function (evt) {
|
|
|
+ // console.log('onAdd', evt);
|
|
|
+ // },
|
|
|
+ // onRemove: function (evt) {
|
|
|
+ // console.log('onRemove', evt);
|
|
|
+ // },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ onMounted(() => {
|
|
|
+ console.log('props.canDragRow', props.canDragRow);
|
|
|
+ if (!props.canDragRow) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ initSortable(); // 开启拖拽功能
|
|
|
+ // console.log(`fn`, fn)
|
|
|
+ });
|
|
|
+ console.log('===============分割线=============');
|
|
|
return {
|
|
|
tableElRef,
|
|
|
getBindValues,
|