vxe-table 4.1.9 → 4.1.11

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.
@@ -13,7 +13,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
13
13
  setupTable ($xetable) {
14
14
  const { props, reactData, internalData } = $xetable
15
15
  const { refElem } = $xetable.getRefMaps()
16
- const { computeMouseOpts, computeEditOpts, computeCheckboxOpts, computeSYOpts, computeTreeOpts } = $xetable.getComputeMaps()
16
+ const { computeMouseOpts, computeEditOpts, computeCheckboxOpts, computeTreeOpts } = $xetable.getComputeMaps()
17
17
 
18
18
  let editMethods = {} as TableEditMethods
19
19
  let editPrivateMethods = {} as TableEditPrivateMethods
@@ -60,13 +60,13 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
60
60
  }
61
61
 
62
62
  function insertTreeRow (newRecords: any[], isAppend: boolean) {
63
- const { treeFullData, afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
63
+ const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
64
64
  const treeOpts = computeTreeOpts.value
65
65
  const funcName = isAppend ? 'push' : 'unshift'
66
66
  newRecords.forEach(item => {
67
67
  const parentRowId = item[treeOpts.parentField]
68
68
  const rowid = getRowid($xetable, item)
69
- const matchObj = parentRowId ? XEUtils.findTree(treeFullData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
69
+ const matchObj = parentRowId ? XEUtils.findTree(tableFullTreeData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
70
70
  if (matchObj) {
71
71
  const { item: parentRow } = matchObj
72
72
  const parentRest = fullAllDataRowIdData[getRowid($xetable, parentRow)]
@@ -86,13 +86,12 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
86
86
  }
87
87
  }
88
88
  afterFullData[funcName](item)
89
- treeFullData[funcName](item)
90
- const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: treeFullData, parent: null, level: 0 }
89
+ tableFullTreeData[funcName](item)
90
+ const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: tableFullTreeData, parent: null, level: 0 }
91
91
  fullDataRowIdData[rowid] = rest
92
92
  fullAllDataRowIdData[rowid] = rest
93
93
  }
94
94
  })
95
- $xetable.updateVirtualTreeData()
96
95
  }
97
96
 
