vxe-table 4.23.7 → 4.23.9
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/dist/all.esm.js +5859 -4018
- package/es/colgroup/index.js +1 -1
- package/es/column/index.js +1 -1
- package/es/components.d.ts +3 -0
- package/es/components.js +4 -8
- package/es/grid/index.js +1 -1
- package/es/grid/src/emits.js +1 -15
- package/es/grid/src/grid.js +398 -121
- package/es/grid/src/props.js +1 -1
- package/es/index.esm.js +6 -0
- package/es/index.js +6 -0
- package/es/table/index.js +1 -1
- package/es/table/module/custom/hook.js +50 -43
- package/es/table/module/custom/panel.js +778 -528
- package/es/table/module/edit/hook.js +141 -63
- package/es/table/module/export/export-panel.js +400 -317
- package/es/table/module/export/hook.js +396 -338
- package/es/table/module/export/import-panel.js +153 -124
- package/es/table/module/filter/hook.js +17 -3
- package/es/table/module/filter/panel.js +147 -85
- package/es/table/module/keyboard/hook.js +9 -5
- package/es/table/module/menu/hook.js +1 -1
- package/es/table/module/menu/panel.js +198 -127
- package/es/table/module/validator/hook.js +1 -1
- package/es/table/render/index.js +152 -99
- package/es/table/src/body.js +356 -234
- package/es/table/src/cell.js +427 -270
- package/es/table/src/columnInfo.js +2 -1
- package/es/table/src/footer.js +145 -100
- package/es/table/src/group.js +7 -3
- package/es/table/src/header.js +230 -173
- package/es/table/src/props.js +1 -1
- package/es/table/src/table.js +1504 -1031
- package/es/table/src/util.js +15 -19
- package/es/toolbar/index.js +1 -1
- package/es/toolbar/src/toolbar.js +133 -76
- package/es/ui/index.d.ts +0 -1
- package/es/ui/index.js +1 -2
- package/es/ui/src/dom.js +9 -6
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.d.ts +1 -1
- package/es/v-x-e-table/index.d.ts +0 -1
- package/es/v-x-e-table/index.js +0 -1
- package/lib/colgroup/index.js +5 -5
- package/lib/column/index.js +5 -5
- package/lib/components.js +8 -12
- package/lib/grid/index.js +4 -4
- package/lib/grid/src/emits.js +1 -15
- package/lib/grid/src/grid.js +419 -142
- package/lib/grid/src/props.js +2 -2
- package/lib/index.common.js +6 -0
- package/lib/index.js +6 -0
- package/lib/index.umd.js +5825 -3945
- package/lib/index.umd.min.js +3 -3
- package/lib/table/index.js +5 -5
- package/lib/table/module/custom/hook.js +51 -44
- package/lib/table/module/custom/panel.js +790 -540
- package/lib/table/module/edit/hook.js +142 -64
- package/lib/table/module/export/export-panel.js +406 -323
- package/lib/table/module/export/hook.js +419 -361
- package/lib/table/module/export/import-panel.js +157 -128
- package/lib/table/module/filter/hook.js +18 -4
- package/lib/table/module/filter/panel.js +149 -87
- package/lib/table/module/keyboard/hook.js +10 -6
- package/lib/table/module/menu/hook.js +2 -2
- package/lib/table/module/menu/panel.js +199 -128
- package/lib/table/module/validator/hook.js +2 -2
- package/lib/table/render/index.js +153 -100
- package/lib/table/src/body.js +357 -235
- package/lib/table/src/cell.js +428 -271
- package/lib/table/src/columnInfo.js +3 -2
- package/lib/table/src/footer.js +146 -101
- package/lib/table/src/group.js +7 -3
- package/lib/table/src/header.js +231 -174
- package/lib/table/src/props.js +2 -2
- package/lib/table/src/table.js +1487 -1045
- package/lib/table/src/util.js +15 -19
- package/lib/toolbar/index.js +4 -4
- package/lib/toolbar/src/toolbar.js +135 -78
- package/lib/ui/index.js +1 -3
- package/lib/ui/src/dom.js +9 -6
- package/lib/ui/src/log.js +1 -1
- package/lib/v-x-e-table/index.js +0 -2
- package/package.json +8 -3
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +41 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +5 -19
- package/packages/grid/src/grid.ts +2229 -1925
- package/packages/grid/src/props.ts +22 -23
- package/packages/index.ts +11 -4
- package/packages/locale/lang/fr-FR.ts +15 -15
- package/packages/locale/lang/it-IT.ts +4 -4
- package/packages/locale/lang/uk-UA.ts +1 -1
- package/packages/locale/lang/uz-UZ.ts +13 -13
- package/packages/locale/lang/zh-CN.ts +907 -907
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +510 -503
- package/packages/table/module/custom/panel.ts +2002 -1743
- package/packages/table/module/edit/hook.ts +1224 -1131
- package/packages/table/module/export/export-panel.ts +697 -611
- package/packages/table/module/export/hook.ts +2160 -2059
- package/packages/table/module/export/import-panel.ts +319 -279
- package/packages/table/module/export/util.ts +25 -24
- package/packages/table/module/filter/hook.ts +519 -501
- package/packages/table/module/filter/panel.ts +368 -304
- package/packages/table/module/keyboard/hook.ts +498 -494
- package/packages/table/module/menu/hook.ts +330 -330
- package/packages/table/module/menu/panel.ts +272 -201
- package/packages/table/module/validator/hook.ts +653 -635
- package/packages/table/render/index.ts +1819 -1744
- package/packages/table/src/body.ts +1078 -955
- package/packages/table/src/cell.ts +1524 -1359
- package/packages/table/src/column.ts +192 -192
- package/packages/table/src/columnInfo.ts +232 -232
- package/packages/table/src/emits.ts +134 -134
- package/packages/table/src/footer.ts +425 -380
- package/packages/table/src/group.ts +67 -63
- package/packages/table/src/header.ts +642 -581
- package/packages/table/src/props.ts +336 -336
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +16011 -15454
- package/packages/table/src/use/cell-view.ts +41 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1206 -1216
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +768 -706
- package/packages/ui/index.ts +519 -521
- package/packages/ui/src/anime.ts +51 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +466 -463
- package/packages/ui/src/log.ts +19 -19
- package/packages/ui/src/utils.ts +66 -66
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +3 -4
- package/packages/v-x-e-table/index.ts +3 -4
- package/types/all.d.ts +76 -76
- package/types/index.d.ts +4 -4
- /package/dist/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/dist/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/dist/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
- /package/es/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/es/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/es/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
- /package/lib/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/lib/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/lib/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
|
@@ -1,1131 +1,1224 @@
|
|
|
1
|
-
import { reactive, nextTick } from 'vue'
|
|
2
|
-
import XEUtils from 'xe-utils'
|
|
3
|
-
import { VxeUI } from '
|
|
4
|
-
import { hasEnableConf, isEnableConf } from '../../../ui/src/utils'
|
|
5
|
-
import { getCellValue, setCellValue, getRowid } from '../../src/util'
|
|
6
|
-
import { removeClass, addClass } from '../../../ui/src/dom'
|
|
7
|
-
import { createComponentLog } from '../../../ui/src/log'
|
|
8
|
-
|
|
9
|
-
import type { VxeTableConstructor, TableEditMethods, TableEditPrivateMethods, VxeTableDefines, VxeGlobalRendererHandles } from '../../../../types'
|
|
10
|
-
|
|
11
|
-
const { warnLog, errLog } = createComponentLog('table')
|
|
12
|
-
|
|
13
|
-
const { getConfig, renderer, hooks, getI18n } = VxeUI
|
|
14
|
-
|
|
15
|
-
const tableEditMethodKeys: (keyof TableEditMethods)[] = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
$xeTable
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
row
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
//
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
return
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
const
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
return
|
|
881
|
-
},
|
|
882
|
-
|
|
883
|
-
warnLog('vxe.error.delFunc', ['
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
const {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
return
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
return
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
let
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
},
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1
|
+
import { reactive, nextTick } from 'vue'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
import { VxeUI } from '@vxe-ui/core'
|
|
4
|
+
import { hasEnableConf, isEnableConf } from '../../../ui/src/utils'
|
|
5
|
+
import { getCellValue, setCellValue, getRowid } from '../../src/util'
|
|
6
|
+
import { removeClass, addClass } from '../../../ui/src/dom'
|
|
7
|
+
import { createComponentLog } from '../../../ui/src/log'
|
|
8
|
+
|
|
9
|
+
import type { VxeTableConstructor, TableEditMethods, TableEditPrivateMethods, VxeTableDefines, VxeGlobalRendererHandles } from '../../../../types'
|
|
10
|
+
|
|
11
|
+
const { warnLog, errLog } = createComponentLog('table')
|
|
12
|
+
|
|
13
|
+
const { getConfig, renderer, hooks, getI18n } = VxeUI
|
|
14
|
+
|
|
15
|
+
const tableEditMethodKeys: (keyof TableEditMethods)[] = [
|
|
16
|
+
'insert',
|
|
17
|
+
'insertAt',
|
|
18
|
+
'insertNextAt',
|
|
19
|
+
'insertChild',
|
|
20
|
+
'insertChildAt',
|
|
21
|
+
'insertChildNextAt',
|
|
22
|
+
'remove',
|
|
23
|
+
'removeCheckboxRow',
|
|
24
|
+
'removeRadioRow',
|
|
25
|
+
'removeCurrentRow',
|
|
26
|
+
'getRecordset',
|
|
27
|
+
'getInsertRecords',
|
|
28
|
+
'getRemoveRecords',
|
|
29
|
+
'getUpdateRecords',
|
|
30
|
+
'getEditRecord',
|
|
31
|
+
'getActiveRecord',
|
|
32
|
+
'getEditCell',
|
|
33
|
+
'getSelectedCell',
|
|
34
|
+
'clearEdit',
|
|
35
|
+
'clearActived',
|
|
36
|
+
'clearSelected',
|
|
37
|
+
'isEditByRow',
|
|
38
|
+
'isActiveByRow',
|
|
39
|
+
'setEditRow',
|
|
40
|
+
'setActiveRow',
|
|
41
|
+
'setEditCell',
|
|
42
|
+
'setActiveCell',
|
|
43
|
+
'setSelectCell'
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
hooks.add('tableEditModule', {
|
|
47
|
+
setupTable($xeTable) {
|
|
48
|
+
const { props, reactData, internalData } = $xeTable
|
|
49
|
+
const { refElem } = $xeTable.getRefMaps()
|
|
50
|
+
const { computeMouseOpts, computeEditOpts, computeCheckboxOpts, computeTreeOpts, computeValidOpts, computeRendererOpts } = $xeTable.getComputeMaps()
|
|
51
|
+
|
|
52
|
+
const browseObj = XEUtils.browse()
|
|
53
|
+
|
|
54
|
+
let editMethods = {} as TableEditMethods
|
|
55
|
+
let editPrivateMethods = {} as TableEditPrivateMethods
|
|
56
|
+
|
|
57
|
+
const getEditColumnModel = (row: any, column: VxeTableDefines.ColumnInfo) => {
|
|
58
|
+
const { model, editRender } = column
|
|
59
|
+
if (editRender) {
|
|
60
|
+
model.value = getCellValue(row, column)
|
|
61
|
+
model.update = false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const setEditColumnModel = (row: any, column: VxeTableDefines.ColumnInfo) => {
|
|
66
|
+
const { model, editRender } = column
|
|
67
|
+
if (editRender && model.update) {
|
|
68
|
+
setCellValue(row, column, model.value)
|
|
69
|
+
model.update = false
|
|
70
|
+
model.value = null
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const removeCellSelectedClass = () => {
|
|
75
|
+
const el = refElem.value
|
|
76
|
+
if (el) {
|
|
77
|
+
const cell = el.querySelector('.col--selected')
|
|
78
|
+
if (cell) {
|
|
79
|
+
removeClass(cell, 'col--selected')
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const syncActivedCell = () => {
|
|
85
|
+
const { editStore, tableColumn } = reactData
|
|
86
|
+
const editOpts = computeEditOpts.value
|
|
87
|
+
const { actived } = editStore
|
|
88
|
+
const { row, column } = actived
|
|
89
|
+
if (row && column) {
|
|
90
|
+
if (editOpts.mode === 'row') {
|
|
91
|
+
tableColumn.forEach((column) => setEditColumnModel(row, column))
|
|
92
|
+
} else {
|
|
93
|
+
setEditColumnModel(row, column)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const insertTreeRow = (newRecords: any[], isAppend: boolean) => {
|
|
99
|
+
const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
100
|
+
const treeOpts = computeTreeOpts.value
|
|
101
|
+
const { rowField, parentField, mapChildrenField } = treeOpts
|
|
102
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
103
|
+
const funcName = isAppend ? 'push' : 'unshift'
|
|
104
|
+
newRecords.forEach((item) => {
|
|
105
|
+
const parentRowId = item[parentField]
|
|
106
|
+
const rowid = getRowid($xeTable, item)
|
|
107
|
+
const matchObj = parentRowId ? XEUtils.findTree(tableFullTreeData, (item) => parentRowId === item[rowField], { children: mapChildrenField }) : null
|
|
108
|
+
if (matchObj) {
|
|
109
|
+
const { item: parentRow } = matchObj
|
|
110
|
+
const parentRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)]
|
|
111
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
112
|
+
let pChilds = parentRow[childrenField]
|
|
113
|
+
let pMapChilds = parentRow[mapChildrenField]
|
|
114
|
+
if (!XEUtils.isArray(pChilds)) {
|
|
115
|
+
pChilds = parentRow[childrenField] = []
|
|
116
|
+
}
|
|
117
|
+
if (!XEUtils.isArray(pMapChilds)) {
|
|
118
|
+
pMapChilds = parentRow[mapChildrenField] = []
|
|
119
|
+
}
|
|
120
|
+
pChilds[funcName](item)
|
|
121
|
+
pMapChilds[funcName](item)
|
|
122
|
+
const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: pChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
123
|
+
fullDataRowIdData[rowid] = rest
|
|
124
|
+
fullAllDataRowIdData[rowid] = rest
|
|
125
|
+
} else {
|
|
126
|
+
if (parentRowId) {
|
|
127
|
+
warnLog('vxe.error.unableInsert')
|
|
128
|
+
}
|
|
129
|
+
afterFullData[funcName](item)
|
|
130
|
+
tableFullTreeData[funcName](item)
|
|
131
|
+
const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
132
|
+
fullDataRowIdData[rowid] = rest
|
|
133
|
+
fullAllDataRowIdData[rowid] = rest
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// const insertGroupRow = (newRecords: any[], isAppend: boolean) => {
|
|
139
|
+
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
const handleInsertRowAt = (records: any, targetRowOrRowid: any, isInsertNextRow?: boolean) => {
|
|
143
|
+
const { treeConfig } = props
|
|
144
|
+
const { isRowGroupStatus } = reactData
|
|
145
|
+
const { tableFullTreeData, afterFullData, mergeBodyList, tableFullData, fullDataRowIdData, fullAllDataRowIdData, insertRowMaps, removeRowMaps } = internalData
|
|
146
|
+
const treeOpts = computeTreeOpts.value
|
|
147
|
+
const { transform, parentField, rowField, mapChildrenField } = treeOpts
|
|
148
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
149
|
+
if (!XEUtils.isArray(records)) {
|
|
150
|
+
records = [records]
|
|
151
|
+
}
|
|
152
|
+
let targetRow = targetRowOrRowid
|
|
153
|
+
if (XEUtils.isString(targetRowOrRowid) || XEUtils.isNumber(targetRowOrRowid)) {
|
|
154
|
+
const rowRest = fullAllDataRowIdData[targetRowOrRowid]
|
|
155
|
+
if (rowRest) {
|
|
156
|
+
targetRow = rowRest.row
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!records.length) {
|
|
160
|
+
return Promise.resolve({ row: null, rows: [] })
|
|
161
|
+
}
|
|
162
|
+
$xeTable.handlePushStack()
|
|
163
|
+
const newRecords: any[] = reactive($xeTable.defineField(records.map((record: any) => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record))))
|
|
164
|
+
let treeRecords: any[] = []
|
|
165
|
+
if (treeConfig && transform) {
|
|
166
|
+
treeRecords = XEUtils.toArrayTree(newRecords, { key: rowField, parentKey: parentField, children: childrenField })
|
|
167
|
+
}
|
|
168
|
+
if (XEUtils.eqNull(targetRow)) {
|
|
169
|
+
// 如果为虚拟树
|
|
170
|
+
if (treeConfig && transform) {
|
|
171
|
+
insertTreeRow(newRecords, false)
|
|
172
|
+
} else if (isRowGroupStatus) {
|
|
173
|
+
// 如果分组
|
|
174
|
+
if (treeConfig) {
|
|
175
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']))
|
|
176
|
+
}
|
|
177
|
+
errLog(getI18n('vxe.error.noGroup', ['insert']))
|
|
178
|
+
// insertGroupRow(newRecords, false)
|
|
179
|
+
} else {
|
|
180
|
+
newRecords.forEach((item) => {
|
|
181
|
+
const rowid = getRowid($xeTable, item)
|
|
182
|
+
const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
183
|
+
fullDataRowIdData[rowid] = rest
|
|
184
|
+
fullAllDataRowIdData[rowid] = rest
|
|
185
|
+
afterFullData.unshift(item)
|
|
186
|
+
tableFullData.unshift(item)
|
|
187
|
+
})
|
|
188
|
+
// 刷新单元格合并
|
|
189
|
+
mergeBodyList.forEach((mergeItem: any) => {
|
|
190
|
+
const { row: mergeRowIndex } = mergeItem
|
|
191
|
+
if (mergeRowIndex >= 0) {
|
|
192
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
if (targetRow === -1) {
|
|
198
|
+
// 如果为虚拟树
|
|
199
|
+
if (treeConfig && transform) {
|
|
200
|
+
insertTreeRow(newRecords, true)
|
|
201
|
+
} else if (isRowGroupStatus) {
|
|
202
|
+
// 如果分组
|
|
203
|
+
if (treeConfig) {
|
|
204
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']))
|
|
205
|
+
}
|
|
206
|
+
errLog(getI18n('vxe.error.noGroup', ['insert']))
|
|
207
|
+
// insertGroupRow(newRecords, true)
|
|
208
|
+
} else {
|
|
209
|
+
newRecords.forEach((item) => {
|
|
210
|
+
const rowid = getRowid($xeTable, item)
|
|
211
|
+
const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, treeIndex: -1, _tIndex: -1, $index: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
212
|
+
fullDataRowIdData[rowid] = rest
|
|
213
|
+
fullAllDataRowIdData[rowid] = rest
|
|
214
|
+
afterFullData.push(item)
|
|
215
|
+
tableFullData.push(item)
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
// 如果为虚拟树
|
|
220
|
+
if (treeConfig && transform) {
|
|
221
|
+
const matchMapObj = XEUtils.findTree(tableFullTreeData, (item) => targetRow[rowField] === item[rowField], { children: mapChildrenField })
|
|
222
|
+
if (matchMapObj) {
|
|
223
|
+
const { parent: parentRow } = matchMapObj
|
|
224
|
+
const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData
|
|
225
|
+
const parentRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)]
|
|
226
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
227
|
+
treeRecords.forEach((row, i) => {
|
|
228
|
+
if (parentRow) {
|
|
229
|
+
if (row[parentField] !== parentRow[rowField]) {
|
|
230
|
+
errLog('vxe.error.errProp', [`${parentField}=${row[parentField]}`, `${parentField}=${parentRow[rowField]}`])
|
|
231
|
+
row[parentField] = parentRow[rowField]
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
if (row[parentField] !== null) {
|
|
235
|
+
if (!XEUtils.eqNull(row[parentField])) {
|
|
236
|
+
errLog('vxe.error.errProp', [`${parentField}=${row[parentField]}`, 'null'])
|
|
237
|
+
}
|
|
238
|
+
row[parentField] = null
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
let targetIndex = matchMapObj.index + i
|
|
242
|
+
if (isInsertNextRow) {
|
|
243
|
+
targetIndex = targetIndex + 1
|
|
244
|
+
}
|
|
245
|
+
parentMapChilds.splice(targetIndex, 0, row)
|
|
246
|
+
})
|
|
247
|
+
XEUtils.eachTree(
|
|
248
|
+
treeRecords,
|
|
249
|
+
(item) => {
|
|
250
|
+
const rowid = getRowid($xeTable, item)
|
|
251
|
+
const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
252
|
+
if (item[childrenField]) {
|
|
253
|
+
item[mapChildrenField] = item[childrenField]
|
|
254
|
+
}
|
|
255
|
+
fullDataRowIdData[rowid] = rest
|
|
256
|
+
fullAllDataRowIdData[rowid] = rest
|
|
257
|
+
},
|
|
258
|
+
{ children: childrenField }
|
|
259
|
+
)
|
|
260
|
+
// 源
|
|
261
|
+
if (parentRow) {
|
|
262
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, (item) => targetRow[rowField] === item[rowField], { children: childrenField })
|
|
263
|
+
if (matchObj) {
|
|
264
|
+
const parentChilds = matchObj.items
|
|
265
|
+
let targetIndex = matchObj.index
|
|
266
|
+
if (isInsertNextRow) {
|
|
267
|
+
targetIndex = targetIndex + 1
|
|
268
|
+
}
|
|
269
|
+
parentChilds.splice(targetIndex, 0, ...treeRecords)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
warnLog('vxe.error.unableInsert')
|
|
274
|
+
insertTreeRow(newRecords, true)
|
|
275
|
+
}
|
|
276
|
+
} else if (isRowGroupStatus) {
|
|
277
|
+
// 如果分组
|
|
278
|
+
if (treeConfig) {
|
|
279
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']))
|
|
280
|
+
}
|
|
281
|
+
errLog(getI18n('vxe.error.noGroup', ['insert']))
|
|
282
|
+
} else {
|
|
283
|
+
if (treeConfig) {
|
|
284
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']))
|
|
285
|
+
}
|
|
286
|
+
let afIndex = -1
|
|
287
|
+
// 如果是可视索引
|
|
288
|
+
if (XEUtils.isNumber(targetRow)) {
|
|
289
|
+
if (targetRow < afterFullData.length) {
|
|
290
|
+
afIndex = targetRow
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
afIndex = $xeTable.findRowIndexOf(afterFullData, targetRow)
|
|
294
|
+
}
|
|
295
|
+
// 如果是插入指定行的下一行
|
|
296
|
+
if (isInsertNextRow) {
|
|
297
|
+
afIndex = Math.min(afterFullData.length, afIndex + 1)
|
|
298
|
+
}
|
|
299
|
+
if (afIndex === -1) {
|
|
300
|
+
throw new Error(getI18n('vxe.error.unableInsert'))
|
|
301
|
+
}
|
|
302
|
+
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
303
|
+
const tfIndex = $xeTable.findRowIndexOf(tableFullData, targetRow)
|
|
304
|
+
if (tfIndex > -1) {
|
|
305
|
+
tableFullData.splice(tfIndex + (isInsertNextRow ? 1 : 0), 0, ...newRecords)
|
|
306
|
+
} else {
|
|
307
|
+
tableFullData.push(...newRecords)
|
|
308
|
+
}
|
|
309
|
+
// 刷新单元格合并
|
|
310
|
+
mergeBodyList.forEach((mergeItem: any) => {
|
|
311
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
312
|
+
if (mergeRowIndex >= afIndex) {
|
|
313
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
314
|
+
} else if (isInsertNextRow ? mergeRowIndex + mergeRowspan >= afIndex : mergeRowIndex + mergeRowspan > afIndex) {
|
|
315
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
316
|
+
}
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const handleStatus = (newRow: any) => {
|
|
323
|
+
const rowid = getRowid($xeTable, newRow)
|
|
324
|
+
// 如果是被删除的数据,则还原状态
|
|
325
|
+
if (removeRowMaps[rowid]) {
|
|
326
|
+
delete removeRowMaps[rowid]
|
|
327
|
+
if (insertRowMaps[rowid]) {
|
|
328
|
+
delete insertRowMaps[rowid]
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
insertRowMaps[rowid] = newRow
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// 如果为虚拟树
|
|
335
|
+
if (treeConfig && transform) {
|
|
336
|
+
XEUtils.eachTree(treeRecords, handleStatus, { children: mapChildrenField })
|
|
337
|
+
} else {
|
|
338
|
+
newRecords.forEach(handleStatus)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
reactData.removeRowFlag++
|
|
342
|
+
reactData.insertRowFlag++
|
|
343
|
+
$xeTable.cacheRowMap(false, false)
|
|
344
|
+
$xeTable.updateScrollYStatus()
|
|
345
|
+
$xeTable.handleTableData(treeConfig && transform)
|
|
346
|
+
if (!(treeConfig && transform)) {
|
|
347
|
+
$xeTable.updateAfterDataIndex()
|
|
348
|
+
}
|
|
349
|
+
$xeTable.updateFooter()
|
|
350
|
+
$xeTable.handleUpdateBodyMerge()
|
|
351
|
+
$xeTable.checkSelectionStatus()
|
|
352
|
+
if (reactData.scrollYLoad) {
|
|
353
|
+
$xeTable.updateScrollYSpace()
|
|
354
|
+
}
|
|
355
|
+
return nextTick()
|
|
356
|
+
.then(() => {
|
|
357
|
+
$xeTable.updateCellAreas()
|
|
358
|
+
return $xeTable.recalculate(true)
|
|
359
|
+
})
|
|
360
|
+
.then(() => {
|
|
361
|
+
return {
|
|
362
|
+
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
363
|
+
rows: newRecords
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const handleInsertChildRowAt = (records: any, parentRowOrParentId: any, targetRow: any, isInsertNextRow?: boolean) => {
|
|
369
|
+
const { treeConfig } = props
|
|
370
|
+
const { fullAllDataRowIdData } = internalData
|
|
371
|
+
const treeOpts = computeTreeOpts.value
|
|
372
|
+
const { transform, rowField, parentField } = treeOpts
|
|
373
|
+
if (treeConfig && transform) {
|
|
374
|
+
if (!XEUtils.isArray(records)) {
|
|
375
|
+
records = [records]
|
|
376
|
+
}
|
|
377
|
+
let parentRow = parentRowOrParentId
|
|
378
|
+
if (XEUtils.isString(parentRowOrParentId) || XEUtils.isNumber(parentRowOrParentId)) {
|
|
379
|
+
const rowRest = fullAllDataRowIdData[parentRowOrParentId]
|
|
380
|
+
if (rowRest) {
|
|
381
|
+
parentRow = rowRest.row
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return handleInsertRowAt(
|
|
385
|
+
records.map((item: any) => Object.assign({}, item, { [parentField]: parentRow[rowField] })),
|
|
386
|
+
targetRow,
|
|
387
|
+
isInsertNextRow
|
|
388
|
+
)
|
|
389
|
+
} else {
|
|
390
|
+
errLog('vxe.error.errProp', ['tree-config.transform=false', 'tree-config.transform=true'])
|
|
391
|
+
}
|
|
392
|
+
return Promise.resolve({ row: null, rows: [] })
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const handleClearEdit = (evnt: Event | null, targetRow?: any) => {
|
|
396
|
+
const { editStore } = reactData
|
|
397
|
+
const { actived, focused } = editStore
|
|
398
|
+
const { row, column } = actived
|
|
399
|
+
const validOpts = computeValidOpts.value
|
|
400
|
+
if (row || column) {
|
|
401
|
+
if (targetRow && getRowid($xeTable, targetRow) !== getRowid($xeTable, row)) {
|
|
402
|
+
return nextTick()
|
|
403
|
+
}
|
|
404
|
+
syncActivedCell()
|
|
405
|
+
$xeTable.updateFooter()
|
|
406
|
+
actived.args = null
|
|
407
|
+
actived.row = null
|
|
408
|
+
actived.column = null
|
|
409
|
+
$xeTable.dispatchEvent(
|
|
410
|
+
'edit-closed',
|
|
411
|
+
{
|
|
412
|
+
row,
|
|
413
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
414
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
415
|
+
column,
|
|
416
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
417
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
418
|
+
},
|
|
419
|
+
evnt || null
|
|
420
|
+
)
|
|
421
|
+
}
|
|
422
|
+
focused.row = null
|
|
423
|
+
focused.column = null
|
|
424
|
+
if (validOpts.autoClear) {
|
|
425
|
+
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
|
|
426
|
+
if ($xeTable.clearValidate) {
|
|
427
|
+
return $xeTable.clearValidate()
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return nextTick().then(() => $xeTable.updateCellAreas())
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const handleEditActive = (
|
|
435
|
+
params: {
|
|
436
|
+
$table: VxeTableConstructor
|
|
437
|
+
column: VxeTableDefines.ColumnInfo
|
|
438
|
+
columnIndex: number
|
|
439
|
+
_columnIndex: number
|
|
440
|
+
$columnIndex: number
|
|
441
|
+
rowIndex: number
|
|
442
|
+
$rowIndex: number
|
|
443
|
+
_rowIndex: number
|
|
444
|
+
row: any
|
|
445
|
+
cell?: HTMLElement
|
|
446
|
+
},
|
|
447
|
+
evnt: Event | null,
|
|
448
|
+
options: {
|
|
449
|
+
isClear?: boolean
|
|
450
|
+
isFocus?: boolean
|
|
451
|
+
isPos?: boolean
|
|
452
|
+
}
|
|
453
|
+
) => {
|
|
454
|
+
const $xeGrid = $xeTable.xeGrid
|
|
455
|
+
const $xeGantt = $xeTable.xeGantt
|
|
456
|
+
|
|
457
|
+
const { editConfig, mouseConfig } = props
|
|
458
|
+
const { editStore, tableColumn } = reactData
|
|
459
|
+
const editOpts = computeEditOpts.value
|
|
460
|
+
const mouseOpts = computeMouseOpts.value
|
|
461
|
+
const { mode } = editOpts
|
|
462
|
+
const { actived, focused } = editStore
|
|
463
|
+
const { row, column } = params
|
|
464
|
+
const { editRender } = column
|
|
465
|
+
const { isFocus, isPos, isClear } = options
|
|
466
|
+
const cell = (params.cell || $xeTable.getCellElement(row, column)) as HTMLElement
|
|
467
|
+
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod
|
|
468
|
+
const editParams = { ...params, cell }
|
|
469
|
+
if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
|
|
470
|
+
// 激活编辑
|
|
471
|
+
if (!$xeTable.isPendingByRow(row) && !$xeTable.isAggregateRecord(row)) {
|
|
472
|
+
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
473
|
+
// 判断是否禁用编辑
|
|
474
|
+
let type: 'edit-disabled' | 'edit-activated' = 'edit-disabled'
|
|
475
|
+
if (!beforeEditMethod || beforeEditMethod({ ...editParams, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt })) {
|
|
476
|
+
if (hasEnableConf(mouseConfig, mouseOpts)) {
|
|
477
|
+
$xeTable.clearSelected()
|
|
478
|
+
if ($xeTable.clearCellAreas) {
|
|
479
|
+
$xeTable.clearCellAreas()
|
|
480
|
+
$xeTable.clearCopyCellArea()
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
$xeTable.closeTooltip()
|
|
484
|
+
if (actived.column) {
|
|
485
|
+
handleClearEdit(evnt)
|
|
486
|
+
}
|
|
487
|
+
type = 'edit-activated'
|
|
488
|
+
column.renderHeight = cell.offsetHeight
|
|
489
|
+
actived.args = editParams
|
|
490
|
+
actived.row = row
|
|
491
|
+
actived.column = column
|
|
492
|
+
$xeTable.handlePushStack()
|
|
493
|
+
if (isClear) {
|
|
494
|
+
setCellValue(row, column, null)
|
|
495
|
+
}
|
|
496
|
+
if (mode === 'row') {
|
|
497
|
+
tableColumn.forEach((column: any) => getEditColumnModel(row, column))
|
|
498
|
+
} else {
|
|
499
|
+
getEditColumnModel(row, column)
|
|
500
|
+
}
|
|
501
|
+
const afterEditMethod = editOpts.afterEditMethod
|
|
502
|
+
nextTick(() => {
|
|
503
|
+
if (isFocus) {
|
|
504
|
+
$xeTable.handleFocus(editParams, evnt)
|
|
505
|
+
}
|
|
506
|
+
if (afterEditMethod) {
|
|
507
|
+
afterEditMethod({ ...editParams, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt })
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
}
|
|
511
|
+
$xeTable.dispatchEvent(
|
|
512
|
+
type,
|
|
513
|
+
{
|
|
514
|
+
row,
|
|
515
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
516
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
517
|
+
column,
|
|
518
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
519
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
520
|
+
},
|
|
521
|
+
evnt
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
// v4已废弃
|
|
525
|
+
if (type === 'edit-activated') {
|
|
526
|
+
$xeTable.dispatchEvent(
|
|
527
|
+
'edit-actived',
|
|
528
|
+
{
|
|
529
|
+
row,
|
|
530
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
531
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
532
|
+
column,
|
|
533
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
534
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
535
|
+
},
|
|
536
|
+
evnt
|
|
537
|
+
)
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
const { column: oldColumn } = actived
|
|
541
|
+
if (hasEnableConf(mouseConfig, mouseOpts)) {
|
|
542
|
+
$xeTable.clearSelected()
|
|
543
|
+
if ($xeTable.clearCellAreas) {
|
|
544
|
+
$xeTable.clearCellAreas()
|
|
545
|
+
$xeTable.clearCopyCellArea()
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (oldColumn && oldColumn !== column) {
|
|
549
|
+
const { model: oldModel } = oldColumn
|
|
550
|
+
if (oldModel.update) {
|
|
551
|
+
setCellValue(row, oldColumn, oldModel.value)
|
|
552
|
+
}
|
|
553
|
+
if ($xeTable.clearValidate) {
|
|
554
|
+
$xeTable.clearValidate(row, column)
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
column.renderHeight = cell.offsetHeight
|
|
558
|
+
actived.args = editParams
|
|
559
|
+
actived.column = column
|
|
560
|
+
if (isPos) {
|
|
561
|
+
setTimeout(() => {
|
|
562
|
+
$xeTable.handleFocus(editParams, evnt)
|
|
563
|
+
})
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
focused.column = null
|
|
567
|
+
focused.row = null
|
|
568
|
+
$xeTable.focus()
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return nextTick()
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const handleEditCell = (
|
|
575
|
+
row: any,
|
|
576
|
+
fieldOrColumn: string | VxeTableDefines.ColumnInfo | null,
|
|
577
|
+
options: {
|
|
578
|
+
isClear?: boolean | undefined
|
|
579
|
+
isFocus?: boolean | undefined
|
|
580
|
+
isPos?: boolean | undefined
|
|
581
|
+
}
|
|
582
|
+
) => {
|
|
583
|
+
const { editConfig } = props
|
|
584
|
+
const { isPos } = options
|
|
585
|
+
const column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn
|
|
586
|
+
if (row && column && isEnableConf(editConfig) && isEnableConf(column.editRender) && !$xeTable.isAggregateRecord(row)) {
|
|
587
|
+
return Promise.resolve(isPos ? $xeTable.scrollToRow(row, column) : null).then(() => {
|
|
588
|
+
const cell = $xeTable.getCellElement(row, column)
|
|
589
|
+
if (cell) {
|
|
590
|
+
handleEditActive(
|
|
591
|
+
{
|
|
592
|
+
row,
|
|
593
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
594
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
595
|
+
_rowIndex: $xeTable.getVTRowIndex(row),
|
|
596
|
+
column,
|
|
597
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
598
|
+
$columnIndex: $xeTable.getVMColumnIndex(column),
|
|
599
|
+
_columnIndex: $xeTable.getVTColumnIndex(column),
|
|
600
|
+
cell,
|
|
601
|
+
$table: $xeTable
|
|
602
|
+
},
|
|
603
|
+
null,
|
|
604
|
+
{
|
|
605
|
+
isFocus: isPos,
|
|
606
|
+
isPos
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
internalData._lastCallTime = Date.now()
|
|
610
|
+
}
|
|
611
|
+
return nextTick()
|
|
612
|
+
})
|
|
613
|
+
}
|
|
614
|
+
return nextTick()
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
editMethods = {
|
|
618
|
+
/**
|
|
619
|
+
* 往表格中插入临时数据
|
|
620
|
+
*
|
|
621
|
+
* @param {*} records
|
|
622
|
+
*/
|
|
623
|
+
insert(records) {
|
|
624
|
+
return handleInsertRowAt(records, null)
|
|
625
|
+
},
|
|
626
|
+
/**
|
|
627
|
+
* 往表格指定行中插入临时数据
|
|
628
|
+
* 如果 row 为空则从插入到顶部,如果为树结构,则插入到目标节点顶部
|
|
629
|
+
* 如果 row 为 -1 则从插入到底部,如果为树结构,则插入到目标节点底部
|
|
630
|
+
* 如果 row 为有效行则插入到该行的位置,如果为树结构,则有插入到效的目标节点该行的位置
|
|
631
|
+
*/
|
|
632
|
+
insertAt(records, targetRowOrRowid) {
|
|
633
|
+
return handleInsertRowAt(records, targetRowOrRowid)
|
|
634
|
+
},
|
|
635
|
+
insertNextAt(records, targetRowOrRowid) {
|
|
636
|
+
return handleInsertRowAt(records, targetRowOrRowid, true)
|
|
637
|
+
},
|
|
638
|
+
insertChild(records, parentRowOrParentId) {
|
|
639
|
+
return handleInsertChildRowAt(records, parentRowOrParentId, null)
|
|
640
|
+
},
|
|
641
|
+
insertChildAt(records, parentRowOrParentId, targetRow) {
|
|
642
|
+
return handleInsertChildRowAt(records, parentRowOrParentId, targetRow)
|
|
643
|
+
},
|
|
644
|
+
insertChildNextAt(records, parentRowOrParentId, targetRow) {
|
|
645
|
+
return handleInsertChildRowAt(records, parentRowOrParentId, targetRow, true)
|
|
646
|
+
},
|
|
647
|
+
/**
|
|
648
|
+
* 删除指定行数据
|
|
649
|
+
* 如果传 row 则删除一行
|
|
650
|
+
* 如果传 rows 则删除多行
|
|
651
|
+
* 如果为空则删除所有
|
|
652
|
+
*/
|
|
653
|
+
remove(rows: any) {
|
|
654
|
+
const { treeConfig } = props
|
|
655
|
+
const { editStore, isRowGroupStatus } = reactData
|
|
656
|
+
const { tableFullTreeData, selectCheckboxMaps, afterFullData, mergeBodyList, tableFullData, pendingRowMaps, insertRowMaps, removeRowMaps } = internalData
|
|
657
|
+
const checkboxOpts = computeCheckboxOpts.value
|
|
658
|
+
const treeOpts = computeTreeOpts.value
|
|
659
|
+
const { transform, mapChildrenField } = treeOpts
|
|
660
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
661
|
+
const { actived } = editStore
|
|
662
|
+
const { checkField } = checkboxOpts
|
|
663
|
+
let delList: any[] = []
|
|
664
|
+
if (!rows) {
|
|
665
|
+
rows = tableFullData
|
|
666
|
+
} else if (!XEUtils.isArray(rows)) {
|
|
667
|
+
rows = [rows]
|
|
668
|
+
}
|
|
669
|
+
if (!rows.length) {
|
|
670
|
+
return Promise.resolve({ row: null, rows: [] })
|
|
671
|
+
}
|
|
672
|
+
$xeTable.handlePushStack()
|
|
673
|
+
// 如果是新增,则保存记录
|
|
674
|
+
rows.forEach((row: any) => {
|
|
675
|
+
if (!$xeTable.isInsertByRow(row)) {
|
|
676
|
+
const rowid = getRowid($xeTable, row)
|
|
677
|
+
removeRowMaps[rowid] = row
|
|
678
|
+
}
|
|
679
|
+
})
|
|
680
|
+
// 如果绑定了多选属性,则更新状态
|
|
681
|
+
if (!checkField) {
|
|
682
|
+
rows.forEach((row: any) => {
|
|
683
|
+
const rowid = getRowid($xeTable, row)
|
|
684
|
+
if (selectCheckboxMaps[rowid]) {
|
|
685
|
+
delete selectCheckboxMaps[rowid]
|
|
686
|
+
}
|
|
687
|
+
})
|
|
688
|
+
reactData.updateCheckboxFlag++
|
|
689
|
+
}
|
|
690
|
+
// 从数据源中移除
|
|
691
|
+
if (tableFullData === rows) {
|
|
692
|
+
rows = delList = tableFullData.slice(0)
|
|
693
|
+
internalData.tableFullData = []
|
|
694
|
+
internalData.afterFullData = []
|
|
695
|
+
$xeTable.clearMergeCells()
|
|
696
|
+
} else {
|
|
697
|
+
// 如果为虚拟树
|
|
698
|
+
if (treeConfig && transform) {
|
|
699
|
+
rows.forEach((row: any) => {
|
|
700
|
+
const rowid = getRowid($xeTable, row)
|
|
701
|
+
const matchMapObj = XEUtils.findTree(tableFullTreeData, (item) => rowid === getRowid($xeTable, item), { children: mapChildrenField })
|
|
702
|
+
if (matchMapObj) {
|
|
703
|
+
const rItems = matchMapObj.items.splice(matchMapObj.index, 1)
|
|
704
|
+
delList.push(rItems[0])
|
|
705
|
+
}
|
|
706
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, (item) => rowid === getRowid($xeTable, item), { children: childrenField })
|
|
707
|
+
if (matchObj) {
|
|
708
|
+
matchObj.items.splice(matchObj.index, 1)
|
|
709
|
+
}
|
|
710
|
+
const afIndex = $xeTable.findRowIndexOf(afterFullData, row)
|
|
711
|
+
if (afIndex > -1) {
|
|
712
|
+
afterFullData.splice(afIndex, 1)
|
|
713
|
+
}
|
|
714
|
+
})
|
|
715
|
+
} else if (isRowGroupStatus) {
|
|
716
|
+
// 如果分组
|
|
717
|
+
warnLog(getI18n('vxe.error.noGroup', ['remove']))
|
|
718
|
+
} else {
|
|
719
|
+
rows.forEach((row: any) => {
|
|
720
|
+
const tfIndex = $xeTable.findRowIndexOf(tableFullData, row)
|
|
721
|
+
if (tfIndex > -1) {
|
|
722
|
+
const rItems = tableFullData.splice(tfIndex, 1)
|
|
723
|
+
delList.push(rItems[0])
|
|
724
|
+
}
|
|
725
|
+
const afIndex = $xeTable.findRowIndexOf(afterFullData, row)
|
|
726
|
+
if (afIndex > -1) {
|
|
727
|
+
// 刷新单元格合并
|
|
728
|
+
mergeBodyList.forEach((mergeItem) => {
|
|
729
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
730
|
+
if (mergeRowIndex > afIndex) {
|
|
731
|
+
mergeItem.row = mergeRowIndex - 1
|
|
732
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
733
|
+
mergeItem.rowspan = mergeRowspan - 1
|
|
734
|
+
}
|
|
735
|
+
})
|
|
736
|
+
afterFullData.splice(afIndex, 1)
|
|
737
|
+
}
|
|
738
|
+
})
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
// 如果当前行被激活编辑,则清除激活状态
|
|
742
|
+
if (actived.row && $xeTable.findRowIndexOf(rows, actived.row) > -1) {
|
|
743
|
+
editMethods.clearEdit()
|
|
744
|
+
}
|
|
745
|
+
// 从新增中移除已删除的数据
|
|
746
|
+
rows.forEach((row: any) => {
|
|
747
|
+
const rowid = getRowid($xeTable, row)
|
|
748
|
+
if (insertRowMaps[rowid]) {
|
|
749
|
+
delete insertRowMaps[rowid]
|
|
750
|
+
}
|
|
751
|
+
if (pendingRowMaps[rowid]) {
|
|
752
|
+
delete pendingRowMaps[rowid]
|
|
753
|
+
}
|
|
754
|
+
})
|
|
755
|
+
reactData.removeRowFlag++
|
|
756
|
+
reactData.insertRowFlag++
|
|
757
|
+
reactData.pendingRowFlag++
|
|
758
|
+
$xeTable.cacheRowMap(false, false)
|
|
759
|
+
$xeTable.handleTableData(treeConfig && transform)
|
|
760
|
+
$xeTable.updateFooter()
|
|
761
|
+
$xeTable.handleUpdateBodyMerge()
|
|
762
|
+
if (!(treeConfig && transform)) {
|
|
763
|
+
$xeTable.updateAfterDataIndex()
|
|
764
|
+
}
|
|
765
|
+
$xeTable.checkSelectionStatus()
|
|
766
|
+
if (reactData.scrollYLoad) {
|
|
767
|
+
$xeTable.updateScrollYSpace()
|
|
768
|
+
}
|
|
769
|
+
return nextTick()
|
|
770
|
+
.then(() => {
|
|
771
|
+
$xeTable.updateCellAreas()
|
|
772
|
+
return $xeTable.recalculate(true)
|
|
773
|
+
})
|
|
774
|
+
.then(() => {
|
|
775
|
+
return { row: delList.length ? delList[delList.length - 1] : null, rows: delList }
|
|
776
|
+
})
|
|
777
|
+
},
|
|
778
|
+
/**
|
|
779
|
+
* 删除复选框选中的数据
|
|
780
|
+
*/
|
|
781
|
+
removeCheckboxRow() {
|
|
782
|
+
return editMethods.remove($xeTable.getCheckboxRecords()).then((params: any) => {
|
|
783
|
+
$xeTable.clearCheckboxRow()
|
|
784
|
+
return params
|
|
785
|
+
})
|
|
786
|
+
},
|
|
787
|
+
/**
|
|
788
|
+
* 删除单选框选中的数据
|
|
789
|
+
*/
|
|
790
|
+
removeRadioRow() {
|
|
791
|
+
const radioRecord = $xeTable.getRadioRecord()
|
|
792
|
+
return editMethods.remove(radioRecord || []).then((params: any) => {
|
|
793
|
+
$xeTable.clearRadioRow()
|
|
794
|
+
return params
|
|
795
|
+
})
|
|
796
|
+
},
|
|
797
|
+
/**
|
|
798
|
+
* 删除当前行选中的数据
|
|
799
|
+
*/
|
|
800
|
+
removeCurrentRow() {
|
|
801
|
+
const currentRecord = $xeTable.getCurrentRecord()
|
|
802
|
+
return editMethods.remove(currentRecord || []).then((params: any) => {
|
|
803
|
+
$xeTable.clearCurrentRow()
|
|
804
|
+
return params
|
|
805
|
+
})
|
|
806
|
+
},
|
|
807
|
+
/**
|
|
808
|
+
* 获取表格数据集,包含新增、删除、修改、标记
|
|
809
|
+
*/
|
|
810
|
+
getRecordset() {
|
|
811
|
+
const removeRecords = editMethods.getRemoveRecords()
|
|
812
|
+
const pendingRecords = $xeTable.getPendingRecords()
|
|
813
|
+
const delRecords = removeRecords.concat(pendingRecords)
|
|
814
|
+
// 如果已经被删除,则无需放到更新数组
|
|
815
|
+
const updateRecords = editMethods.getUpdateRecords().filter((row) => {
|
|
816
|
+
return !delRecords.some((item) => $xeTable.eqRow(item, row))
|
|
817
|
+
})
|
|
818
|
+
return {
|
|
819
|
+
insertRecords: editMethods.getInsertRecords(),
|
|
820
|
+
removeRecords,
|
|
821
|
+
updateRecords,
|
|
822
|
+
pendingRecords
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
/**
|
|
826
|
+
* 获取新增的临时数据
|
|
827
|
+
*/
|
|
828
|
+
getInsertRecords() {
|
|
829
|
+
const { fullAllDataRowIdData, insertRowMaps } = internalData
|
|
830
|
+
const insertRecords: any[] = []
|
|
831
|
+
XEUtils.each(insertRowMaps, (row, rowid) => {
|
|
832
|
+
if (fullAllDataRowIdData[rowid]) {
|
|
833
|
+
insertRecords.push(row)
|
|
834
|
+
}
|
|
835
|
+
})
|
|
836
|
+
return insertRecords
|
|
837
|
+
},
|
|
838
|
+
/**
|
|
839
|
+
* 获取已删除的数据
|
|
840
|
+
*/
|
|
841
|
+
getRemoveRecords() {
|
|
842
|
+
const { removeRowMaps } = internalData
|
|
843
|
+
const removeRecords: any[] = []
|
|
844
|
+
XEUtils.each(removeRowMaps, (row) => {
|
|
845
|
+
removeRecords.push(row)
|
|
846
|
+
})
|
|
847
|
+
return removeRecords
|
|
848
|
+
},
|
|
849
|
+
/**
|
|
850
|
+
* 获取更新数据
|
|
851
|
+
* 只精准匹配 row 的更改
|
|
852
|
+
* 如果是树表格,子节点更改状态不会影响父节点的更新状态
|
|
853
|
+
*/
|
|
854
|
+
getUpdateRecords() {
|
|
855
|
+
const { keepSource, treeConfig } = props
|
|
856
|
+
const { tableFullData, tableFullTreeData } = internalData
|
|
857
|
+
const treeOpts = computeTreeOpts.value
|
|
858
|
+
const updateRecords: any[] = []
|
|
859
|
+
if (keepSource) {
|
|
860
|
+
syncActivedCell()
|
|
861
|
+
if (treeConfig) {
|
|
862
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
863
|
+
XEUtils.eachTree(
|
|
864
|
+
tableFullTreeData,
|
|
865
|
+
(row) => {
|
|
866
|
+
if ($xeTable.isUpdateByRow(row)) {
|
|
867
|
+
updateRecords.push(row)
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
{ children: childrenField }
|
|
871
|
+
)
|
|
872
|
+
} else {
|
|
873
|
+
tableFullData.forEach((row) => {
|
|
874
|
+
if ($xeTable.isUpdateByRow(row)) {
|
|
875
|
+
updateRecords.push(row)
|
|
876
|
+
}
|
|
877
|
+
})
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return updateRecords
|
|
881
|
+
},
|
|
882
|
+
getActiveRecord() {
|
|
883
|
+
warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditCell'])
|
|
884
|
+
const { editStore } = reactData
|
|
885
|
+
const { fullAllDataRowIdData } = internalData
|
|
886
|
+
const { args, row } = editStore.actived
|
|
887
|
+
if (args && row && fullAllDataRowIdData[getRowid($xeTable, row)]) {
|
|
888
|
+
return Object.assign({}, args, { row })
|
|
889
|
+
}
|
|
890
|
+
return null
|
|
891
|
+
},
|
|
892
|
+
getEditRecord() {
|
|
893
|
+
warnLog('vxe.error.delFunc', ['getEditRecord', 'getEditCell'])
|
|
894
|
+
const { editStore } = reactData
|
|
895
|
+
const { fullAllDataRowIdData } = internalData
|
|
896
|
+
const { args, row } = editStore.actived
|
|
897
|
+
if (args && row && fullAllDataRowIdData[getRowid($xeTable, row)]) {
|
|
898
|
+
return Object.assign({}, args, { row })
|
|
899
|
+
}
|
|
900
|
+
return null
|
|
901
|
+
},
|
|
902
|
+
getEditCell() {
|
|
903
|
+
const { editStore } = reactData
|
|
904
|
+
const { row, column } = editStore.actived
|
|
905
|
+
if (column && row) {
|
|
906
|
+
return {
|
|
907
|
+
row,
|
|
908
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
909
|
+
column,
|
|
910
|
+
columnIndex: $xeTable.getColumnIndex(column)
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return null
|
|
914
|
+
},
|
|
915
|
+
/**
|
|
916
|
+
* 获取选中的单元格
|
|
917
|
+
*/
|
|
918
|
+
getSelectedCell() {
|
|
919
|
+
const { editStore } = reactData
|
|
920
|
+
const { row, column } = editStore.selected
|
|
921
|
+
if (row && column) {
|
|
922
|
+
return {
|
|
923
|
+
row,
|
|
924
|
+
column
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return null
|
|
928
|
+
},
|
|
929
|
+
clearActived(row) {
|
|
930
|
+
// 即将废弃
|
|
931
|
+
warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit'])
|
|
932
|
+
return $xeTable.clearEdit(row)
|
|
933
|
+
},
|
|
934
|
+
/**
|
|
935
|
+
* 清除激活的编辑
|
|
936
|
+
*/
|
|
937
|
+
clearEdit(row) {
|
|
938
|
+
return handleClearEdit(null, row)
|
|
939
|
+
},
|
|
940
|
+
/**
|
|
941
|
+
* 清除所选中源状态
|
|
942
|
+
*/
|
|
943
|
+
clearSelected() {
|
|
944
|
+
const { editStore } = reactData
|
|
945
|
+
const { selected } = editStore
|
|
946
|
+
selected.row = null
|
|
947
|
+
selected.column = null
|
|
948
|
+
removeCellSelectedClass()
|
|
949
|
+
return nextTick()
|
|
950
|
+
},
|
|
951
|
+
isActiveByRow(row) {
|
|
952
|
+
warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow'])
|
|
953
|
+
// 即将废弃
|
|
954
|
+
return $xeTable.isEditByRow(row)
|
|
955
|
+
},
|
|
956
|
+
/**
|
|
957
|
+
* 判断行是否为激活编辑状态
|
|
958
|
+
* @param {Row} row 行对象
|
|
959
|
+
*/
|
|
960
|
+
isEditByRow(row) {
|
|
961
|
+
const { editStore } = reactData
|
|
962
|
+
return editStore.actived.row === row
|
|
963
|
+
},
|
|
964
|
+
setActiveRow(row) {
|
|
965
|
+
warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow'])
|
|
966
|
+
// 即将废弃
|
|
967
|
+
return editMethods.setEditRow(row)
|
|
968
|
+
},
|
|
969
|
+
/**
|
|
970
|
+
* 激活行编辑
|
|
971
|
+
*/
|
|
972
|
+
setEditRow(row, fieldOrColumn, options) {
|
|
973
|
+
const { visibleColumn } = internalData
|
|
974
|
+
let column: any = XEUtils.find(visibleColumn, (column) => isEnableConf(column.editRender))
|
|
975
|
+
let isPos = false
|
|
976
|
+
if (fieldOrColumn) {
|
|
977
|
+
isPos = true
|
|
978
|
+
if (fieldOrColumn !== true) {
|
|
979
|
+
column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return handleEditCell(
|
|
983
|
+
row,
|
|
984
|
+
column,
|
|
985
|
+
Object.assign(
|
|
986
|
+
{
|
|
987
|
+
isPos,
|
|
988
|
+
isFocus: isPos
|
|
989
|
+
},
|
|
990
|
+
options
|
|
991
|
+
)
|
|
992
|
+
)
|
|
993
|
+
},
|
|
994
|
+
setActiveCell(row, fieldOrColumn) {
|
|
995
|
+
warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell'])
|
|
996
|
+
// 即将废弃
|
|
997
|
+
return editMethods.setEditCell(row, fieldOrColumn)
|
|
998
|
+
},
|
|
999
|
+
/**
|
|
1000
|
+
* 激活单元格编辑
|
|
1001
|
+
*/
|
|
1002
|
+
setEditCell(row, fieldOrColumn, options) {
|
|
1003
|
+
return handleEditCell(
|
|
1004
|
+
row,
|
|
1005
|
+
fieldOrColumn,
|
|
1006
|
+
Object.assign(
|
|
1007
|
+
{
|
|
1008
|
+
isFocus: true,
|
|
1009
|
+
isPos: true
|
|
1010
|
+
},
|
|
1011
|
+
options
|
|
1012
|
+
)
|
|
1013
|
+
)
|
|
1014
|
+
},
|
|
1015
|
+
/**
|
|
1016
|
+
* 只对 trigger=dblclick 有效,选中单元格
|
|
1017
|
+
*/
|
|
1018
|
+
setSelectCell(row, fieldOrColumn) {
|
|
1019
|
+
const { tableData } = reactData
|
|
1020
|
+
const editOpts = computeEditOpts.value
|
|
1021
|
+
const column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn
|
|
1022
|
+
if (row && column && editOpts.trigger !== 'manual') {
|
|
1023
|
+
const rowIndex = $xeTable.findRowIndexOf(tableData, row)
|
|
1024
|
+
if (rowIndex > -1 && column) {
|
|
1025
|
+
const cell = $xeTable.getCellElement(row, column)
|
|
1026
|
+
const params = {
|
|
1027
|
+
$table: $xeTable,
|
|
1028
|
+
row,
|
|
1029
|
+
rowIndex,
|
|
1030
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
1031
|
+
_rowIndex: $xeTable.getVTRowIndex(row),
|
|
1032
|
+
column,
|
|
1033
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
1034
|
+
$columnIndex: $xeTable.getVMColumnIndex(column),
|
|
1035
|
+
_columnIndex: $xeTable.getVTColumnIndex(column),
|
|
1036
|
+
cell
|
|
1037
|
+
}
|
|
1038
|
+
$xeTable.handleSelected(params, null)
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
return nextTick()
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
const handleCellFocus = (
|
|
1046
|
+
cell: HTMLElement,
|
|
1047
|
+
params: {
|
|
1048
|
+
$table: VxeTableConstructor
|
|
1049
|
+
column: VxeTableDefines.ColumnInfo
|
|
1050
|
+
row: any
|
|
1051
|
+
}
|
|
1052
|
+
) => {
|
|
1053
|
+
const { editConfig } = props
|
|
1054
|
+
const { column } = params
|
|
1055
|
+
const { editRender } = column
|
|
1056
|
+
const editOpts = computeEditOpts.value
|
|
1057
|
+
if (editConfig && isEnableConf(editRender)) {
|
|
1058
|
+
const rendererOpts = computeRendererOpts.value
|
|
1059
|
+
const renderName = editRender.name
|
|
1060
|
+
const compRender = renderName ? rendererOpts[renderName] || renderer.get(renderName) : null
|
|
1061
|
+
let autoFocus: boolean | string | ((params: VxeGlobalRendererHandles.TableAutoFocusParams) => HTMLElement | null) | null | undefined = editRender.autofocus || editRender.autoFocus
|
|
1062
|
+
let autoSelect = editRender.autoSelect || editRender.autoselect
|
|
1063
|
+
let inputElem: HTMLElement | null = null
|
|
1064
|
+
// 是否启用聚焦
|
|
1065
|
+
if (editOpts.autoFocus) {
|
|
1066
|
+
if (!autoFocus && compRender) {
|
|
1067
|
+
autoFocus = compRender.tableAutoFocus || compRender.tableAutofocus || compRender.autofocus
|
|
1068
|
+
}
|
|
1069
|
+
if (!autoSelect && compRender) {
|
|
1070
|
+
autoSelect = compRender.tableAutoSelect || compRender.autoselect
|
|
1071
|
+
}
|
|
1072
|
+
// 如果指定了聚焦 class
|
|
1073
|
+
if (XEUtils.isFunction(autoFocus)) {
|
|
1074
|
+
inputElem = autoFocus(params)
|
|
1075
|
+
} else if (autoFocus) {
|
|
1076
|
+
if (autoFocus === true) {
|
|
1077
|
+
// 自动匹配模式,会自动匹配第一个可输入元素
|
|
1078
|
+
inputElem = cell.querySelector('input,textarea')
|
|
1079
|
+
} else {
|
|
1080
|
+
inputElem = cell.querySelector(autoFocus)
|
|
1081
|
+
}
|
|
1082
|
+
if (inputElem) {
|
|
1083
|
+
inputElem.focus()
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return inputElem as HTMLInputElement
|
|
1088
|
+
}
|
|
1089
|
+
return null
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
editPrivateMethods = {
|
|
1093
|
+
/**
|
|
1094
|
+
* 处理激活编辑
|
|
1095
|
+
*/
|
|
1096
|
+
handleEdit(params, evnt, options) {
|
|
1097
|
+
return handleEditActive(
|
|
1098
|
+
params,
|
|
1099
|
+
evnt,
|
|
1100
|
+
Object.assign(
|
|
1101
|
+
{
|
|
1102
|
+
isFocus: true,
|
|
1103
|
+
isPos: true
|
|
1104
|
+
},
|
|
1105
|
+
options
|
|
1106
|
+
)
|
|
1107
|
+
)
|
|
1108
|
+
},
|
|
1109
|
+
/**
|
|
1110
|
+
* @deprecated
|
|
1111
|
+
*/
|
|
1112
|
+
handleActived(params, evnt) {
|
|
1113
|
+
return editPrivateMethods.handleEdit(params, evnt)
|
|
1114
|
+
},
|
|
1115
|
+
/**
|
|
1116
|
+
* 处理取消编辑
|
|
1117
|
+
* @param evnt
|
|
1118
|
+
* @returns
|
|
1119
|
+
*/
|
|
1120
|
+
handleClearEdit,
|
|
1121
|
+
handleCellFocus,
|
|
1122
|
+
/**
|
|
1123
|
+
* 处理聚焦
|
|
1124
|
+
*/
|
|
1125
|
+
handleFocus(params) {
|
|
1126
|
+
const { row, column, cell } = params
|
|
1127
|
+
const { editRender } = column
|
|
1128
|
+
const editOpts = computeEditOpts.value
|
|
1129
|
+
if (isEnableConf(editRender)) {
|
|
1130
|
+
const autoSelect = editRender.autoSelect || editRender.autoselect
|
|
1131
|
+
const inputElem = handleCellFocus(cell, params)
|
|
1132
|
+
if (inputElem) {
|
|
1133
|
+
if (autoSelect) {
|
|
1134
|
+
inputElem.select()
|
|
1135
|
+
} else {
|
|
1136
|
+
// 保持一致行为,光标移到末端
|
|
1137
|
+
if (browseObj.msie) {
|
|
1138
|
+
const textRange = (inputElem as any).createTextRange()
|
|
1139
|
+
textRange.collapse(false)
|
|
1140
|
+
textRange.select()
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
} else {
|
|
1144
|
+
// 是否自动定位
|
|
1145
|
+
if (editOpts.autoPos) {
|
|
1146
|
+
if (!column.fixed) {
|
|
1147
|
+
// 显示到可视区中
|
|
1148
|
+
$xeTable.scrollToRow(row, column)
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1154
|
+
/**
|
|
1155
|
+
* 处理选中源
|
|
1156
|
+
*/
|
|
1157
|
+
handleSelected(params, evnt) {
|
|
1158
|
+
const { mouseConfig, editConfig } = props
|
|
1159
|
+
const { editStore } = reactData
|
|
1160
|
+
const mouseOpts = computeMouseOpts.value
|
|
1161
|
+
const editOpts = computeEditOpts.value
|
|
1162
|
+
const { actived, selected } = editStore
|
|
1163
|
+
const { row, column } = params
|
|
1164
|
+
const isMouseSelected = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.selected
|
|
1165
|
+
const selectMethod = () => {
|
|
1166
|
+
if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
|
|
1167
|
+
if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
|
|
1168
|
+
handleClearEdit(evnt)
|
|
1169
|
+
$xeTable.clearSelected()
|
|
1170
|
+
if ($xeTable.clearCellAreas) {
|
|
1171
|
+
$xeTable.clearCellAreas()
|
|
1172
|
+
$xeTable.clearCopyCellArea()
|
|
1173
|
+
}
|
|
1174
|
+
selected.args = params
|
|
1175
|
+
selected.row = row
|
|
1176
|
+
selected.column = column
|
|
1177
|
+
if (isMouseSelected) {
|
|
1178
|
+
editPrivateMethods.addCellSelectedClass()
|
|
1179
|
+
}
|
|
1180
|
+
$xeTable.focus()
|
|
1181
|
+
// 如果是支持可复用控件
|
|
1182
|
+
if (editConfig && editOpts.isReuseKeep && isEnableConf(editOpts) && isEnableConf(column.editRender)) {
|
|
1183
|
+
setTimeout(() => {
|
|
1184
|
+
const cell = $xeTable.getCellElement(row, column)
|
|
1185
|
+
if (cell) {
|
|
1186
|
+
const hasReusekeep = cell.querySelector('.vxe-reusekeep-control')
|
|
1187
|
+
if (hasReusekeep) {
|
|
1188
|
+
handleCellFocus(cell, params)
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}, 0)
|
|
1192
|
+
}
|
|
1193
|
+
if (evnt) {
|
|
1194
|
+
$xeTable.dispatchEvent('cell-selected', params, evnt)
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
return nextTick()
|
|
1199
|
+
}
|
|
1200
|
+
return selectMethod()
|
|
1201
|
+
},
|
|
1202
|
+
addCellSelectedClass() {
|
|
1203
|
+
const { editStore } = reactData
|
|
1204
|
+
const { selected } = editStore
|
|
1205
|
+
const { row, column } = selected
|
|
1206
|
+
removeCellSelectedClass()
|
|
1207
|
+
if (row && column) {
|
|
1208
|
+
const cell = $xeTable.getCellElement(row, column)
|
|
1209
|
+
if (cell) {
|
|
1210
|
+
addClass(cell, 'col--selected')
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
return { ...editMethods, ...editPrivateMethods }
|
|
1217
|
+
},
|
|
1218
|
+
setupGrid($xeGrid) {
|
|
1219
|
+
return $xeGrid.extendTableMethods(tableEditMethodKeys)
|
|
1220
|
+
},
|
|
1221
|
+
setupGantt($xeGantt) {
|
|
1222
|
+
return $xeGantt.extendTableMethods(tableEditMethodKeys)
|
|
1223
|
+
}
|
|
1224
|
+
})
|