yy-vue-easytable 2.27.2
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/LICENSE +22 -0
- package/README.md +187 -0
- package/libs/font/demo.css +539 -0
- package/libs/font/demo_index.html +400 -0
- package/libs/font/iconfont.css +57 -0
- package/libs/font/iconfont.eot +0 -0
- package/libs/font/iconfont.js +1 -0
- package/libs/font/iconfont.json +79 -0
- package/libs/font/iconfont.svg +56 -0
- package/libs/font/iconfont.ttf +0 -0
- package/libs/font/iconfont.woff +0 -0
- package/libs/font/iconfont.woff2 +0 -0
- package/libs/locale/lang/af-ZA.js +48 -0
- package/libs/locale/lang/en-US.js +48 -0
- package/libs/locale/lang/fr-FR.js +48 -0
- package/libs/locale/lang/ko-KR.js +48 -0
- package/libs/locale/lang/pt-BR.js +48 -0
- package/libs/locale/lang/ru-RU.js +48 -0
- package/libs/locale/lang/zh-CN.js +48 -0
- package/libs/locale/lang/zh-TW.js +48 -0
- package/libs/locale/lang/zu-ZA.js +48 -0
- package/libs/main.js +1 -0
- package/libs/theme-dark/base.css +1 -0
- package/libs/theme-dark/index.css +1253 -0
- package/libs/theme-dark/var.css +7 -0
- package/libs/theme-dark/ve-checkbox.css +150 -0
- package/libs/theme-dark/ve-contextmenu.css +71 -0
- package/libs/theme-dark/ve-dropdown.css +177 -0
- package/libs/theme-dark/ve-icon.css +10 -0
- package/libs/theme-dark/ve-loading.css +218 -0
- package/libs/theme-dark/ve-pagination.css +136 -0
- package/libs/theme-dark/ve-radio.css +111 -0
- package/libs/theme-dark/ve-select.css +50 -0
- package/libs/theme-dark/ve-table.css +385 -0
- package/libs/theme-default/base.css +1 -0
- package/libs/theme-default/index.css +1253 -0
- package/libs/theme-default/var.css +7 -0
- package/libs/theme-default/ve-checkbox.css +150 -0
- package/libs/theme-default/ve-contextmenu.css +71 -0
- package/libs/theme-default/ve-dropdown.css +177 -0
- package/libs/theme-default/ve-icon.css +10 -0
- package/libs/theme-default/ve-loading.css +218 -0
- package/libs/theme-default/ve-pagination.css +136 -0
- package/libs/theme-default/ve-radio.css +111 -0
- package/libs/theme-default/ve-select.css +50 -0
- package/libs/theme-default/ve-table.css +385 -0
- package/libs/umd/index.js +9 -0
- package/libs/ve-checkbox-group.js +1 -0
- package/libs/ve-checkbox.js +1 -0
- package/libs/ve-contextmenu.js +1 -0
- package/libs/ve-dropdown.js +1 -0
- package/libs/ve-icon.js +1 -0
- package/libs/ve-loading.js +1 -0
- package/libs/ve-locale.js +1 -0
- package/libs/ve-pagination.js +1 -0
- package/libs/ve-radio.js +1 -0
- package/libs/ve-select.js +1 -0
- package/libs/ve-table.js +1 -0
- package/package.json +142 -0
- package/packages/font/demo.css +539 -0
- package/packages/font/demo_index.html +400 -0
- package/packages/font/iconfont.css +57 -0
- package/packages/font/iconfont.eot +0 -0
- package/packages/font/iconfont.js +1 -0
- package/packages/font/iconfont.json +79 -0
- package/packages/font/iconfont.svg +56 -0
- package/packages/font/iconfont.ttf +0 -0
- package/packages/font/iconfont.woff +0 -0
- package/packages/font/iconfont.woff2 +0 -0
- package/packages/index.js +75 -0
- package/packages/src/comps/resize-observer/index.js +2 -0
- package/packages/src/comps/resize-observer/src/index.jsx +38 -0
- package/packages/src/directives/clickoutside.js +31 -0
- package/packages/src/directives/events-outside.js +79 -0
- package/packages/src/directives/focus.js +28 -0
- package/packages/src/locale/index.js +27 -0
- package/packages/src/locale/lang/af-ZA.js +29 -0
- package/packages/src/locale/lang/en-US.js +30 -0
- package/packages/src/locale/lang/fr-FR.js +29 -0
- package/packages/src/locale/lang/ko-KR.js +29 -0
- package/packages/src/locale/lang/pt-BR.js +29 -0
- package/packages/src/locale/lang/ru-RU.js +29 -0
- package/packages/src/locale/lang/zh-CN.js +30 -0
- package/packages/src/locale/lang/zh-TW.js +29 -0
- package/packages/src/locale/lang/zu-ZA.js +29 -0
- package/packages/src/mixins/emitter.js +39 -0
- package/packages/src/utils/animation-frame.js +39 -0
- package/packages/src/utils/auto-resize.js +179 -0
- package/packages/src/utils/constant.js +42 -0
- package/packages/src/utils/dom.js +239 -0
- package/packages/src/utils/event-key-codes.js +53 -0
- package/packages/src/utils/hooks-manager.js +76 -0
- package/packages/src/utils/index.js +161 -0
- package/packages/src/utils/mouse-event.js +24 -0
- package/packages/src/utils/random.js +6 -0
- package/packages/src/utils/request-animation-timeout.js +36 -0
- package/packages/src/utils/resize-event.js +40 -0
- package/packages/src/utils/scroll-bar.js +27 -0
- package/packages/style/ve-checkbox.less +179 -0
- package/packages/style/ve-contextmenu.less +76 -0
- package/packages/style/ve-dropdown.less +204 -0
- package/packages/style/ve-icon.less +3 -0
- package/packages/style/ve-loading.less +242 -0
- package/packages/style/ve-pagination.less +153 -0
- package/packages/style/ve-radio.less +126 -0
- package/packages/style/ve-select.less +48 -0
- package/packages/style/ve-table.less +539 -0
- package/packages/theme-dark/base.less +1 -0
- package/packages/theme-dark/index.less +12 -0
- package/packages/theme-dark/var.less +111 -0
- package/packages/theme-dark/ve-checkbox.less +2 -0
- package/packages/theme-dark/ve-contextmenu.less +2 -0
- package/packages/theme-dark/ve-dropdown.less +2 -0
- package/packages/theme-dark/ve-icon.less +2 -0
- package/packages/theme-dark/ve-loading.less +2 -0
- package/packages/theme-dark/ve-pagination.less +2 -0
- package/packages/theme-dark/ve-radio.less +2 -0
- package/packages/theme-dark/ve-select.less +2 -0
- package/packages/theme-dark/ve-table.less +2 -0
- package/packages/theme-default/base.less +1 -0
- package/packages/theme-default/index.less +12 -0
- package/packages/theme-default/var.less +111 -0
- package/packages/theme-default/ve-checkbox.less +2 -0
- package/packages/theme-default/ve-contextmenu.less +2 -0
- package/packages/theme-default/ve-dropdown.less +2 -0
- package/packages/theme-default/ve-icon.less +2 -0
- package/packages/theme-default/ve-loading.less +2 -0
- package/packages/theme-default/ve-pagination.less +2 -0
- package/packages/theme-default/ve-radio.less +2 -0
- package/packages/theme-default/ve-select.less +2 -0
- package/packages/theme-default/ve-table.less +2 -0
- package/packages/ve-checkbox/index.js +7 -0
- package/packages/ve-checkbox/src/index.jsx +175 -0
- package/packages/ve-checkbox/src/util/constant.js +14 -0
- package/packages/ve-checkbox/src/util/index.js +10 -0
- package/packages/ve-checkbox-group/index.js +7 -0
- package/packages/ve-checkbox-group/src/index.jsx +53 -0
- package/packages/ve-checkbox-group/src/util/constant.js +14 -0
- package/packages/ve-checkbox-group/src/util/index.js +10 -0
- package/packages/ve-contextmenu/index.js +7 -0
- package/packages/ve-contextmenu/src/index.jsx +731 -0
- package/packages/ve-contextmenu/src/util/constant.js +29 -0
- package/packages/ve-contextmenu/src/util/index.js +10 -0
- package/packages/ve-dropdown/index.js +7 -0
- package/packages/ve-dropdown/src/index.jsx +720 -0
- package/packages/ve-dropdown/src/util/constant.js +15 -0
- package/packages/ve-dropdown/src/util/index.js +10 -0
- package/packages/ve-icon/index.js +7 -0
- package/packages/ve-icon/src/index.jsx +52 -0
- package/packages/ve-icon/src/util/constant.js +10 -0
- package/packages/ve-icon/src/util/index.js +10 -0
- package/packages/ve-loading/index.js +8 -0
- package/packages/ve-loading/src/bounce.jsx +50 -0
- package/packages/ve-loading/src/flow.jsx +51 -0
- package/packages/ve-loading/src/grid.jsx +57 -0
- package/packages/ve-loading/src/index.js +106 -0
- package/packages/ve-loading/src/loading.jsx +63 -0
- package/packages/ve-loading/src/plane.jsx +38 -0
- package/packages/ve-loading/src/pulse.jsx +38 -0
- package/packages/ve-loading/src/util/constant.js +31 -0
- package/packages/ve-loading/src/util/index.js +10 -0
- package/packages/ve-loading/src/wave.jsx +53 -0
- package/packages/ve-locale/index.js +28 -0
- package/packages/ve-pagination/index.js +7 -0
- package/packages/ve-pagination/src/index.jsx +304 -0
- package/packages/ve-pagination/src/pager.jsx +166 -0
- package/packages/ve-pagination/src/util/constant.js +16 -0
- package/packages/ve-pagination/src/util/index.js +10 -0
- package/packages/ve-radio/index.js +7 -0
- package/packages/ve-radio/src/index.jsx +121 -0
- package/packages/ve-radio/src/util/constant.js +13 -0
- package/packages/ve-radio/src/util/index.js +10 -0
- package/packages/ve-select/index.js +7 -0
- package/packages/ve-select/src/index.jsx +193 -0
- package/packages/ve-select/src/util/constant.js +13 -0
- package/packages/ve-select/src/util/index.js +10 -0
- package/packages/ve-table/index.js +7 -0
- package/packages/ve-table/src/body/body-checkbox-content.jsx +126 -0
- package/packages/ve-table/src/body/body-radio-content.jsx +113 -0
- package/packages/ve-table/src/body/body-td.jsx +671 -0
- package/packages/ve-table/src/body/body-tr-scrolling.jsx +38 -0
- package/packages/ve-table/src/body/body-tr.jsx +383 -0
- package/packages/ve-table/src/body/expand-tr-icon.jsx +80 -0
- package/packages/ve-table/src/body/expand-tr.jsx +147 -0
- package/packages/ve-table/src/body/index.jsx +943 -0
- package/packages/ve-table/src/colgroup/index.jsx +48 -0
- package/packages/ve-table/src/column-resizer/index.jsx +318 -0
- package/packages/ve-table/src/editor/constant.js +5 -0
- package/packages/ve-table/src/editor/index.jsx +533 -0
- package/packages/ve-table/src/footer/footer-td.jsx +396 -0
- package/packages/ve-table/src/footer/footer-tr.jsx +249 -0
- package/packages/ve-table/src/footer/index.jsx +108 -0
- package/packages/ve-table/src/header/header-checkbox-content.jsx +69 -0
- package/packages/ve-table/src/header/header-filter-content.jsx +100 -0
- package/packages/ve-table/src/header/header-filter-custom-content.jsx +110 -0
- package/packages/ve-table/src/header/header-th.jsx +664 -0
- package/packages/ve-table/src/header/header-tr.jsx +255 -0
- package/packages/ve-table/src/header/index.jsx +195 -0
- package/packages/ve-table/src/index.jsx +4196 -0
- package/packages/ve-table/src/selection/constant.js +5 -0
- package/packages/ve-table/src/selection/index.jsx +1643 -0
- package/packages/ve-table/src/util/clipboard.js +428 -0
- package/packages/ve-table/src/util/constant.js +269 -0
- package/packages/ve-table/src/util/index.js +1585 -0
- package/packages/ve-table/src/util/store.js +14 -0
|
@@ -0,0 +1,1643 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clsName,
|
|
3
|
+
isLastColumnByColKey,
|
|
4
|
+
isLastRowByRowKey,
|
|
5
|
+
getColKeysByRangeColKeys,
|
|
6
|
+
isExistGivenFixedColKey,
|
|
7
|
+
isExistNotFixedColKey,
|
|
8
|
+
getLeftmostColKey,
|
|
9
|
+
getRightmostColKey,
|
|
10
|
+
getColKeysByFixedTypeWithinColKeys,
|
|
11
|
+
getTotalWidthByColKeys,
|
|
12
|
+
getPreviewColKey,
|
|
13
|
+
getNextColKey,
|
|
14
|
+
} from "../util";
|
|
15
|
+
import {
|
|
16
|
+
COMPS_NAME,
|
|
17
|
+
EMIT_EVENTS,
|
|
18
|
+
HOOKS_NAME,
|
|
19
|
+
AUTOFILLING_DIRECTION,
|
|
20
|
+
CURRENT_CELL_SELECTION_TYPES,
|
|
21
|
+
COLUMN_FIXED_TYPE,
|
|
22
|
+
} from "../util/constant";
|
|
23
|
+
import { INSTANCE_METHODS } from "./constant";
|
|
24
|
+
import emitter from "../../../src/mixins/emitter";
|
|
25
|
+
import { isEmptyValue, isBoolean } from "../../../src/utils/index.js";
|
|
26
|
+
import { debounce } from "lodash";
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: COMPS_NAME.VE_TABLE_SELECTION,
|
|
30
|
+
mixins: [emitter],
|
|
31
|
+
props: {
|
|
32
|
+
tableEl: {
|
|
33
|
+
type: HTMLTableElement,
|
|
34
|
+
default: null,
|
|
35
|
+
},
|
|
36
|
+
allRowKeys: {
|
|
37
|
+
type: Array,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
colgroups: {
|
|
41
|
+
type: Array,
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
parentRendered: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
hooks: {
|
|
49
|
+
type: Object,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
// cell autofill option
|
|
53
|
+
cellAutofillOption: {
|
|
54
|
+
type: [Object, Boolean],
|
|
55
|
+
default: function () {
|
|
56
|
+
return null;
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
cellSelectionData: {
|
|
60
|
+
type: Object,
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
cellSelectionRangeData: {
|
|
64
|
+
type: Object,
|
|
65
|
+
required: true,
|
|
66
|
+
},
|
|
67
|
+
isAutofillStarting: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
currentCellSelectionType: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: "",
|
|
74
|
+
},
|
|
75
|
+
// is scrolling
|
|
76
|
+
showVirtualScrollingPlaceholder: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: false,
|
|
79
|
+
},
|
|
80
|
+
isVirtualScroll: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false,
|
|
83
|
+
},
|
|
84
|
+
virtualScrollVisibleIndexs: {
|
|
85
|
+
type: Object,
|
|
86
|
+
required: true,
|
|
87
|
+
},
|
|
88
|
+
isCellEditing: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: false,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
data() {
|
|
95
|
+
return {
|
|
96
|
+
// current cell
|
|
97
|
+
currentCellEl: null,
|
|
98
|
+
normalEndCellEl: null,
|
|
99
|
+
autoFillEndCellEl: null,
|
|
100
|
+
// cell selection rect
|
|
101
|
+
cellSelectionRect: {
|
|
102
|
+
// current cell element rect
|
|
103
|
+
currentCellRect: {
|
|
104
|
+
left: 0,
|
|
105
|
+
top: 0,
|
|
106
|
+
width: 0,
|
|
107
|
+
height: 0,
|
|
108
|
+
},
|
|
109
|
+
// normal end cell element rect
|
|
110
|
+
normalEndCellRect: {
|
|
111
|
+
left: 0,
|
|
112
|
+
top: 0,
|
|
113
|
+
width: 0,
|
|
114
|
+
height: 0,
|
|
115
|
+
},
|
|
116
|
+
// auto fill end cell element rect
|
|
117
|
+
autoFillEndCellRect: {
|
|
118
|
+
left: 0,
|
|
119
|
+
top: 0,
|
|
120
|
+
width: 0,
|
|
121
|
+
height: 0,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
computed: {
|
|
128
|
+
// selection borders visibility
|
|
129
|
+
selectionBordersVisibility() {
|
|
130
|
+
let result = true;
|
|
131
|
+
if (this.isVirtualScroll) {
|
|
132
|
+
const {
|
|
133
|
+
showVirtualScrollingPlaceholder,
|
|
134
|
+
cellSelectionData,
|
|
135
|
+
virtualScrollVisibleIndexs,
|
|
136
|
+
currentCellSelectionType,
|
|
137
|
+
} = this;
|
|
138
|
+
|
|
139
|
+
if (showVirtualScrollingPlaceholder) {
|
|
140
|
+
result = false;
|
|
141
|
+
} else {
|
|
142
|
+
const { currentCell, normalEndCell } = cellSelectionData;
|
|
143
|
+
|
|
144
|
+
if (
|
|
145
|
+
currentCellSelectionType ===
|
|
146
|
+
CURRENT_CELL_SELECTION_TYPES.SINGLE
|
|
147
|
+
) {
|
|
148
|
+
if (
|
|
149
|
+
currentCell.rowIndex <
|
|
150
|
+
virtualScrollVisibleIndexs.start ||
|
|
151
|
+
currentCell.rowIndex >
|
|
152
|
+
virtualScrollVisibleIndexs.end
|
|
153
|
+
) {
|
|
154
|
+
result = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (
|
|
159
|
+
currentCellSelectionType ===
|
|
160
|
+
CURRENT_CELL_SELECTION_TYPES.RANGE
|
|
161
|
+
) {
|
|
162
|
+
if (
|
|
163
|
+
(currentCell.rowIndex <
|
|
164
|
+
virtualScrollVisibleIndexs.start &&
|
|
165
|
+
normalEndCell.rowIndex <
|
|
166
|
+
virtualScrollVisibleIndexs.start) ||
|
|
167
|
+
(currentCell.rowIndex >
|
|
168
|
+
virtualScrollVisibleIndexs.end &&
|
|
169
|
+
normalEndCell.rowIndex >
|
|
170
|
+
virtualScrollVisibleIndexs.end)
|
|
171
|
+
) {
|
|
172
|
+
result = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
},
|
|
179
|
+
// show corner
|
|
180
|
+
showCorner() {
|
|
181
|
+
let result = true;
|
|
182
|
+
const { cellAutofillOption } = this;
|
|
183
|
+
if (cellAutofillOption) {
|
|
184
|
+
const { directionX, directionY } = this.cellAutofillOption;
|
|
185
|
+
if (
|
|
186
|
+
isBoolean(directionY) &&
|
|
187
|
+
!directionY &&
|
|
188
|
+
isBoolean(directionX) &&
|
|
189
|
+
!directionX
|
|
190
|
+
) {
|
|
191
|
+
result = false;
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
result = false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return result;
|
|
198
|
+
},
|
|
199
|
+
// corner cell info
|
|
200
|
+
cornerCellInfo() {
|
|
201
|
+
const { allRowKeys, colgroups, cellSelectionRangeData } = this;
|
|
202
|
+
|
|
203
|
+
const { rightColKey, bottomRowKey } = cellSelectionRangeData;
|
|
204
|
+
|
|
205
|
+
let isLastColumn = false;
|
|
206
|
+
if (isLastColumnByColKey(rightColKey, colgroups)) {
|
|
207
|
+
isLastColumn = true;
|
|
208
|
+
} else {
|
|
209
|
+
const index = colgroups.findIndex((x) => x.key === rightColKey);
|
|
210
|
+
// right col is right fixed and current col is not right fixed
|
|
211
|
+
if (
|
|
212
|
+
colgroups[index + 1].fixed === COLUMN_FIXED_TYPE.RIGHT &&
|
|
213
|
+
colgroups[index].fixed !== COLUMN_FIXED_TYPE.RIGHT
|
|
214
|
+
) {
|
|
215
|
+
isLastColumn = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let isLastRow = false;
|
|
220
|
+
if (isLastRowByRowKey(bottomRowKey, allRowKeys)) {
|
|
221
|
+
isLastRow = true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
isLastColumn,
|
|
226
|
+
isLastRow,
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
// is first selection row
|
|
230
|
+
isFirstSelectionRow() {
|
|
231
|
+
const { allRowKeys, cellSelectionRangeData } = this;
|
|
232
|
+
return allRowKeys[0] === cellSelectionRangeData.topRowKey;
|
|
233
|
+
},
|
|
234
|
+
// is first selection column
|
|
235
|
+
isFirstSelectionCol() {
|
|
236
|
+
const { colgroups, cellSelectionRangeData } = this;
|
|
237
|
+
return colgroups[0].key === cellSelectionRangeData.leftColKey;
|
|
238
|
+
},
|
|
239
|
+
// is first not fixed selection column
|
|
240
|
+
isFirstNotFixedSelectionCol() {
|
|
241
|
+
let result = false;
|
|
242
|
+
|
|
243
|
+
const { colgroups, cellSelectionRangeData } = this;
|
|
244
|
+
|
|
245
|
+
if (colgroups.find((x) => x.fixed === "left")) {
|
|
246
|
+
const col = colgroups.find((x) => !x.fixed);
|
|
247
|
+
if (col && col.field === cellSelectionRangeData.leftColKey) {
|
|
248
|
+
result = true;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return result;
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
watch: {
|
|
257
|
+
parentRendered: {
|
|
258
|
+
handler: function (val) {
|
|
259
|
+
if (val) {
|
|
260
|
+
// add table container scroll hook
|
|
261
|
+
this.hooks.addHook(
|
|
262
|
+
HOOKS_NAME.TABLE_CONTAINER_SCROLL,
|
|
263
|
+
() => {
|
|
264
|
+
this.setCellEls();
|
|
265
|
+
this.debounceSetCellEls();
|
|
266
|
+
|
|
267
|
+
this.resetCellPositions();
|
|
268
|
+
// debounce reset cell positions
|
|
269
|
+
this.debounceResetCellPositions();
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
// add table size change hook
|
|
273
|
+
this.hooks.addHook(HOOKS_NAME.TABLE_SIZE_CHANGE, () => {
|
|
274
|
+
// debounce reset cell positions
|
|
275
|
+
this.debounceResetCellPositions();
|
|
276
|
+
});
|
|
277
|
+
// add table td width change hook
|
|
278
|
+
this.hooks.addHook(
|
|
279
|
+
HOOKS_NAME.TABLE_CELL_WIDTH_CHANGE,
|
|
280
|
+
() => {
|
|
281
|
+
this.$nextTick(() => {
|
|
282
|
+
this.resetCellPositions();
|
|
283
|
+
});
|
|
284
|
+
},
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
// add clipboard cell value change hook
|
|
288
|
+
this.hooks.addHook(
|
|
289
|
+
HOOKS_NAME.CLIPBOARD_CELL_VALUE_CHANGE,
|
|
290
|
+
() => {
|
|
291
|
+
this.$nextTick(() => {
|
|
292
|
+
this.resetCellPositions();
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
immediate: true,
|
|
299
|
+
},
|
|
300
|
+
// watch current cell
|
|
301
|
+
"cellSelectionData.currentCell": {
|
|
302
|
+
handler: function (val) {
|
|
303
|
+
const { rowKey, colKey } = val;
|
|
304
|
+
if (!isEmptyValue(rowKey) && !isEmptyValue(colKey)) {
|
|
305
|
+
this.setCurrentCellEl();
|
|
306
|
+
this.setSelectionPositions({ type: "currentCell" });
|
|
307
|
+
} else {
|
|
308
|
+
this[INSTANCE_METHODS.CLEAR_CURRENT_CELL_RECT]();
|
|
309
|
+
}
|
|
310
|
+
this.setCellSelectionRangeData();
|
|
311
|
+
},
|
|
312
|
+
deep: true,
|
|
313
|
+
immediate: true,
|
|
314
|
+
},
|
|
315
|
+
// watch normal end cell
|
|
316
|
+
"cellSelectionData.normalEndCell": {
|
|
317
|
+
handler: function (val) {
|
|
318
|
+
const { rowKey, colKey } = val;
|
|
319
|
+
if (!isEmptyValue(rowKey) && !isEmptyValue(colKey)) {
|
|
320
|
+
// set normal end cell el
|
|
321
|
+
this.setNormalEndCellEl();
|
|
322
|
+
this.setSelectionPositions({ type: "normalEndCell" });
|
|
323
|
+
} else {
|
|
324
|
+
this[INSTANCE_METHODS.CLEAR_NORMAL_END_CELL_RECT]();
|
|
325
|
+
}
|
|
326
|
+
this.setCellSelectionRangeData();
|
|
327
|
+
},
|
|
328
|
+
deep: true,
|
|
329
|
+
immediate: true,
|
|
330
|
+
},
|
|
331
|
+
// watch autofill cell
|
|
332
|
+
"cellSelectionData.autoFillEndCell": {
|
|
333
|
+
handler: function (val) {
|
|
334
|
+
const { rowKey, colKey } = val;
|
|
335
|
+
if (!isEmptyValue(rowKey) && !isEmptyValue(colKey)) {
|
|
336
|
+
this.setAutofillEndCellEl();
|
|
337
|
+
this.setSelectionPositions({ type: "autoFillEndCell" });
|
|
338
|
+
} else {
|
|
339
|
+
this.clearAutofillEndCellRect();
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
deep: true,
|
|
343
|
+
immediate: true,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
methods: {
|
|
348
|
+
// reset cell position
|
|
349
|
+
resetCellPositions() {
|
|
350
|
+
const { currentCell, normalEndCell } = this.cellSelectionData;
|
|
351
|
+
if (
|
|
352
|
+
!isEmptyValue(currentCell.rowKey) &&
|
|
353
|
+
!isEmptyValue(currentCell.colKey)
|
|
354
|
+
) {
|
|
355
|
+
this.setSelectionPositions({
|
|
356
|
+
type: "currentCell",
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (
|
|
361
|
+
!isEmptyValue(normalEndCell.rowKey) &&
|
|
362
|
+
!isEmptyValue(normalEndCell.colKey)
|
|
363
|
+
) {
|
|
364
|
+
this.setSelectionPositions({
|
|
365
|
+
type: "normalEndCell",
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
// set cell els
|
|
371
|
+
setCellEls() {
|
|
372
|
+
if (this.isVirtualScroll && this.selectionBordersVisibility) {
|
|
373
|
+
this.setCurrentCellEl();
|
|
374
|
+
this.setNormalEndCellEl();
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
// set cell selection range data
|
|
379
|
+
setCellSelectionRangeData() {
|
|
380
|
+
const { currentCellSelectionType } = this;
|
|
381
|
+
const { currentCell, normalEndCell } = this.cellSelectionData;
|
|
382
|
+
|
|
383
|
+
let result = {};
|
|
384
|
+
|
|
385
|
+
if (
|
|
386
|
+
currentCellSelectionType === CURRENT_CELL_SELECTION_TYPES.SINGLE
|
|
387
|
+
) {
|
|
388
|
+
result = {
|
|
389
|
+
leftColKey: currentCell.colKey,
|
|
390
|
+
rightColKey: currentCell.colKey,
|
|
391
|
+
topRowKey: currentCell.rowKey,
|
|
392
|
+
bottomRowKey: currentCell.rowKey,
|
|
393
|
+
};
|
|
394
|
+
} else if (
|
|
395
|
+
currentCellSelectionType === CURRENT_CELL_SELECTION_TYPES.RANGE
|
|
396
|
+
) {
|
|
397
|
+
const leftmostColKey = getLeftmostColKey({
|
|
398
|
+
colgroups: this.colgroups,
|
|
399
|
+
colKeys: [currentCell.colKey, normalEndCell.colKey],
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
/*
|
|
403
|
+
current cell col key is leftmost colKey
|
|
404
|
+
需要用 colKey 的位置进行判断,不能根据当前单元格 left 值判断(固定列时)
|
|
405
|
+
*/
|
|
406
|
+
if (leftmostColKey === currentCell.colKey) {
|
|
407
|
+
result.leftColKey = currentCell.colKey;
|
|
408
|
+
result.rightColKey = normalEndCell.colKey;
|
|
409
|
+
} else {
|
|
410
|
+
result.leftColKey = normalEndCell.colKey;
|
|
411
|
+
result.rightColKey = currentCell.colKey;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (currentCell.rowIndex < normalEndCell.rowIndex) {
|
|
415
|
+
result.topRowKey = currentCell.rowKey;
|
|
416
|
+
result.bottomRowKey = normalEndCell.rowKey;
|
|
417
|
+
} else {
|
|
418
|
+
result.topRowKey = normalEndCell.rowKey;
|
|
419
|
+
result.bottomRowKey = currentCell.rowKey;
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
// clear
|
|
423
|
+
result = {
|
|
424
|
+
leftColKey: "",
|
|
425
|
+
rightColKey: "",
|
|
426
|
+
topRowKey: "",
|
|
427
|
+
bottomRowKey: "",
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
this.$emit(EMIT_EVENTS.CELL_SELECTION_RANGE_DATA_CHANGE, result);
|
|
432
|
+
},
|
|
433
|
+
|
|
434
|
+
// get cell position
|
|
435
|
+
getCellPosition({ cellEl, tableLeft, tableTop }) {
|
|
436
|
+
if (!this.selectionBordersVisibility) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const {
|
|
441
|
+
left: cellLeft,
|
|
442
|
+
top: cellTop,
|
|
443
|
+
height: cellHeight,
|
|
444
|
+
width: cellWidth,
|
|
445
|
+
} = cellEl.getBoundingClientRect();
|
|
446
|
+
|
|
447
|
+
if (cellHeight && cellWidth) {
|
|
448
|
+
return {
|
|
449
|
+
left: cellLeft - tableLeft,
|
|
450
|
+
top: cellTop - tableTop,
|
|
451
|
+
width: cellWidth,
|
|
452
|
+
height: cellHeight,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
|
|
457
|
+
// get cell position by column key
|
|
458
|
+
getCellPositionByColKey({
|
|
459
|
+
tableLeft,
|
|
460
|
+
tableTop,
|
|
461
|
+
colKey,
|
|
462
|
+
isFirstRow,
|
|
463
|
+
isLastRow,
|
|
464
|
+
}) {
|
|
465
|
+
if (!this.selectionBordersVisibility) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
let cellEl;
|
|
470
|
+
if (isFirstRow) {
|
|
471
|
+
cellEl = this.getTableFirstRowCellByColKey(colKey);
|
|
472
|
+
} else if (isLastRow) {
|
|
473
|
+
cellEl = this.getTableLastRowCellByColKey(colKey);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (!cellEl) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const {
|
|
481
|
+
left: cellLeft,
|
|
482
|
+
top: cellTop,
|
|
483
|
+
//height: cellHeight,
|
|
484
|
+
width: cellWidth,
|
|
485
|
+
} = cellEl.getBoundingClientRect();
|
|
486
|
+
|
|
487
|
+
if (cellWidth) {
|
|
488
|
+
return {
|
|
489
|
+
left: cellLeft - tableLeft,
|
|
490
|
+
top: cellTop - tableTop,
|
|
491
|
+
width: cellWidth,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
|
|
496
|
+
// set selection positions
|
|
497
|
+
setSelectionPositions({ type }) {
|
|
498
|
+
const {
|
|
499
|
+
allRowKeys,
|
|
500
|
+
tableEl,
|
|
501
|
+
currentCellEl,
|
|
502
|
+
normalEndCellEl,
|
|
503
|
+
autoFillEndCellEl,
|
|
504
|
+
cellSelectionData,
|
|
505
|
+
virtualScrollVisibleIndexs,
|
|
506
|
+
} = this;
|
|
507
|
+
|
|
508
|
+
// table empty
|
|
509
|
+
if (allRowKeys.length === 0) {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (!tableEl) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const { left: tableLeft, top: tableTop } =
|
|
518
|
+
tableEl.getBoundingClientRect();
|
|
519
|
+
|
|
520
|
+
let isCurrentCellOverflow = false;
|
|
521
|
+
let isNormalEndCellOverflow = false;
|
|
522
|
+
// set current cell position
|
|
523
|
+
if (type === "currentCell") {
|
|
524
|
+
isCurrentCellOverflow = true;
|
|
525
|
+
if (currentCellEl) {
|
|
526
|
+
const rect = this.getCellPosition({
|
|
527
|
+
cellEl: currentCellEl,
|
|
528
|
+
tableLeft,
|
|
529
|
+
tableTop,
|
|
530
|
+
});
|
|
531
|
+
if (rect) {
|
|
532
|
+
isCurrentCellOverflow = false;
|
|
533
|
+
this.cellSelectionRect.currentCellRect = rect;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// set nromal end cell position`
|
|
539
|
+
if (type === "normalEndCell") {
|
|
540
|
+
isNormalEndCellOverflow = true;
|
|
541
|
+
if (normalEndCellEl) {
|
|
542
|
+
const rect = this.getCellPosition({
|
|
543
|
+
cellEl: normalEndCellEl,
|
|
544
|
+
tableLeft,
|
|
545
|
+
tableTop,
|
|
546
|
+
});
|
|
547
|
+
if (rect) {
|
|
548
|
+
isNormalEndCellOverflow = false;
|
|
549
|
+
this.cellSelectionRect.normalEndCellRect = rect;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// current cell overflow or normal end cell overflow && is virtual scroll
|
|
555
|
+
if (
|
|
556
|
+
(isCurrentCellOverflow || isNormalEndCellOverflow) &&
|
|
557
|
+
this.isVirtualScroll
|
|
558
|
+
) {
|
|
559
|
+
const { currentCell, normalEndCell } = cellSelectionData;
|
|
560
|
+
// 弥补的
|
|
561
|
+
let mackUpColKey;
|
|
562
|
+
let mackUpRowIndex;
|
|
563
|
+
|
|
564
|
+
if (isCurrentCellOverflow) {
|
|
565
|
+
mackUpColKey = currentCell.colKey;
|
|
566
|
+
mackUpRowIndex = currentCell.rowIndex;
|
|
567
|
+
} else {
|
|
568
|
+
mackUpColKey = normalEndCell.colKey;
|
|
569
|
+
mackUpRowIndex = normalEndCell.rowIndex;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
let mackUpRect;
|
|
573
|
+
/*
|
|
574
|
+
当没有 currentCellRect 或 normalCellRect 时 进行纠正,否则只更新top值
|
|
575
|
+
*/
|
|
576
|
+
if (
|
|
577
|
+
(isCurrentCellOverflow &&
|
|
578
|
+
!this.cellSelectionRect.currentCellRect.height) ||
|
|
579
|
+
(isNormalEndCellOverflow &&
|
|
580
|
+
!this.cellSelectionRect.normalEndCellRect.height)
|
|
581
|
+
) {
|
|
582
|
+
let mackUpRectParams = {
|
|
583
|
+
tableLeft,
|
|
584
|
+
tableTop,
|
|
585
|
+
colKey: mackUpColKey,
|
|
586
|
+
};
|
|
587
|
+
// 上方超出
|
|
588
|
+
if (mackUpRowIndex < virtualScrollVisibleIndexs.start) {
|
|
589
|
+
mackUpRect = this.getCellPositionByColKey({
|
|
590
|
+
...mackUpRectParams,
|
|
591
|
+
isFirstRow: true,
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
// 下方超出
|
|
595
|
+
else if (mackUpRowIndex > virtualScrollVisibleIndexs.end) {
|
|
596
|
+
mackUpRect = this.getCellPositionByColKey({
|
|
597
|
+
...mackUpRectParams,
|
|
598
|
+
isLastRow: true,
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
// 仅更新 top 值
|
|
603
|
+
else {
|
|
604
|
+
// 上方超出
|
|
605
|
+
if (mackUpRowIndex < virtualScrollVisibleIndexs.start) {
|
|
606
|
+
mackUpRect = {
|
|
607
|
+
top: 0,
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
// 下方超出
|
|
611
|
+
else if (mackUpRowIndex > virtualScrollVisibleIndexs.end) {
|
|
612
|
+
mackUpRect = {
|
|
613
|
+
top: tableEl.clientHeight,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (isCurrentCellOverflow) {
|
|
619
|
+
Object.assign(
|
|
620
|
+
this.cellSelectionRect.currentCellRect,
|
|
621
|
+
mackUpRect,
|
|
622
|
+
);
|
|
623
|
+
} else {
|
|
624
|
+
Object.assign(
|
|
625
|
+
this.cellSelectionRect.normalEndCellRect,
|
|
626
|
+
mackUpRect,
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (autoFillEndCellEl && type === "autoFillEndCell") {
|
|
632
|
+
const rect = this.getCellPosition({
|
|
633
|
+
cellEl: autoFillEndCellEl,
|
|
634
|
+
tableLeft,
|
|
635
|
+
tableTop,
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
if (rect) {
|
|
639
|
+
this.cellSelectionRect.autoFillEndCellRect = rect;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
|
|
644
|
+
/*
|
|
645
|
+
get selection current
|
|
646
|
+
1、selection current
|
|
647
|
+
2、auto fill area
|
|
648
|
+
*/
|
|
649
|
+
getSelectionCurrent({ fixedType }) {
|
|
650
|
+
let result = {
|
|
651
|
+
selectionCurrent: null,
|
|
652
|
+
autoFillArea: null,
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
const { cellSelectionRect, colgroups, cellSelectionData } = this;
|
|
656
|
+
|
|
657
|
+
const { currentCellRect, normalEndCellRect } = cellSelectionRect;
|
|
658
|
+
|
|
659
|
+
if (!currentCellRect.width) {
|
|
660
|
+
return result;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const borders = {
|
|
664
|
+
borderWidth: currentCellRect.width + 1,
|
|
665
|
+
borderHeight: currentCellRect.height,
|
|
666
|
+
|
|
667
|
+
topBorder: {
|
|
668
|
+
show: true,
|
|
669
|
+
width: 0,
|
|
670
|
+
height: 2,
|
|
671
|
+
top: currentCellRect.top - 1,
|
|
672
|
+
left: currentCellRect.left - 1,
|
|
673
|
+
},
|
|
674
|
+
rightBorder: {
|
|
675
|
+
show: true,
|
|
676
|
+
width: 2,
|
|
677
|
+
height: 0,
|
|
678
|
+
top: currentCellRect.top,
|
|
679
|
+
left: currentCellRect.left + currentCellRect.width - 2,
|
|
680
|
+
},
|
|
681
|
+
bottomBorder: {
|
|
682
|
+
show: true,
|
|
683
|
+
width: 0,
|
|
684
|
+
height: 2,
|
|
685
|
+
top: currentCellRect.top + currentCellRect.height - 2,
|
|
686
|
+
left: currentCellRect.left - 1,
|
|
687
|
+
},
|
|
688
|
+
leftBorder: {
|
|
689
|
+
show: true,
|
|
690
|
+
width: 2,
|
|
691
|
+
height: 0,
|
|
692
|
+
top: currentCellRect.top,
|
|
693
|
+
left: currentCellRect.left - 1,
|
|
694
|
+
},
|
|
695
|
+
corner: {
|
|
696
|
+
show: !normalEndCellRect.width,
|
|
697
|
+
top: 0,
|
|
698
|
+
left: 0,
|
|
699
|
+
},
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
borders.corner.top = borders.bottomBorder.top - 3;
|
|
703
|
+
borders.corner.left = borders.rightBorder.left - 3;
|
|
704
|
+
|
|
705
|
+
// cell selection single autofill
|
|
706
|
+
if (!normalEndCellRect.width) {
|
|
707
|
+
result.autoFillArea = this.getSelectionAutofillArea({
|
|
708
|
+
areaPostions: borders,
|
|
709
|
+
fixedType,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const totalColKeys = [cellSelectionData.currentCell.colKey];
|
|
714
|
+
|
|
715
|
+
const fixedColKeys = getColKeysByFixedTypeWithinColKeys({
|
|
716
|
+
colKeys: totalColKeys,
|
|
717
|
+
fixedType,
|
|
718
|
+
colgroups,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
result.selectionCurrent = this.getBorders({
|
|
722
|
+
...borders,
|
|
723
|
+
showCorner: !normalEndCellRect.width,
|
|
724
|
+
className: "selection-current",
|
|
725
|
+
fixedType,
|
|
726
|
+
totalColKeys,
|
|
727
|
+
fixedColKeys,
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
return result;
|
|
731
|
+
},
|
|
732
|
+
|
|
733
|
+
/*
|
|
734
|
+
get selection areas
|
|
735
|
+
1、normal area
|
|
736
|
+
2、auto fill area
|
|
737
|
+
*/
|
|
738
|
+
getSelectionAreas({ fixedType }) {
|
|
739
|
+
let result = {
|
|
740
|
+
normalArea: null,
|
|
741
|
+
autoFillArea: null,
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
const { currentCell, normalEndCell } = this.cellSelectionData;
|
|
745
|
+
|
|
746
|
+
const { cellSelectionRect, cellSelectionRangeData, colgroups } =
|
|
747
|
+
this;
|
|
748
|
+
|
|
749
|
+
const { currentCellRect, normalEndCellRect } = cellSelectionRect;
|
|
750
|
+
|
|
751
|
+
if (!currentCellRect.width || !normalEndCellRect.width) {
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const borders = {
|
|
756
|
+
borderWidth: 0,
|
|
757
|
+
borderHeight: 0,
|
|
758
|
+
|
|
759
|
+
topBorder: {
|
|
760
|
+
show: true,
|
|
761
|
+
width: 0,
|
|
762
|
+
height: 1,
|
|
763
|
+
top: 0,
|
|
764
|
+
left: 0,
|
|
765
|
+
},
|
|
766
|
+
rightBorder: {
|
|
767
|
+
show: true,
|
|
768
|
+
width: 1,
|
|
769
|
+
height: 0,
|
|
770
|
+
top: 0,
|
|
771
|
+
left: 0,
|
|
772
|
+
},
|
|
773
|
+
bottomBorder: {
|
|
774
|
+
show: true,
|
|
775
|
+
width: 0,
|
|
776
|
+
height: 1,
|
|
777
|
+
top: 0,
|
|
778
|
+
left: 0,
|
|
779
|
+
},
|
|
780
|
+
leftBorder: {
|
|
781
|
+
show: true,
|
|
782
|
+
width: 1,
|
|
783
|
+
height: 0,
|
|
784
|
+
top: 0,
|
|
785
|
+
left: 0,
|
|
786
|
+
},
|
|
787
|
+
corner: {
|
|
788
|
+
show: true,
|
|
789
|
+
top: 0,
|
|
790
|
+
left: 0,
|
|
791
|
+
},
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
const leftmostColKey = getLeftmostColKey({
|
|
795
|
+
colgroups: this.colgroups,
|
|
796
|
+
colKeys: [currentCell.colKey, normalEndCell.colKey],
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
// end cell column key right
|
|
800
|
+
if (leftmostColKey === currentCell.colKey) {
|
|
801
|
+
borders.borderWidth =
|
|
802
|
+
normalEndCellRect.left -
|
|
803
|
+
currentCellRect.left +
|
|
804
|
+
normalEndCellRect.width +
|
|
805
|
+
1;
|
|
806
|
+
|
|
807
|
+
borders.topBorder.left = currentCellRect.left - 1;
|
|
808
|
+
borders.bottomBorder.left = currentCellRect.left - 1;
|
|
809
|
+
borders.leftBorder.left = currentCellRect.left - 1;
|
|
810
|
+
borders.rightBorder.left =
|
|
811
|
+
normalEndCellRect.left + normalEndCellRect.width - 1;
|
|
812
|
+
}
|
|
813
|
+
// end cell column key left or equal
|
|
814
|
+
else if (leftmostColKey === normalEndCell.colKey) {
|
|
815
|
+
borders.borderWidth =
|
|
816
|
+
currentCellRect.left -
|
|
817
|
+
normalEndCellRect.left +
|
|
818
|
+
currentCellRect.width +
|
|
819
|
+
1;
|
|
820
|
+
|
|
821
|
+
borders.topBorder.left = normalEndCellRect.left - 1;
|
|
822
|
+
borders.rightBorder.left =
|
|
823
|
+
currentCellRect.left + currentCellRect.width - 1;
|
|
824
|
+
borders.bottomBorder.left = normalEndCellRect.left - 1;
|
|
825
|
+
borders.leftBorder.left = normalEndCellRect.left - 1;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// end cell below
|
|
829
|
+
if (normalEndCellRect.top > currentCellRect.top) {
|
|
830
|
+
borders.borderHeight =
|
|
831
|
+
normalEndCellRect.top -
|
|
832
|
+
currentCellRect.top +
|
|
833
|
+
normalEndCellRect.height;
|
|
834
|
+
|
|
835
|
+
borders.topBorder.top = currentCellRect.top - 1;
|
|
836
|
+
borders.rightBorder.top = currentCellRect.top;
|
|
837
|
+
borders.bottomBorder.top =
|
|
838
|
+
normalEndCellRect.top + normalEndCellRect.height - 1;
|
|
839
|
+
borders.leftBorder.top = currentCellRect.top;
|
|
840
|
+
}
|
|
841
|
+
// end cell above or equal
|
|
842
|
+
else if (normalEndCellRect.top <= currentCellRect.top) {
|
|
843
|
+
borders.borderHeight =
|
|
844
|
+
currentCellRect.top -
|
|
845
|
+
normalEndCellRect.top +
|
|
846
|
+
currentCellRect.height;
|
|
847
|
+
|
|
848
|
+
borders.topBorder.top = normalEndCellRect.top - 1;
|
|
849
|
+
borders.rightBorder.top = normalEndCellRect.top;
|
|
850
|
+
borders.bottomBorder.top =
|
|
851
|
+
currentCellRect.top + currentCellRect.height - 1;
|
|
852
|
+
borders.leftBorder.top = normalEndCellRect.top;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
borders.corner.top = borders.bottomBorder.top - 4;
|
|
856
|
+
borders.corner.left = borders.rightBorder.left - 4;
|
|
857
|
+
|
|
858
|
+
if (normalEndCellRect.width) {
|
|
859
|
+
result.autoFillArea = this.getSelectionAutofillArea({
|
|
860
|
+
areaPostions: borders,
|
|
861
|
+
fixedType,
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const { leftColKey, rightColKey } = cellSelectionRangeData;
|
|
866
|
+
const totalColKeys = getColKeysByRangeColKeys({
|
|
867
|
+
colKey1: leftColKey,
|
|
868
|
+
colKey2: rightColKey,
|
|
869
|
+
colgroups,
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
const fixedColKeys = getColKeysByFixedTypeWithinColKeys({
|
|
873
|
+
colKeys: totalColKeys,
|
|
874
|
+
fixedType,
|
|
875
|
+
colgroups,
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
result.normalArea = this.getBorders({
|
|
879
|
+
...borders,
|
|
880
|
+
className: "selection-normal-area",
|
|
881
|
+
fixedType,
|
|
882
|
+
totalColKeys,
|
|
883
|
+
fixedColKeys,
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
result.normalAreaLayer = this.getAreaLayer({
|
|
887
|
+
...borders,
|
|
888
|
+
className: "selection-normal-area-layer",
|
|
889
|
+
fixedType,
|
|
890
|
+
totalColKeys,
|
|
891
|
+
fixedColKeys,
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
return result;
|
|
895
|
+
},
|
|
896
|
+
|
|
897
|
+
// get selection auto fill
|
|
898
|
+
getSelectionAutofillArea({ areaPostions, fixedType }) {
|
|
899
|
+
let result = null;
|
|
900
|
+
|
|
901
|
+
const {
|
|
902
|
+
cellAutofillOption,
|
|
903
|
+
cellSelectionRangeData,
|
|
904
|
+
cellSelectionRect,
|
|
905
|
+
cellSelectionData,
|
|
906
|
+
isAutofillStarting,
|
|
907
|
+
currentCellSelectionType,
|
|
908
|
+
colgroups,
|
|
909
|
+
} = this;
|
|
910
|
+
|
|
911
|
+
if (!isAutofillStarting) {
|
|
912
|
+
return result;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
const { currentCellRect, autoFillEndCellRect } = cellSelectionRect;
|
|
916
|
+
|
|
917
|
+
if (!currentCellRect.width || !autoFillEndCellRect.width) {
|
|
918
|
+
return result;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
if (!areaPostions) {
|
|
922
|
+
return result;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
const borders = {
|
|
926
|
+
borderWidth: 0,
|
|
927
|
+
borderHeight: 0,
|
|
928
|
+
|
|
929
|
+
topBorder: {
|
|
930
|
+
show: true,
|
|
931
|
+
width: 0,
|
|
932
|
+
height: 1,
|
|
933
|
+
top: 0,
|
|
934
|
+
left: 0,
|
|
935
|
+
},
|
|
936
|
+
rightBorder: {
|
|
937
|
+
show: true,
|
|
938
|
+
width: 1,
|
|
939
|
+
height: 0,
|
|
940
|
+
top: 0,
|
|
941
|
+
left: 0,
|
|
942
|
+
},
|
|
943
|
+
bottomBorder: {
|
|
944
|
+
show: true,
|
|
945
|
+
width: 0,
|
|
946
|
+
height: 1,
|
|
947
|
+
top: 0,
|
|
948
|
+
left: 0,
|
|
949
|
+
},
|
|
950
|
+
leftBorder: {
|
|
951
|
+
show: true,
|
|
952
|
+
width: 1,
|
|
953
|
+
height: 0,
|
|
954
|
+
top: 0,
|
|
955
|
+
left: 0,
|
|
956
|
+
},
|
|
957
|
+
corner: {
|
|
958
|
+
show: false,
|
|
959
|
+
top: 0,
|
|
960
|
+
left: 0,
|
|
961
|
+
},
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
const { currentCell, autoFillEndCell } = cellSelectionData;
|
|
965
|
+
|
|
966
|
+
let { leftColKey, rightColKey } = cellSelectionRangeData;
|
|
967
|
+
if (
|
|
968
|
+
currentCellSelectionType === CURRENT_CELL_SELECTION_TYPES.SINGLE
|
|
969
|
+
) {
|
|
970
|
+
leftColKey = currentCell.colKey;
|
|
971
|
+
rightColKey = currentCell.colKey;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
let leftmostColKey;
|
|
975
|
+
if (leftColKey !== autoFillEndCell.colKey) {
|
|
976
|
+
leftmostColKey = getLeftmostColKey({
|
|
977
|
+
colgroups,
|
|
978
|
+
colKeys: [leftColKey, autoFillEndCell.colKey],
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
let rightmostColKey;
|
|
983
|
+
if (rightColKey !== autoFillEndCell.colKey) {
|
|
984
|
+
rightmostColKey = getRightmostColKey({
|
|
985
|
+
colgroups,
|
|
986
|
+
colKeys: [rightColKey, autoFillEndCell.colKey],
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// autofilling direction
|
|
991
|
+
let autofillingDirection;
|
|
992
|
+
|
|
993
|
+
let rangeColKey1;
|
|
994
|
+
let rangeColKey2;
|
|
995
|
+
|
|
996
|
+
// auto fill end cell below
|
|
997
|
+
if (autoFillEndCellRect.top > areaPostions.bottomBorder.top) {
|
|
998
|
+
autofillingDirection = AUTOFILLING_DIRECTION.DOWN;
|
|
999
|
+
|
|
1000
|
+
rangeColKey1 = leftColKey;
|
|
1001
|
+
rangeColKey2 = rightColKey;
|
|
1002
|
+
|
|
1003
|
+
borders.topBorder.show = false;
|
|
1004
|
+
|
|
1005
|
+
borders.borderWidth = areaPostions.borderWidth;
|
|
1006
|
+
borders.borderHeight =
|
|
1007
|
+
autoFillEndCellRect.top -
|
|
1008
|
+
areaPostions.bottomBorder.top +
|
|
1009
|
+
autoFillEndCellRect.height;
|
|
1010
|
+
|
|
1011
|
+
borders.rightBorder.top = areaPostions.bottomBorder.top;
|
|
1012
|
+
borders.rightBorder.left = areaPostions.rightBorder.left;
|
|
1013
|
+
if (
|
|
1014
|
+
currentCellSelectionType ===
|
|
1015
|
+
CURRENT_CELL_SELECTION_TYPES.SINGLE
|
|
1016
|
+
) {
|
|
1017
|
+
borders.rightBorder.left++;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
borders.leftBorder.top = areaPostions.bottomBorder.top;
|
|
1021
|
+
borders.leftBorder.left = areaPostions.leftBorder.left;
|
|
1022
|
+
|
|
1023
|
+
borders.bottomBorder.top =
|
|
1024
|
+
autoFillEndCellRect.top + autoFillEndCellRect.height - 1;
|
|
1025
|
+
borders.bottomBorder.left = areaPostions.bottomBorder.left;
|
|
1026
|
+
}
|
|
1027
|
+
// end cell above
|
|
1028
|
+
else if (autoFillEndCellRect.top < areaPostions.topBorder.top) {
|
|
1029
|
+
autofillingDirection = AUTOFILLING_DIRECTION.UP;
|
|
1030
|
+
|
|
1031
|
+
rangeColKey1 = leftColKey;
|
|
1032
|
+
rangeColKey2 = rightColKey;
|
|
1033
|
+
|
|
1034
|
+
borders.bottomBorder.show = false;
|
|
1035
|
+
|
|
1036
|
+
borders.borderWidth = areaPostions.borderWidth;
|
|
1037
|
+
borders.borderHeight =
|
|
1038
|
+
areaPostions.topBorder.top - autoFillEndCellRect.top;
|
|
1039
|
+
|
|
1040
|
+
borders.topBorder.top = autoFillEndCellRect.top - 1;
|
|
1041
|
+
borders.topBorder.left = areaPostions.topBorder.left;
|
|
1042
|
+
|
|
1043
|
+
borders.rightBorder.top = autoFillEndCellRect.top;
|
|
1044
|
+
borders.rightBorder.left = areaPostions.rightBorder.left;
|
|
1045
|
+
if (
|
|
1046
|
+
currentCellSelectionType ===
|
|
1047
|
+
CURRENT_CELL_SELECTION_TYPES.SINGLE
|
|
1048
|
+
) {
|
|
1049
|
+
borders.rightBorder.left++;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
borders.leftBorder.top = autoFillEndCellRect.top;
|
|
1053
|
+
borders.leftBorder.left = areaPostions.leftBorder.left;
|
|
1054
|
+
}
|
|
1055
|
+
// auto fill end cell right
|
|
1056
|
+
else if (
|
|
1057
|
+
rightmostColKey === autoFillEndCell.colKey &&
|
|
1058
|
+
!isEmptyValue(rightmostColKey)
|
|
1059
|
+
) {
|
|
1060
|
+
autofillingDirection = AUTOFILLING_DIRECTION.RIGHT;
|
|
1061
|
+
|
|
1062
|
+
rangeColKey1 = getNextColKey({
|
|
1063
|
+
colgroups,
|
|
1064
|
+
currentColKey: rightColKey,
|
|
1065
|
+
});
|
|
1066
|
+
rangeColKey2 = autoFillEndCell.colKey;
|
|
1067
|
+
|
|
1068
|
+
borders.leftBorder.show = false;
|
|
1069
|
+
|
|
1070
|
+
borders.borderWidth =
|
|
1071
|
+
autoFillEndCellRect.left -
|
|
1072
|
+
areaPostions.rightBorder.left +
|
|
1073
|
+
autoFillEndCellRect.width +
|
|
1074
|
+
1;
|
|
1075
|
+
borders.borderHeight = areaPostions.borderHeight;
|
|
1076
|
+
|
|
1077
|
+
borders.topBorder.top = areaPostions.topBorder.top;
|
|
1078
|
+
borders.topBorder.left = areaPostions.rightBorder.left - 1;
|
|
1079
|
+
|
|
1080
|
+
borders.rightBorder.top = areaPostions.topBorder.top;
|
|
1081
|
+
borders.rightBorder.left =
|
|
1082
|
+
autoFillEndCellRect.left + autoFillEndCellRect.width - 1;
|
|
1083
|
+
|
|
1084
|
+
borders.bottomBorder.top = areaPostions.bottomBorder.top;
|
|
1085
|
+
borders.bottomBorder.left = areaPostions.rightBorder.left - 1;
|
|
1086
|
+
}
|
|
1087
|
+
// auto fill end cell left
|
|
1088
|
+
else if (
|
|
1089
|
+
leftmostColKey === autoFillEndCell.colKey &&
|
|
1090
|
+
!isEmptyValue(leftmostColKey)
|
|
1091
|
+
) {
|
|
1092
|
+
autofillingDirection = AUTOFILLING_DIRECTION.LEFT;
|
|
1093
|
+
|
|
1094
|
+
rangeColKey1 = getPreviewColKey({
|
|
1095
|
+
colgroups,
|
|
1096
|
+
currentColKey: leftColKey,
|
|
1097
|
+
});
|
|
1098
|
+
rangeColKey2 = autoFillEndCell.colKey;
|
|
1099
|
+
|
|
1100
|
+
borders.rightBorder.show = false;
|
|
1101
|
+
|
|
1102
|
+
borders.borderWidth =
|
|
1103
|
+
areaPostions.leftBorder.left - autoFillEndCellRect.left + 1;
|
|
1104
|
+
borders.borderHeight = areaPostions.borderHeight;
|
|
1105
|
+
|
|
1106
|
+
borders.topBorder.top = areaPostions.topBorder.top;
|
|
1107
|
+
borders.topBorder.left = autoFillEndCellRect.left;
|
|
1108
|
+
|
|
1109
|
+
borders.rightBorder.left = areaPostions.topBorder.left;
|
|
1110
|
+
|
|
1111
|
+
borders.bottomBorder.top = areaPostions.bottomBorder.top;
|
|
1112
|
+
borders.bottomBorder.left = autoFillEndCellRect.left;
|
|
1113
|
+
|
|
1114
|
+
borders.leftBorder.top = areaPostions.topBorder.top;
|
|
1115
|
+
borders.leftBorder.left = autoFillEndCellRect.left;
|
|
1116
|
+
} else {
|
|
1117
|
+
return result;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
const { directionX, directionY } = cellAutofillOption;
|
|
1121
|
+
if (isBoolean(directionX) && !directionX) {
|
|
1122
|
+
if (
|
|
1123
|
+
autofillingDirection === AUTOFILLING_DIRECTION.LEFT ||
|
|
1124
|
+
autofillingDirection === AUTOFILLING_DIRECTION.RIGHT
|
|
1125
|
+
) {
|
|
1126
|
+
return false;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if (isBoolean(directionY) && !directionY) {
|
|
1131
|
+
if (
|
|
1132
|
+
autofillingDirection === AUTOFILLING_DIRECTION.UP ||
|
|
1133
|
+
autofillingDirection === AUTOFILLING_DIRECTION.DOWN
|
|
1134
|
+
) {
|
|
1135
|
+
return false;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
const totalColKeys = getColKeysByRangeColKeys({
|
|
1140
|
+
colKey1: rangeColKey1,
|
|
1141
|
+
colKey2: rangeColKey2,
|
|
1142
|
+
colgroups,
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1145
|
+
let fixedColKeys = getColKeysByFixedTypeWithinColKeys({
|
|
1146
|
+
colKeys: totalColKeys,
|
|
1147
|
+
fixedType,
|
|
1148
|
+
colgroups,
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
result = this.getBorders({
|
|
1152
|
+
className: "selection-autofill-area",
|
|
1153
|
+
...borders,
|
|
1154
|
+
fixedType,
|
|
1155
|
+
totalColKeys,
|
|
1156
|
+
fixedColKeys,
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
if (result) {
|
|
1160
|
+
this.dispatch(
|
|
1161
|
+
COMPS_NAME.VE_TABLE,
|
|
1162
|
+
EMIT_EVENTS.AUTOFILLING_DIRECTION_CHANGE,
|
|
1163
|
+
autofillingDirection,
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
return result;
|
|
1168
|
+
},
|
|
1169
|
+
|
|
1170
|
+
// get borders
|
|
1171
|
+
getBorders({
|
|
1172
|
+
borderWidth,
|
|
1173
|
+
borderHeight,
|
|
1174
|
+
topBorder,
|
|
1175
|
+
rightBorder,
|
|
1176
|
+
bottomBorder,
|
|
1177
|
+
leftBorder,
|
|
1178
|
+
corner,
|
|
1179
|
+
className,
|
|
1180
|
+
fixedType,
|
|
1181
|
+
totalColKeys,
|
|
1182
|
+
fixedColKeys,
|
|
1183
|
+
}) {
|
|
1184
|
+
const {
|
|
1185
|
+
cornerCellInfo,
|
|
1186
|
+
colgroups,
|
|
1187
|
+
isFirstSelectionRow,
|
|
1188
|
+
isFirstSelectionCol,
|
|
1189
|
+
isFirstNotFixedSelectionCol,
|
|
1190
|
+
showCorner,
|
|
1191
|
+
} = this;
|
|
1192
|
+
|
|
1193
|
+
let isRender = true;
|
|
1194
|
+
|
|
1195
|
+
if (fixedType) {
|
|
1196
|
+
isRender = isExistGivenFixedColKey({
|
|
1197
|
+
fixedType,
|
|
1198
|
+
colKeys: totalColKeys,
|
|
1199
|
+
colgroups,
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
// middle normal area
|
|
1203
|
+
else {
|
|
1204
|
+
isRender = isExistNotFixedColKey({
|
|
1205
|
+
colKeys: totalColKeys,
|
|
1206
|
+
colgroups,
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
if (!isRender) {
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// fixed columns total width
|
|
1215
|
+
let fixedColsTotalWidth = 0;
|
|
1216
|
+
if (fixedColKeys.length) {
|
|
1217
|
+
fixedColsTotalWidth = getTotalWidthByColKeys({
|
|
1218
|
+
colKeys: fixedColKeys,
|
|
1219
|
+
colgroups,
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
if (fixedType) {
|
|
1224
|
+
borderWidth = fixedColsTotalWidth;
|
|
1225
|
+
if (fixedType === COLUMN_FIXED_TYPE.LEFT) {
|
|
1226
|
+
borderWidth += 1;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
if (fixedType === COLUMN_FIXED_TYPE.LEFT) {
|
|
1231
|
+
if (totalColKeys.length !== fixedColKeys.length) {
|
|
1232
|
+
rightBorder.show = false;
|
|
1233
|
+
corner.show = false;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
if (fixedType === COLUMN_FIXED_TYPE.RIGHT) {
|
|
1238
|
+
if (totalColKeys.length !== fixedColKeys.length) {
|
|
1239
|
+
leftBorder.show = false;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
topBorder.left = rightBorder.left - borderWidth + 1;
|
|
1243
|
+
bottomBorder.left = rightBorder.left - borderWidth + 1;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// solved first row、first column、first not fixed column selection border hidden
|
|
1247
|
+
if (isFirstSelectionRow) {
|
|
1248
|
+
topBorder.top += 1;
|
|
1249
|
+
}
|
|
1250
|
+
if (isFirstSelectionCol) {
|
|
1251
|
+
leftBorder.left += 1;
|
|
1252
|
+
}
|
|
1253
|
+
if (isFirstNotFixedSelectionCol) {
|
|
1254
|
+
leftBorder.left += 1;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
let cornerTop = corner.top;
|
|
1258
|
+
let cornerLeft = corner.left;
|
|
1259
|
+
let cornerBorderRightWidth = "1px";
|
|
1260
|
+
let cornerBorderBottomtWidth = "1px";
|
|
1261
|
+
|
|
1262
|
+
if (cornerCellInfo.isLastRow) {
|
|
1263
|
+
cornerTop -= 3;
|
|
1264
|
+
cornerBorderBottomtWidth = "0px";
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
if (cornerCellInfo.isLastColumn) {
|
|
1268
|
+
cornerLeft -= 3;
|
|
1269
|
+
cornerBorderRightWidth = "0px";
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
if (!showCorner) {
|
|
1273
|
+
corner.show = false;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
// corner props
|
|
1277
|
+
const cornerProps = {
|
|
1278
|
+
class: clsName("selection-corner"),
|
|
1279
|
+
style: {
|
|
1280
|
+
display: corner.show ? "block" : "none",
|
|
1281
|
+
top: cornerTop + "px",
|
|
1282
|
+
left: cornerLeft + "px",
|
|
1283
|
+
borderWidth: `1px ${cornerBorderRightWidth} ${cornerBorderBottomtWidth} 1px`,
|
|
1284
|
+
},
|
|
1285
|
+
on: {
|
|
1286
|
+
mousedown: (e) => {
|
|
1287
|
+
this.dispatch(
|
|
1288
|
+
COMPS_NAME.VE_TABLE,
|
|
1289
|
+
EMIT_EVENTS.SELECTION_CORNER_MOUSEDOWN,
|
|
1290
|
+
{
|
|
1291
|
+
event: e,
|
|
1292
|
+
},
|
|
1293
|
+
);
|
|
1294
|
+
},
|
|
1295
|
+
mouseup: (e) => {
|
|
1296
|
+
this.dispatch(
|
|
1297
|
+
COMPS_NAME.VE_TABLE,
|
|
1298
|
+
EMIT_EVENTS.SELECTION_CORNER_MOUSEUP,
|
|
1299
|
+
{
|
|
1300
|
+
event: e,
|
|
1301
|
+
},
|
|
1302
|
+
);
|
|
1303
|
+
},
|
|
1304
|
+
},
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
return (
|
|
1308
|
+
<div class={clsName(className)}>
|
|
1309
|
+
{/* top */}
|
|
1310
|
+
<div
|
|
1311
|
+
style={{
|
|
1312
|
+
display: topBorder.show ? "block" : "none",
|
|
1313
|
+
width: borderWidth + "px",
|
|
1314
|
+
height: topBorder.height + "px",
|
|
1315
|
+
top: topBorder.top + "px",
|
|
1316
|
+
left: topBorder.left + "px",
|
|
1317
|
+
}}
|
|
1318
|
+
class={clsName("selection-border")}
|
|
1319
|
+
></div>
|
|
1320
|
+
{/* right */}
|
|
1321
|
+
<div
|
|
1322
|
+
style={{
|
|
1323
|
+
display: rightBorder.show ? "block" : "none",
|
|
1324
|
+
width: rightBorder.width + "px",
|
|
1325
|
+
height: borderHeight + "px",
|
|
1326
|
+
top: rightBorder.top + "px",
|
|
1327
|
+
left: rightBorder.left + "px",
|
|
1328
|
+
}}
|
|
1329
|
+
class={clsName("selection-border")}
|
|
1330
|
+
></div>
|
|
1331
|
+
{/* bottom */}
|
|
1332
|
+
<div
|
|
1333
|
+
style={{
|
|
1334
|
+
display: bottomBorder.show ? "block" : "none",
|
|
1335
|
+
width: borderWidth + "px",
|
|
1336
|
+
height: bottomBorder.height + "px",
|
|
1337
|
+
top: bottomBorder.top + "px",
|
|
1338
|
+
left: bottomBorder.left + "px",
|
|
1339
|
+
}}
|
|
1340
|
+
class={clsName("selection-border")}
|
|
1341
|
+
></div>
|
|
1342
|
+
{/* left */}
|
|
1343
|
+
<div
|
|
1344
|
+
style={{
|
|
1345
|
+
display: leftBorder.show ? "block" : "none",
|
|
1346
|
+
width: leftBorder.width + "px",
|
|
1347
|
+
height: borderHeight + "px",
|
|
1348
|
+
top: leftBorder.top + "px",
|
|
1349
|
+
left: leftBorder.left + "px",
|
|
1350
|
+
}}
|
|
1351
|
+
class={clsName("selection-border")}
|
|
1352
|
+
></div>
|
|
1353
|
+
{/* corner */}
|
|
1354
|
+
{<div {...cornerProps}></div>}
|
|
1355
|
+
</div>
|
|
1356
|
+
);
|
|
1357
|
+
},
|
|
1358
|
+
|
|
1359
|
+
// get area rect
|
|
1360
|
+
getAreaLayer({
|
|
1361
|
+
borderWidth,
|
|
1362
|
+
borderHeight,
|
|
1363
|
+
topBorder,
|
|
1364
|
+
className,
|
|
1365
|
+
fixedType,
|
|
1366
|
+
totalColKeys,
|
|
1367
|
+
fixedColKeys,
|
|
1368
|
+
}) {
|
|
1369
|
+
const { colgroups } = this;
|
|
1370
|
+
|
|
1371
|
+
let isRender = true;
|
|
1372
|
+
|
|
1373
|
+
if (fixedType) {
|
|
1374
|
+
isRender = isExistGivenFixedColKey({
|
|
1375
|
+
fixedType,
|
|
1376
|
+
colKeys: totalColKeys,
|
|
1377
|
+
colgroups,
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
// middle normal area
|
|
1381
|
+
else {
|
|
1382
|
+
isRender = isExistNotFixedColKey({
|
|
1383
|
+
colKeys: totalColKeys,
|
|
1384
|
+
colgroups,
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
if (!isRender) {
|
|
1389
|
+
return null;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// fixed columns total width
|
|
1393
|
+
let fixedColsTotalWidth = 0;
|
|
1394
|
+
if (fixedColKeys.length) {
|
|
1395
|
+
fixedColsTotalWidth = getTotalWidthByColKeys({
|
|
1396
|
+
colKeys: fixedColKeys,
|
|
1397
|
+
colgroups,
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
if (fixedType) {
|
|
1402
|
+
borderWidth = fixedColsTotalWidth;
|
|
1403
|
+
if (fixedType === COLUMN_FIXED_TYPE.LEFT) {
|
|
1404
|
+
borderWidth += 1;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
return (
|
|
1409
|
+
<div
|
|
1410
|
+
class={clsName(className)}
|
|
1411
|
+
style={{
|
|
1412
|
+
top: topBorder.top + "px",
|
|
1413
|
+
left: topBorder.left + "px",
|
|
1414
|
+
width: borderWidth + "px",
|
|
1415
|
+
height: borderHeight + "px",
|
|
1416
|
+
}}
|
|
1417
|
+
></div>
|
|
1418
|
+
);
|
|
1419
|
+
},
|
|
1420
|
+
|
|
1421
|
+
/*
|
|
1422
|
+
get table first row cell by col key
|
|
1423
|
+
用作跨页单元格选择,表格大小变化或者存在横向滚动条时,区域选择位置自动校准
|
|
1424
|
+
*/
|
|
1425
|
+
getTableFirstRowCellByColKey(colKey) {
|
|
1426
|
+
let result = null;
|
|
1427
|
+
|
|
1428
|
+
const { tableEl } = this;
|
|
1429
|
+
|
|
1430
|
+
if (tableEl) {
|
|
1431
|
+
result = tableEl.querySelector(
|
|
1432
|
+
`tbody.ve-table-body tr td[col-key="${colKey}"]`,
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1435
|
+
return result;
|
|
1436
|
+
},
|
|
1437
|
+
|
|
1438
|
+
/*
|
|
1439
|
+
get table last row cell by col key
|
|
1440
|
+
用作跨页单元格选择,表格大小变化或者存在横向滚动条时,区域选择位置自动校准
|
|
1441
|
+
*/
|
|
1442
|
+
getTableLastRowCellByColKey(colKey) {
|
|
1443
|
+
let result = null;
|
|
1444
|
+
|
|
1445
|
+
const { tableEl } = this;
|
|
1446
|
+
|
|
1447
|
+
if (tableEl) {
|
|
1448
|
+
result = tableEl.querySelector(
|
|
1449
|
+
`tbody.ve-table-body tr:last-child td[col-key="${colKey}"]`,
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
return result;
|
|
1453
|
+
},
|
|
1454
|
+
|
|
1455
|
+
// get table el
|
|
1456
|
+
getTableCellEl({ rowKey, colKey }) {
|
|
1457
|
+
let result = null;
|
|
1458
|
+
|
|
1459
|
+
const { tableEl } = this;
|
|
1460
|
+
|
|
1461
|
+
if (tableEl) {
|
|
1462
|
+
result = tableEl.querySelector(
|
|
1463
|
+
`tbody.ve-table-body tr[row-key="${rowKey}"] td[col-key="${colKey}"]`,
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
return result;
|
|
1467
|
+
},
|
|
1468
|
+
|
|
1469
|
+
// set current cell el
|
|
1470
|
+
setCurrentCellEl() {
|
|
1471
|
+
const { cellSelectionData } = this;
|
|
1472
|
+
|
|
1473
|
+
const { rowKey, colKey } = cellSelectionData.currentCell;
|
|
1474
|
+
|
|
1475
|
+
if (!isEmptyValue(rowKey) && !isEmptyValue(colKey)) {
|
|
1476
|
+
const cellEl = this.getTableCellEl({
|
|
1477
|
+
rowKey,
|
|
1478
|
+
colKey,
|
|
1479
|
+
});
|
|
1480
|
+
if (cellEl) {
|
|
1481
|
+
this.currentCellEl = cellEl;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1485
|
+
|
|
1486
|
+
// set normal end cell el
|
|
1487
|
+
setNormalEndCellEl() {
|
|
1488
|
+
const { cellSelectionData } = this;
|
|
1489
|
+
|
|
1490
|
+
const { rowKey, colKey } = cellSelectionData.normalEndCell;
|
|
1491
|
+
|
|
1492
|
+
if (!isEmptyValue(rowKey) && !isEmptyValue(colKey)) {
|
|
1493
|
+
const cellEl = this.getTableCellEl({
|
|
1494
|
+
rowKey,
|
|
1495
|
+
colKey,
|
|
1496
|
+
});
|
|
1497
|
+
if (cellEl) {
|
|
1498
|
+
this.normalEndCellEl = cellEl;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
|
|
1503
|
+
// set auto fill cell el
|
|
1504
|
+
setAutofillEndCellEl() {
|
|
1505
|
+
const { cellSelectionData, tableEl } = this;
|
|
1506
|
+
|
|
1507
|
+
const { rowKey, colKey } = cellSelectionData.autoFillEndCell;
|
|
1508
|
+
|
|
1509
|
+
if (tableEl) {
|
|
1510
|
+
const autoFillEndCellEl = tableEl.querySelector(
|
|
1511
|
+
`tbody.ve-table-body tr[row-key="${rowKey}"] td[col-key="${colKey}"]`,
|
|
1512
|
+
);
|
|
1513
|
+
|
|
1514
|
+
if (autoFillEndCellEl) {
|
|
1515
|
+
this.autoFillEndCellEl = autoFillEndCellEl;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
|
|
1520
|
+
// clear auto fill end cell rect
|
|
1521
|
+
clearAutofillEndCellRect() {
|
|
1522
|
+
this.autoFillEndCellEl = null;
|
|
1523
|
+
this.cellSelectionRect.autoFillEndCellRect = {
|
|
1524
|
+
left: 0,
|
|
1525
|
+
top: 0,
|
|
1526
|
+
width: 0,
|
|
1527
|
+
height: 0,
|
|
1528
|
+
};
|
|
1529
|
+
},
|
|
1530
|
+
|
|
1531
|
+
// clear current cell rect
|
|
1532
|
+
[INSTANCE_METHODS.CLEAR_CURRENT_CELL_RECT]() {
|
|
1533
|
+
this.currentCellEl = null;
|
|
1534
|
+
this.cellSelectionRect.currentCellRect = {
|
|
1535
|
+
left: 0,
|
|
1536
|
+
top: 0,
|
|
1537
|
+
width: 0,
|
|
1538
|
+
height: 0,
|
|
1539
|
+
};
|
|
1540
|
+
},
|
|
1541
|
+
|
|
1542
|
+
// clear normal end cell rect
|
|
1543
|
+
[INSTANCE_METHODS.CLEAR_NORMAL_END_CELL_RECT]() {
|
|
1544
|
+
this.normalEndCellEl = null;
|
|
1545
|
+
this.cellSelectionRect.normalEndCellRect = {
|
|
1546
|
+
left: 0,
|
|
1547
|
+
top: 0,
|
|
1548
|
+
width: 0,
|
|
1549
|
+
height: 0,
|
|
1550
|
+
};
|
|
1551
|
+
},
|
|
1552
|
+
},
|
|
1553
|
+
|
|
1554
|
+
created() {
|
|
1555
|
+
// debounce reset cell positions
|
|
1556
|
+
this.debounceResetCellPositions = debounce(
|
|
1557
|
+
this.resetCellPositions,
|
|
1558
|
+
210,
|
|
1559
|
+
);
|
|
1560
|
+
// debounce set cell els
|
|
1561
|
+
this.debounceSetCellEls = debounce(this.setCellEls, 200);
|
|
1562
|
+
},
|
|
1563
|
+
|
|
1564
|
+
render() {
|
|
1565
|
+
if (!this.selectionBordersVisibility) {
|
|
1566
|
+
return null;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// fixed left
|
|
1570
|
+
const fixedLeftSelectionCurrent = this.getSelectionCurrent({
|
|
1571
|
+
fixedType: COLUMN_FIXED_TYPE.LEFT,
|
|
1572
|
+
});
|
|
1573
|
+
const fixedLeftSelectionArea = this.getSelectionAreas({
|
|
1574
|
+
fixedType: COLUMN_FIXED_TYPE.LEFT,
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
const fixedLeftAutoFillArea =
|
|
1578
|
+
fixedLeftSelectionCurrent.autoFillArea ||
|
|
1579
|
+
fixedLeftSelectionArea.autoFillArea;
|
|
1580
|
+
|
|
1581
|
+
// middle
|
|
1582
|
+
const middleSelectionCurrent = this.getSelectionCurrent({
|
|
1583
|
+
fixedType: "",
|
|
1584
|
+
});
|
|
1585
|
+
const middleSelectionArea = this.getSelectionAreas({
|
|
1586
|
+
fixedType: "",
|
|
1587
|
+
});
|
|
1588
|
+
|
|
1589
|
+
const middleAutoFillArea =
|
|
1590
|
+
middleSelectionCurrent.autoFillArea ||
|
|
1591
|
+
middleSelectionArea.autoFillArea;
|
|
1592
|
+
|
|
1593
|
+
// fixed right
|
|
1594
|
+
const fixedRightSelectionCurrent = this.getSelectionCurrent({
|
|
1595
|
+
fixedType: COLUMN_FIXED_TYPE.RIGHT,
|
|
1596
|
+
});
|
|
1597
|
+
const fixedRightSelectionArea = this.getSelectionAreas({
|
|
1598
|
+
fixedType: COLUMN_FIXED_TYPE.RIGHT,
|
|
1599
|
+
});
|
|
1600
|
+
|
|
1601
|
+
const fixedRightAutoFillArea =
|
|
1602
|
+
fixedRightSelectionCurrent.autoFillArea ||
|
|
1603
|
+
fixedRightSelectionArea.autoFillArea;
|
|
1604
|
+
|
|
1605
|
+
return (
|
|
1606
|
+
<div
|
|
1607
|
+
class={clsName("selection-wrapper")}
|
|
1608
|
+
style={{ visibility: this.isCellEditing ? "hidden" : "" }}
|
|
1609
|
+
>
|
|
1610
|
+
<div class={clsName("selection-fixed-left")}>
|
|
1611
|
+
{/* current */}
|
|
1612
|
+
{fixedLeftSelectionCurrent.selectionCurrent}
|
|
1613
|
+
{/* area */}
|
|
1614
|
+
{fixedLeftSelectionArea.normalArea}
|
|
1615
|
+
{/* auto fill */}
|
|
1616
|
+
{fixedLeftAutoFillArea}
|
|
1617
|
+
{/* area layer */}
|
|
1618
|
+
{fixedLeftSelectionArea.normalAreaLayer}
|
|
1619
|
+
</div>
|
|
1620
|
+
<div class={clsName("selection-middle")}>
|
|
1621
|
+
{/* current */}
|
|
1622
|
+
{middleSelectionCurrent.selectionCurrent}
|
|
1623
|
+
{/* area */}
|
|
1624
|
+
{middleSelectionArea.normalArea}
|
|
1625
|
+
{/* auto fill */}
|
|
1626
|
+
{middleAutoFillArea}
|
|
1627
|
+
{/* area layer */}
|
|
1628
|
+
{middleSelectionArea.normalAreaLayer}
|
|
1629
|
+
</div>
|
|
1630
|
+
<div class={clsName("selection-fixed-right")}>
|
|
1631
|
+
{/* current */}
|
|
1632
|
+
{fixedRightSelectionCurrent.selectionCurrent}
|
|
1633
|
+
{/* area */}
|
|
1634
|
+
{fixedRightSelectionArea.normalArea}
|
|
1635
|
+
{/* auto fill */}
|
|
1636
|
+
{fixedRightAutoFillArea}
|
|
1637
|
+
{/* area layer */}
|
|
1638
|
+
{fixedRightSelectionArea.normalAreaLayer}
|
|
1639
|
+
</div>
|
|
1640
|
+
</div>
|
|
1641
|
+
);
|
|
1642
|
+
},
|
|
1643
|
+
};
|