98
97
  editMethods = {
@@ -114,9 +113,8 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
114
113
  */
115
114
  insertAt (records: any, row: any) {
116
115
  const { treeConfig } = props
117
- const { mergeList, editStore, scrollYLoad } = reactData
118
- const { treeFullData, afterFullData, tableFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
119
- const sYOpts = computeSYOpts.value
116
+ const { mergeList, editStore } = reactData
117
+ const { tableFullTreeData, afterFullData, tableFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
120
118
  const treeOpts = computeTreeOpts.value
121
119
  const { transform } = treeOpts
122
120
  if (!XEUtils.isArray(records)) {
@@ -157,7 +155,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
157
155
  } else {
158
156
  // 如果为虚拟树
159
157
  if (treeConfig && transform) {
160
- const matchObj = XEUtils.findTree(treeFullData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
158
+ const matchObj = XEUtils.findTree(tableFullTreeData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
161
159
  if (matchObj) {
162
160
  const { parent: parentRow } = matchObj
163
161
  const parentChilds = matchObj.items
@@ -180,7 +178,6 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
180
178
  fullDataRowIdData[rowid] = rest
181
179
  fullAllDataRowIdData[rowid] = rest
182
180
  })
183
- $xetable.updateVirtualTreeData()
184
181
  } else {
185
182
  if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
186
183
  warnLog('vxe.error.unableInsert')
@@ -210,13 +207,11 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
210
207
  }
211
208
  }
212
209
  editStore.insertList.unshift(...newRecords)
213
- reactData.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
214
210
  $xetable.updateFooter()
215
211
  $xetable.cacheRowMap()
216
- $xetable.handleTableData(transform)
217
- $xetable.updateAfterDataIndex()
212
+ $xetable.handleTableData(treeConfig && treeOpts.transform)
218
213
  $xetable.checkSelectionStatus()
219
- if (scrollYLoad) {
214
+ if (reactData.scrollYLoad) {
220
215
  $xetable.updateScrollYSpace()
221
216
  }
222
217
  return nextTick().then(() => {
@@ -237,10 +232,9 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
237
232
  */
238
233
  remove (rows: any) {
239
234
  const { treeConfig } = props
240
- const { mergeList, editStore, selection, scrollYLoad } = reactData
241
- const { treeFullData, afterFullData, tableFullData } = internalData
235
+ const { mergeList, editStore, selection } = reactData
236
+ const { tableFullTreeData, afterFullData, tableFullData } = internalData
242
237
  const checkboxOpts = computeCheckboxOpts.value
243
- const sYOpts = computeSYOpts.value
244
238
  const treeOpts = computeTreeOpts.value
245
239
  const { transform } = treeOpts
246
240
  const { actived, removeList, insertList } = editStore
@@ -277,7 +271,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
277
271
  if (treeConfig && transform) {
278
272
  rows.forEach((row: any) => {
279
273
  const rowid = getRowid($xetable, row)
280
- const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid($xetable, item), treeOpts)
274
+ const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid($xetable, item), treeOpts)
281
275
  if (matchObj) {
282
276
  const rItems = matchObj.items.splice(matchObj.index, 1)
283
277
  rest.push(rItems[0])
@@ -286,7 +280,6 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
286
280
  if (afIndex > -1) {
287
281
  afterFullData.splice(afIndex, 1)
288
282
  }
289
- $xetable.updateVirtualTreeData()
290
283
  })
291
284
  } else {
292
285
  rows.forEach((row: any) => {
@@ -322,13 +315,11 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
322
315
  insertList.splice(iIndex, 1)
323
316
  }
324
317
  })
325
- reactData.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
326
318
  $xetable.updateFooter()
327
319
  $xetable.cacheRowMap()
328
- $xetable.handleTableData(transform)
329
- $xetable.updateAfterDataIndex()
320
+ $xetable.handleTableData(treeConfig && treeOpts.transform)
330
321
  $xetable.checkSelectionStatus()
331
- if (scrollYLoad) {
322
+ if (reactData.scrollYLoad) {
332
323
  $xetable.updateScrollYSpace()
333
324
  }
334
325
  return nextTick().then(() => {
@@ -383,7 +374,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
383
374
  getInsertRecords () {
384
375
  const { treeConfig } = props
385
376
  const { editStore } = reactData
386
- const { treeFullData, tableFullData } = internalData
377
+ const { tableFullTreeData, tableFullData } = internalData
387
378
  const treeOpts = computeTreeOpts.value
388
379
  const insertList = editStore.insertList
389
380
  const insertRecords: any[] = []
@@ -392,7 +383,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
392
383
  if (treeConfig && treeOpts.transform) {
393
384
  insertList.forEach(row => {
394
385
  const rowid = getRowid($xetable, row)
395
- const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid($xetable, item), treeOpts)
386
+ const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid($xetable, item), treeOpts)
396
387
  if (matchObj) {
397
388
  insertRecords.push(row)
398
389
  }
@@ -2,7 +2,7 @@ import { inject, nextTick } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import GlobalConfig from '../../v-x-e-table/src/conf'
4
4
  import { VXETable } from '../../v-x-e-table'
5
- import { isColumnInfo, mergeBodyMethod, getCellValue, toTreePathSeq } from '../../table/src/util'
5
+ import { isColumnInfo, mergeBodyMethod, getCellValue } from '../../table/src/util'
6
6
  import { errLog, warnLog, parseFile, formatText } from '../../tools/utils'
7
7
  import { readLocalFile, handlePrint, saveLocalFile, createHtmlPage, getExportBlobByContent } from './util'
8
8
 
@@ -295,16 +295,13 @@ const tableExportHook: VxeGlobalHooksHandles.HookOptions = {
295
295
  return row[treeOpts.children] && row[treeOpts.children].length
296
296
  }
297
297
 
298
- const getSeq = (row: any, rowIndex: any, column: any, columnIndex: any, path: string[] | null) => {
298
+ const getSeq = (row: any, rowIndex: any, column: any, columnIndex: any) => {
299
299
  const seqOpts = computeSeqOpts.value
300
300
  const seqMethod = seqOpts.seqMethod || column.seqMethod
301
301
  if (seqMethod) {
302
302
  return seqMethod({ row, rowIndex, column, columnIndex })
303
303
  }
304
- if (path) {
305
- return toTreePathSeq(path)
306
- }
307
- return seqOpts.startIndex + rowIndex + 1
304
+ return $xetable.getRowSeq(row)
308
305
  }
309
306
 
310
307
  const toBooleanValue = (cellValue: any) => {
@@ -350,7 +347,7 @@ const tableExportHook: VxeGlobalHooksHandles.HookOptions = {
350
347
  } else {
351
348
  switch (column.type) {
352
349
  case 'seq':
353
- cellValue = getSeq(row, rowIndex, column, columnIndex, path)
350
+ cellValue = getSeq(row, rowIndex, column, columnIndex)
354
351
  break
355
352
  case 'checkbox':
356
353
  cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
@@ -406,7 +403,7 @@ const tableExportHook: VxeGlobalHooksHandles.HookOptions = {
406
403
  } else {
407
404
  switch (column.type) {
408
405
  case 'seq':
409
- cellValue = getSeq(row, rowIndex, column, columnIndex, [])
406
+ cellValue = getSeq(row, rowIndex, column, columnIndex)
410
407
  break
411
408
  case 'checkbox':
412
409
  cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
@@ -84,7 +84,7 @@ const tableFilterHook: VxeGlobalHooksHandles.HookOptions = {
84
84
  // 判断面板不能大于表格高度
85
85
  let maxHeight = null
86
86
  if (filterHeight >= bodyElem.clientHeight) {
87
- maxHeight = Math.max(40, bodyElem.clientHeight - (filterFootElem ? filterFootElem.offsetHeight : 0) - (filterHeadElem ? filterHeadElem.offsetHeight : 0))
87
+ maxHeight = Math.max(60, bodyElem.clientHeight - (filterFootElem ? filterFootElem.offsetHeight : 0) - (filterHeadElem ? filterHeadElem.offsetHeight : 0))
88
88
  }
89
89
  if (column.fixed === 'left') {
90
90
  left = targetElem.offsetLeft + targetElem.offsetParent.offsetLeft - centerWidth
@@ -176,7 +176,7 @@ export default defineComponent({
176
176
  })
177
177
 
178
178
  const getOptkey = () => {
179
- return props.optionId || '_XID'
179
+ return props.optionId || '_X_ID'
180
180
  }
181
181
 
182
182
  const getOptid = (option: any) => {
@@ -300,6 +300,7 @@ export default defineComponent({
300
300
  const treeOpts = computeTreeOpts.value
301
301
  const editOpts = computeEditOpts.value
302
302
  const rowOpts = computeRowOpts.value
303
+ const { transform } = treeOpts
303
304
  const rows: any[] = []
304
305
  tableData.forEach((row: any, $rowIndex: any) => {
305
306
  const trOn: any = {}
@@ -324,9 +325,14 @@ export default defineComponent({
324
325
  }
325
326
  const rowid = getRowid($xetable, row)
326
327
  const rest = fullDataRowIdData[rowid]
327
- const rowLevel = rest ? rest.level : 0
328
- const seq = rest ? rest.seq : -1
328
+ let rowLevel = 0
329
+ let seq: string | number = -1
330
+ if (rest) {
331
+ rowLevel = rest.level
332
+ seq = rest.seq
333
+ }
329
334
  const params = { $table: $xetable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
335
+ // 处理新增状态
330
336
  let isNewRow = false
331
337
  if (editConfig) {
332
338
  isNewRow = $xetable.findRowIndexOf(editStore.insertList, row) > -1
@@ -384,7 +390,7 @@ export default defineComponent({
384
390
  )
385
391
  }
386
392
  // 如果是树形表格
387
- if (treeConfig && !scrollYLoad && treeExpandeds.length) {
393
+ if (treeConfig && !scrollYLoad && !transform && treeExpandeds.length) {
388
394
  const rowChildren = row[treeOpts.children]
389
395
  if (rowChildren && rowChildren.length && $xetable.findRowIndexOf(treeExpandeds, row) > -1) {
390
396
  rows.push(...renderRows(fixedType, rowChildren, tableColumn))