stk-table-vue 0.8.14 → 0.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -172
- package/lib/src/StkTable/StkTable.vue.d.ts +19 -1
- package/lib/src/StkTable/useScrollbar.d.ts +57 -0
- package/lib/src/StkTable/utils/index.d.ts +7 -0
- package/lib/stk-table-vue.js +396 -205
- package/lib/style.css +42 -1
- package/package.json +74 -74
- package/src/StkTable/StkTable.vue +1730 -1665
- package/src/StkTable/components/DragHandle.vue +9 -9
- package/src/StkTable/components/SortIcon.vue +6 -6
- package/src/StkTable/components/TriangleIcon.vue +3 -3
- package/src/StkTable/const.ts +50 -50
- package/src/StkTable/index.ts +4 -4
- package/src/StkTable/style.less +627 -578
- package/src/StkTable/types/highlightDimOptions.ts +26 -26
- package/src/StkTable/types/index.ts +297 -297
- package/src/StkTable/useAutoResize.ts +91 -91
- package/src/StkTable/useColResize.ts +216 -216
- package/src/StkTable/useFixedCol.ts +150 -150
- package/src/StkTable/useFixedStyle.ts +75 -75
- package/src/StkTable/useGetFixedColPosition.ts +65 -65
- package/src/StkTable/useHighlight.ts +257 -257
- package/src/StkTable/useKeyboardArrowScroll.ts +112 -112
- package/src/StkTable/useMaxRowSpan.ts +55 -55
- package/src/StkTable/useMergeCells.ts +120 -120
- package/src/StkTable/useRowExpand.ts +88 -88
- package/src/StkTable/useScrollRowByRow.ts +113 -113
- package/src/StkTable/useScrollbar.ts +187 -0
- package/src/StkTable/useThDrag.ts +102 -102
- package/src/StkTable/useTrDrag.ts +113 -113
- package/src/StkTable/useTree.ts +161 -161
- package/src/StkTable/useVirtualScroll.ts +494 -494
- package/src/StkTable/utils/constRefUtils.ts +29 -29
- package/src/StkTable/utils/index.ts +287 -258
- package/src/StkTable/utils/useTriggerRef.ts +33 -33
- package/src/VirtualTree.vue +622 -622
- package/src/VirtualTreeSelect.vue +367 -367
- package/src/vite-env.d.ts +10 -10
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
2
|
-
import { ColKeyGen, StkTableColumn } from './types';
|
|
3
|
-
import { isEmptyValue } from './utils';
|
|
4
|
-
|
|
5
|
-
type Params = {
|
|
6
|
-
props: any;
|
|
7
|
-
emits: any;
|
|
8
|
-
colKeyGen: ColKeyGen;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* 列顺序拖动
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export function useThDrag({ props, emits, colKeyGen }: Params) {
|
|
15
|
-
const findParentTH = (e: DragEvent) => (e.target as HTMLElement).closest('th');
|
|
16
|
-
|
|
17
|
-
const dragConfig = computed(() => {
|
|
18
|
-
const headerDrag = props.headerDrag;
|
|
19
|
-
const draggable = headerDrag !== false; // true or object
|
|
20
|
-
return {
|
|
21
|
-
draggable,
|
|
22
|
-
mode: 'insert',
|
|
23
|
-
disabled: () => false,
|
|
24
|
-
...headerDrag,
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/** 开始拖动记录th位置 */
|
|
29
|
-
function onThDragStart(e: DragEvent) {
|
|
30
|
-
const th = findParentTH(e);
|
|
31
|
-
if (!th) return;
|
|
32
|
-
const dragStartKey = th.dataset.colKey || '';
|
|
33
|
-
const dt = e.dataTransfer;
|
|
34
|
-
if (dt) {
|
|
35
|
-
dt.effectAllowed = 'move';
|
|
36
|
-
dt.setData('text/plain', dragStartKey);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
emits('th-drag-start', dragStartKey);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function onThDragOver(e: DragEvent) {
|
|
43
|
-
const th = findParentTH(e);
|
|
44
|
-
if (!th) return;
|
|
45
|
-
|
|
46
|
-
const isHeaderDraggable = th.getAttribute('draggable') === 'true';
|
|
47
|
-
if (!isHeaderDraggable) return;
|
|
48
|
-
|
|
49
|
-
const dt = e.dataTransfer;
|
|
50
|
-
if (dt) {
|
|
51
|
-
dt.dropEffect = 'move';
|
|
52
|
-
}
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** th拖动释放时 */
|
|
57
|
-
function onThDrop(e: DragEvent) {
|
|
58
|
-
const th = findParentTH(e);
|
|
59
|
-
if (!th) return;
|
|
60
|
-
const dragStartKey = e.dataTransfer?.getData('text');
|
|
61
|
-
if (dragStartKey !== th.dataset.colKey) {
|
|
62
|
-
handleColOrderChange(dragStartKey, th.dataset.colKey);
|
|
63
|
-
}
|
|
64
|
-
emits('th-drop', th.dataset.colKey);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** 列拖动交换顺序 */
|
|
68
|
-
function handleColOrderChange(dragStartKey: string | undefined, dragEndKey: string | undefined) {
|
|
69
|
-
if (isEmptyValue(dragStartKey) || isEmptyValue(dragEndKey)) return;
|
|
70
|
-
|
|
71
|
-
if (dragConfig.value.mode !== 'none') {
|
|
72
|
-
const columns: StkTableColumn<any>[] = props.columns.slice();
|
|
73
|
-
|
|
74
|
-
const dragStartIndex = columns.findIndex(col => colKeyGen.value(col) === dragStartKey);
|
|
75
|
-
const dragEndIndex = columns.findIndex(col => colKeyGen.value(col) === dragEndKey);
|
|
76
|
-
|
|
77
|
-
if (dragStartIndex === -1 || dragEndIndex === -1) return;
|
|
78
|
-
|
|
79
|
-
const dragStartCol = columns[dragStartIndex];
|
|
80
|
-
// if mode is none, do nothing
|
|
81
|
-
if (dragConfig.value.mode === 'swap') {
|
|
82
|
-
columns[dragStartIndex] = columns[dragEndIndex];
|
|
83
|
-
columns[dragEndIndex] = dragStartCol;
|
|
84
|
-
} else {
|
|
85
|
-
// default is insert
|
|
86
|
-
columns.splice(dragStartIndex, 1);
|
|
87
|
-
columns.splice(dragEndIndex, 0, dragStartCol);
|
|
88
|
-
}
|
|
89
|
-
emits('update:columns', columns);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
emits('col-order-change', dragStartKey, dragEndKey);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
onThDragStart,
|
|
97
|
-
onThDragOver,
|
|
98
|
-
onThDrop,
|
|
99
|
-
/** 是否可拖拽 */
|
|
100
|
-
isHeaderDraggable: (col: StkTableColumn<any>) => dragConfig.value.draggable && !dragConfig.value.disabled(col),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import { ColKeyGen, StkTableColumn } from './types';
|
|
3
|
+
import { isEmptyValue } from './utils';
|
|
4
|
+
|
|
5
|
+
type Params = {
|
|
6
|
+
props: any;
|
|
7
|
+
emits: any;
|
|
8
|
+
colKeyGen: ColKeyGen;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 列顺序拖动
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function useThDrag({ props, emits, colKeyGen }: Params) {
|
|
15
|
+
const findParentTH = (e: DragEvent) => (e.target as HTMLElement).closest('th');
|
|
16
|
+
|
|
17
|
+
const dragConfig = computed(() => {
|
|
18
|
+
const headerDrag = props.headerDrag;
|
|
19
|
+
const draggable = headerDrag !== false; // true or object
|
|
20
|
+
return {
|
|
21
|
+
draggable,
|
|
22
|
+
mode: 'insert',
|
|
23
|
+
disabled: () => false,
|
|
24
|
+
...headerDrag,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** 开始拖动记录th位置 */
|
|
29
|
+
function onThDragStart(e: DragEvent) {
|
|
30
|
+
const th = findParentTH(e);
|
|
31
|
+
if (!th) return;
|
|
32
|
+
const dragStartKey = th.dataset.colKey || '';
|
|
33
|
+
const dt = e.dataTransfer;
|
|
34
|
+
if (dt) {
|
|
35
|
+
dt.effectAllowed = 'move';
|
|
36
|
+
dt.setData('text/plain', dragStartKey);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
emits('th-drag-start', dragStartKey);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function onThDragOver(e: DragEvent) {
|
|
43
|
+
const th = findParentTH(e);
|
|
44
|
+
if (!th) return;
|
|
45
|
+
|
|
46
|
+
const isHeaderDraggable = th.getAttribute('draggable') === 'true';
|
|
47
|
+
if (!isHeaderDraggable) return;
|
|
48
|
+
|
|
49
|
+
const dt = e.dataTransfer;
|
|
50
|
+
if (dt) {
|
|
51
|
+
dt.dropEffect = 'move';
|
|
52
|
+
}
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** th拖动释放时 */
|
|
57
|
+
function onThDrop(e: DragEvent) {
|
|
58
|
+
const th = findParentTH(e);
|
|
59
|
+
if (!th) return;
|
|
60
|
+
const dragStartKey = e.dataTransfer?.getData('text');
|
|
61
|
+
if (dragStartKey !== th.dataset.colKey) {
|
|
62
|
+
handleColOrderChange(dragStartKey, th.dataset.colKey);
|
|
63
|
+
}
|
|
64
|
+
emits('th-drop', th.dataset.colKey);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** 列拖动交换顺序 */
|
|
68
|
+
function handleColOrderChange(dragStartKey: string | undefined, dragEndKey: string | undefined) {
|
|
69
|
+
if (isEmptyValue(dragStartKey) || isEmptyValue(dragEndKey)) return;
|
|
70
|
+
|
|
71
|
+
if (dragConfig.value.mode !== 'none') {
|
|
72
|
+
const columns: StkTableColumn<any>[] = props.columns.slice();
|
|
73
|
+
|
|
74
|
+
const dragStartIndex = columns.findIndex(col => colKeyGen.value(col) === dragStartKey);
|
|
75
|
+
const dragEndIndex = columns.findIndex(col => colKeyGen.value(col) === dragEndKey);
|
|
76
|
+
|
|
77
|
+
if (dragStartIndex === -1 || dragEndIndex === -1) return;
|
|
78
|
+
|
|
79
|
+
const dragStartCol = columns[dragStartIndex];
|
|
80
|
+
// if mode is none, do nothing
|
|
81
|
+
if (dragConfig.value.mode === 'swap') {
|
|
82
|
+
columns[dragStartIndex] = columns[dragEndIndex];
|
|
83
|
+
columns[dragEndIndex] = dragStartCol;
|
|
84
|
+
} else {
|
|
85
|
+
// default is insert
|
|
86
|
+
columns.splice(dragStartIndex, 1);
|
|
87
|
+
columns.splice(dragEndIndex, 0, dragStartCol);
|
|
88
|
+
}
|
|
89
|
+
emits('update:columns', columns);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
emits('col-order-change', dragStartKey, dragEndKey);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
onThDragStart,
|
|
97
|
+
onThDragOver,
|
|
98
|
+
onThDrop,
|
|
99
|
+
/** 是否可拖拽 */
|
|
100
|
+
isHeaderDraggable: (col: StkTableColumn<any>) => dragConfig.value.draggable && !dragConfig.value.disabled(col),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import { computed, ShallowRef } from 'vue';
|
|
2
|
-
import { DragRowConfig } from './types';
|
|
3
|
-
import { getClosestTr } from './utils';
|
|
4
|
-
|
|
5
|
-
type Params = {
|
|
6
|
-
props: any;
|
|
7
|
-
emits: any;
|
|
8
|
-
dataSourceCopy: ShallowRef<any[]>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const TR_DRAGGING_CLASS = 'tr-dragging';
|
|
12
|
-
const TR_DRAG_OVER_CLASS = 'tr-dragging-over';
|
|
13
|
-
const DATA_TRANSFER_FORMAT = 'text/plain';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 拖拽行
|
|
17
|
-
* TODO: 不在虚拟滚动的情况下,从上面拖拽到下面,跨页的时候,滚动条会自适应位置。没有顶上去
|
|
18
|
-
*/
|
|
19
|
-
export function useTrDrag({ props, emits, dataSourceCopy }: Params) {
|
|
20
|
-
let trDragFlag = false;
|
|
21
|
-
|
|
22
|
-
const dragRowConfig = computed<DragRowConfig>(() => {
|
|
23
|
-
return { mode: 'insert', ...props.dragRowConfig };
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
function onTrDragStart(e: DragEvent, rowIndex: number) {
|
|
27
|
-
const tr = getClosestTr(e);
|
|
28
|
-
if (tr) {
|
|
29
|
-
const trRect = tr.getBoundingClientRect();
|
|
30
|
-
const x = e.clientX - (trRect.left ?? 0);
|
|
31
|
-
e.dataTransfer?.setDragImage(tr, x, trRect.height / 2);
|
|
32
|
-
tr.classList.add(TR_DRAGGING_CLASS);
|
|
33
|
-
}
|
|
34
|
-
const dt = e.dataTransfer;
|
|
35
|
-
if (dt) {
|
|
36
|
-
dt.effectAllowed = 'move';
|
|
37
|
-
dt.setData(DATA_TRANSFER_FORMAT, String(rowIndex));
|
|
38
|
-
}
|
|
39
|
-
trDragFlag = true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function onTrDragOver(e: DragEvent) {
|
|
43
|
-
if (!trDragFlag) return;
|
|
44
|
-
e.preventDefault(); // 阻止默认行为,否则不会触发 drop 事件
|
|
45
|
-
|
|
46
|
-
const dt = e.dataTransfer;
|
|
47
|
-
if (dt) {
|
|
48
|
-
dt.dropEffect = 'move';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let oldTr: HTMLElement | null = null;
|
|
53
|
-
function onTrDragEnter(e: DragEvent) {
|
|
54
|
-
if (!trDragFlag) return;
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
const tr = getClosestTr(e);
|
|
57
|
-
if (oldTr && oldTr !== tr) {
|
|
58
|
-
// 两个tr不一样说明移动到了另一个tr中
|
|
59
|
-
oldTr.classList.remove(TR_DRAG_OVER_CLASS);
|
|
60
|
-
}
|
|
61
|
-
if (tr) {
|
|
62
|
-
oldTr = tr;
|
|
63
|
-
tr.classList.add(TR_DRAG_OVER_CLASS);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function onTrDragEnd(e: DragEvent) {
|
|
68
|
-
if (!trDragFlag) return;
|
|
69
|
-
const tr = getClosestTr(e);
|
|
70
|
-
if (tr) {
|
|
71
|
-
tr.classList.remove(TR_DRAGGING_CLASS);
|
|
72
|
-
}
|
|
73
|
-
if (oldTr) {
|
|
74
|
-
oldTr.classList.remove(TR_DRAG_OVER_CLASS);
|
|
75
|
-
oldTr = null;
|
|
76
|
-
}
|
|
77
|
-
trDragFlag = false;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function onTrDrop(e: DragEvent, rowIndex: number) {
|
|
81
|
-
if (!trDragFlag) return;
|
|
82
|
-
const dt = e.dataTransfer;
|
|
83
|
-
if (!dt) return;
|
|
84
|
-
const mode = dragRowConfig.value.mode;
|
|
85
|
-
const sourceIndex = Number(dt.getData(DATA_TRANSFER_FORMAT));
|
|
86
|
-
// dt.clearData(DATA_TRANSFER_FORMAT); // firefox not work
|
|
87
|
-
const endIndex = rowIndex;
|
|
88
|
-
if (sourceIndex === endIndex) return;
|
|
89
|
-
|
|
90
|
-
if (mode !== 'none') {
|
|
91
|
-
const dataSourceTemp = dataSourceCopy.value.slice();
|
|
92
|
-
const sourceRow = dataSourceTemp[sourceIndex];
|
|
93
|
-
if (mode === 'swap') {
|
|
94
|
-
dataSourceTemp[sourceIndex] = dataSourceTemp[endIndex];
|
|
95
|
-
dataSourceTemp[endIndex] = sourceRow;
|
|
96
|
-
} else {
|
|
97
|
-
dataSourceTemp.splice(sourceIndex, 1);
|
|
98
|
-
dataSourceTemp.splice(endIndex, 0, sourceRow);
|
|
99
|
-
}
|
|
100
|
-
dataSourceCopy.value = dataSourceTemp;
|
|
101
|
-
}
|
|
102
|
-
emits('row-order-change', sourceIndex, endIndex);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
dragRowConfig,
|
|
107
|
-
onTrDragStart,
|
|
108
|
-
onTrDragEnter,
|
|
109
|
-
onTrDragOver,
|
|
110
|
-
onTrDrop,
|
|
111
|
-
onTrDragEnd,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
1
|
+
import { computed, ShallowRef } from 'vue';
|
|
2
|
+
import { DragRowConfig } from './types';
|
|
3
|
+
import { getClosestTr } from './utils';
|
|
4
|
+
|
|
5
|
+
type Params = {
|
|
6
|
+
props: any;
|
|
7
|
+
emits: any;
|
|
8
|
+
dataSourceCopy: ShallowRef<any[]>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const TR_DRAGGING_CLASS = 'tr-dragging';
|
|
12
|
+
const TR_DRAG_OVER_CLASS = 'tr-dragging-over';
|
|
13
|
+
const DATA_TRANSFER_FORMAT = 'text/plain';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 拖拽行
|
|
17
|
+
* TODO: 不在虚拟滚动的情况下,从上面拖拽到下面,跨页的时候,滚动条会自适应位置。没有顶上去
|
|
18
|
+
*/
|
|
19
|
+
export function useTrDrag({ props, emits, dataSourceCopy }: Params) {
|
|
20
|
+
let trDragFlag = false;
|
|
21
|
+
|
|
22
|
+
const dragRowConfig = computed<DragRowConfig>(() => {
|
|
23
|
+
return { mode: 'insert', ...props.dragRowConfig };
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function onTrDragStart(e: DragEvent, rowIndex: number) {
|
|
27
|
+
const tr = getClosestTr(e);
|
|
28
|
+
if (tr) {
|
|
29
|
+
const trRect = tr.getBoundingClientRect();
|
|
30
|
+
const x = e.clientX - (trRect.left ?? 0);
|
|
31
|
+
e.dataTransfer?.setDragImage(tr, x, trRect.height / 2);
|
|
32
|
+
tr.classList.add(TR_DRAGGING_CLASS);
|
|
33
|
+
}
|
|
34
|
+
const dt = e.dataTransfer;
|
|
35
|
+
if (dt) {
|
|
36
|
+
dt.effectAllowed = 'move';
|
|
37
|
+
dt.setData(DATA_TRANSFER_FORMAT, String(rowIndex));
|
|
38
|
+
}
|
|
39
|
+
trDragFlag = true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function onTrDragOver(e: DragEvent) {
|
|
43
|
+
if (!trDragFlag) return;
|
|
44
|
+
e.preventDefault(); // 阻止默认行为,否则不会触发 drop 事件
|
|
45
|
+
|
|
46
|
+
const dt = e.dataTransfer;
|
|
47
|
+
if (dt) {
|
|
48
|
+
dt.dropEffect = 'move';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let oldTr: HTMLElement | null = null;
|
|
53
|
+
function onTrDragEnter(e: DragEvent) {
|
|
54
|
+
if (!trDragFlag) return;
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
const tr = getClosestTr(e);
|
|
57
|
+
if (oldTr && oldTr !== tr) {
|
|
58
|
+
// 两个tr不一样说明移动到了另一个tr中
|
|
59
|
+
oldTr.classList.remove(TR_DRAG_OVER_CLASS);
|
|
60
|
+
}
|
|
61
|
+
if (tr) {
|
|
62
|
+
oldTr = tr;
|
|
63
|
+
tr.classList.add(TR_DRAG_OVER_CLASS);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function onTrDragEnd(e: DragEvent) {
|
|
68
|
+
if (!trDragFlag) return;
|
|
69
|
+
const tr = getClosestTr(e);
|
|
70
|
+
if (tr) {
|
|
71
|
+
tr.classList.remove(TR_DRAGGING_CLASS);
|
|
72
|
+
}
|
|
73
|
+
if (oldTr) {
|
|
74
|
+
oldTr.classList.remove(TR_DRAG_OVER_CLASS);
|
|
75
|
+
oldTr = null;
|
|
76
|
+
}
|
|
77
|
+
trDragFlag = false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function onTrDrop(e: DragEvent, rowIndex: number) {
|
|
81
|
+
if (!trDragFlag) return;
|
|
82
|
+
const dt = e.dataTransfer;
|
|
83
|
+
if (!dt) return;
|
|
84
|
+
const mode = dragRowConfig.value.mode;
|
|
85
|
+
const sourceIndex = Number(dt.getData(DATA_TRANSFER_FORMAT));
|
|
86
|
+
// dt.clearData(DATA_TRANSFER_FORMAT); // firefox not work
|
|
87
|
+
const endIndex = rowIndex;
|
|
88
|
+
if (sourceIndex === endIndex) return;
|
|
89
|
+
|
|
90
|
+
if (mode !== 'none') {
|
|
91
|
+
const dataSourceTemp = dataSourceCopy.value.slice();
|
|
92
|
+
const sourceRow = dataSourceTemp[sourceIndex];
|
|
93
|
+
if (mode === 'swap') {
|
|
94
|
+
dataSourceTemp[sourceIndex] = dataSourceTemp[endIndex];
|
|
95
|
+
dataSourceTemp[endIndex] = sourceRow;
|
|
96
|
+
} else {
|
|
97
|
+
dataSourceTemp.splice(sourceIndex, 1);
|
|
98
|
+
dataSourceTemp.splice(endIndex, 0, sourceRow);
|
|
99
|
+
}
|
|
100
|
+
dataSourceCopy.value = dataSourceTemp;
|
|
101
|
+
}
|
|
102
|
+
emits('row-order-change', sourceIndex, endIndex);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
dragRowConfig,
|
|
107
|
+
onTrDragStart,
|
|
108
|
+
onTrDragEnter,
|
|
109
|
+
onTrDragOver,
|
|
110
|
+
onTrDrop,
|
|
111
|
+
onTrDragEnd,
|
|
112
|
+
};
|
|
113
|
+
}
|