vxe-table 3.17.0-beta.13 → 3.17.0-beta.15
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/es/style.css +1 -1
- package/es/table/module/custom/mixin.js +11 -2
- package/es/table/src/columnInfo.js +4 -0
- package/es/table/src/methods.js +73 -32
- package/es/table/src/table.js +1 -1
- package/es/table/src/util.js +9 -0
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +121 -36
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/custom/mixin.js +15 -2
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/src/columnInfo.js +4 -0
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/methods.js +91 -33
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +1 -1
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +10 -0
- package/lib/table/src/util.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +1 -1
- package/packages/table/module/custom/mixin.ts +11 -2
- package/packages/table/src/columnInfo.ts +5 -0
- package/packages/table/src/methods.ts +76 -33
- package/packages/table/src/table.ts +1 -1
- package/packages/table/src/util.ts +10 -0
- /package/es/{iconfont.1753775808744.ttf → iconfont.1753843895290.ttf} +0 -0
- /package/es/{iconfont.1753775808744.woff → iconfont.1753843895290.woff} +0 -0
- /package/es/{iconfont.1753775808744.woff2 → iconfont.1753843895290.woff2} +0 -0
- /package/lib/{iconfont.1753775808744.ttf → iconfont.1753843895290.ttf} +0 -0
- /package/lib/{iconfont.1753775808744.woff → iconfont.1753843895290.woff} +0 -0
- /package/lib/{iconfont.1753775808744.woff2 → iconfont.1753843895290.woff2} +0 -0
|
@@ -3,7 +3,7 @@ import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTarge
|
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
5
|
import Cell from './cell'
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight } from './util'
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getColumnList, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight } from './util'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime'
|
|
9
9
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
@@ -134,11 +134,35 @@ function handleCustomRestore ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
134
134
|
const reactData = $xeTable as unknown as TableReactData
|
|
135
135
|
const internalData = $xeTable as unknown as TableInternalData
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
let hasCustomSort = false
|
|
137
|
+
const { collectColumn } = internalData
|
|
138
|
+
let { resizableData, sortData, visibleData, fixedData } = storeData
|
|
140
139
|
// 处理还原
|
|
141
140
|
if (resizableData || sortData || visibleData || fixedData) {
|
|
141
|
+
const sortColMaps: Record<string, {
|
|
142
|
+
key: string
|
|
143
|
+
sNum: number
|
|
144
|
+
pKey: string | null
|
|
145
|
+
}> = {}
|
|
146
|
+
// 转换兼容老版本数据
|
|
147
|
+
if (sortData) {
|
|
148
|
+
if (!XEUtils.isArray(sortData)) {
|
|
149
|
+
const sortRests: {key: string, index: number}[] = []
|
|
150
|
+
XEUtils.each(sortData, (index: number, colKey: string) => {
|
|
151
|
+
sortRests.push({ key: colKey, index })
|
|
152
|
+
})
|
|
153
|
+
sortData = XEUtils.orderBy(sortRests, { field: 'index', order: 'asc' }).map(item => ({ k: item.key }))
|
|
154
|
+
}
|
|
155
|
+
let colNum = 1
|
|
156
|
+
XEUtils.eachTree(sortData, (sObj, index, sOjs, path, pSObj) => {
|
|
157
|
+
sortColMaps[sObj.k] = {
|
|
158
|
+
key: sObj.k,
|
|
159
|
+
sNum: colNum++,
|
|
160
|
+
pKey: pSObj ? pSObj.k : null
|
|
161
|
+
}
|
|
162
|
+
}, { children: 'c' })
|
|
163
|
+
}
|
|
164
|
+
const colKeyMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
|
|
165
|
+
const allCols: VxeTableDefines.ColumnInfo[] = []
|
|
142
166
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
143
167
|
const colKey = column.getKey()
|
|
144
168
|
// 支持一级
|
|
@@ -146,10 +170,6 @@ function handleCustomRestore ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
146
170
|
if (fixedData && fixedData[colKey] !== undefined) {
|
|
147
171
|
column.fixed = fixedData[colKey]
|
|
148
172
|
}
|
|
149
|
-
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
150
|
-
hasCustomSort = true
|
|
151
|
-
column.renderSortNumber = sortData[colKey]
|
|
152
|
-
}
|
|
153
173
|
}
|
|
154
174
|
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
155
175
|
column.resizeWidth = resizableData[colKey]
|
|
@@ -157,12 +177,23 @@ function handleCustomRestore ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
157
177
|
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
158
178
|
column.visible = visibleData[colKey]
|
|
159
179
|
}
|
|
180
|
+
colKeyMaps[colKey] = column
|
|
181
|
+
allCols.push(column)
|
|
160
182
|
})
|
|
161
183
|
// 如果自定义了顺序
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
184
|
+
if (sortData) {
|
|
185
|
+
allCols.forEach(column => {
|
|
186
|
+
const colKey = column.getKey()
|
|
187
|
+
const scItem = sortColMaps[colKey]
|
|
188
|
+
if (scItem) {
|
|
189
|
+
const parentColumn = scItem.pKey ? colKeyMaps[scItem.pKey] : null
|
|
190
|
+
column.parentId = parentColumn ? parentColumn.id : null
|
|
191
|
+
column.renderSortNumber = scItem.sNum
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
|
|
195
|
+
internalData.collectColumn = newCollectCols
|
|
196
|
+
internalData.tableFullColumn = getColumnList(newCollectCols)
|
|
166
197
|
}
|
|
167
198
|
reactData.isCustomStatus = true
|
|
168
199
|
} else {
|
|
@@ -3211,15 +3242,6 @@ function loadScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
3211
3242
|
$xeTable.closeTooltip()
|
|
3212
3243
|
}
|
|
3213
3244
|
|
|
3214
|
-
// 获取所有的列,排除分组
|
|
3215
|
-
function getColumnList (columns: any[]) {
|
|
3216
|
-
const result: any[] = []
|
|
3217
|
-
columns.forEach((column) => {
|
|
3218
|
-
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
|
|
3219
|
-
})
|
|
3220
|
-
return result
|
|
3221
|
-
}
|
|
3222
|
-
|
|
3223
3245
|
function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, isReset: boolean) {
|
|
3224
3246
|
const props = $xeTable
|
|
3225
3247
|
const reactData = $xeTable as unknown as TableReactData
|
|
@@ -3346,18 +3368,22 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
3346
3368
|
return $xeTable.updateFooter()
|
|
3347
3369
|
}
|
|
3348
3370
|
|
|
3349
|
-
function
|
|
3371
|
+
function initColumnHierarchy ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
3350
3372
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3351
3373
|
|
|
3352
3374
|
const { collectColumn } = internalData
|
|
3353
|
-
|
|
3354
|
-
|
|
3375
|
+
let sortIndex = 1
|
|
3376
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
3377
|
+
const parentId = parentColumn ? parentColumn.id : null
|
|
3378
|
+
column.parentId = parentId
|
|
3379
|
+
column.defaultParentId = parentId
|
|
3355
3380
|
column.sortNumber = sortIndex
|
|
3356
3381
|
column.renderSortNumber = sortIndex
|
|
3382
|
+
sortIndex++
|
|
3357
3383
|
})
|
|
3358
3384
|
}
|
|
3359
3385
|
|
|
3360
|
-
function
|
|
3386
|
+
function handleInitColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, collectColumn: VxeTableDefines.ColumnInfo[]) {
|
|
3361
3387
|
const $xeToolbar = $xeTable.$refs.$xeToolbar as VxeToolbarConstructor
|
|
3362
3388
|
const reactData = $xeTable as unknown as TableReactData
|
|
3363
3389
|
const internalData = $xeTable as unknown as TableInternalData
|
|
@@ -3367,7 +3393,7 @@ function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, c
|
|
|
3367
3393
|
const tableFullColumn = getColumnList(collectColumn)
|
|
3368
3394
|
internalData.tableFullColumn = tableFullColumn
|
|
3369
3395
|
reactData.isColLoading = true
|
|
3370
|
-
|
|
3396
|
+
initColumnHierarchy($xeTable)
|
|
3371
3397
|
return Promise.resolve(
|
|
3372
3398
|
restoreCustomStorage($xeTable)
|
|
3373
3399
|
).then(() => {
|
|
@@ -4049,7 +4075,7 @@ const Methods = {
|
|
|
4049
4075
|
|
|
4050
4076
|
const { lastScrollLeft, lastScrollTop } = internalData
|
|
4051
4077
|
const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn($xeTable, column), { children: 'children' })
|
|
4052
|
-
return
|
|
4078
|
+
return handleInitColumn($xeTable, collectColumn).then(() => {
|
|
4053
4079
|
let targetScrollLeft = lastScrollLeft
|
|
4054
4080
|
let targetScrollTop = lastScrollTop
|
|
4055
4081
|
const virtualXOpts = $xeTable.computeVirtualXOpts
|
|
@@ -4074,10 +4100,10 @@ const Methods = {
|
|
|
4074
4100
|
return this.loadColumn(columns)
|
|
4075
4101
|
})
|
|
4076
4102
|
},
|
|
4077
|
-
|
|
4103
|
+
handleInitColumn (collectColumn: any[]) {
|
|
4078
4104
|
const $xeTable = this
|
|
4079
4105
|
|
|
4080
|
-
return
|
|
4106
|
+
return handleInitColumn($xeTable, collectColumn)
|
|
4081
4107
|
},
|
|
4082
4108
|
/**
|
|
4083
4109
|
* 更新数据行的 Map
|
|
@@ -5278,7 +5304,7 @@ const Methods = {
|
|
|
5278
5304
|
const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
|
|
5279
5305
|
const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
|
|
5280
5306
|
const resizableData: Record<string, number> = {}
|
|
5281
|
-
const sortData:
|
|
5307
|
+
const sortData: VxeTableDefines.CustomSortStoreObj[] = []
|
|
5282
5308
|
const visibleData: Record<string, boolean> = {}
|
|
5283
5309
|
const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
5284
5310
|
const aggFuncData: Record<string, VxeColumnPropTypes.AggFunc> = {}
|
|
@@ -5300,18 +5326,35 @@ const Methods = {
|
|
|
5300
5326
|
let hasFixed = 0
|
|
5301
5327
|
let hasVisible = 0
|
|
5302
5328
|
let hasAggFunc = 0
|
|
5329
|
+
const sortMaps: Record<string, VxeTableDefines.CustomSortStoreObj> = {}
|
|
5303
5330
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
5304
5331
|
const colKey = column.getKey()
|
|
5305
5332
|
if (!colKey) {
|
|
5306
5333
|
errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
|
|
5307
5334
|
return
|
|
5308
5335
|
}
|
|
5309
|
-
|
|
5310
|
-
|
|
5336
|
+
if (parentColumn) {
|
|
5337
|
+
if (isCustomSort) {
|
|
5338
|
+
const pColKey = parentColumn.getKey()
|
|
5339
|
+
const psObj = sortMaps[pColKey]
|
|
5340
|
+
hasSort = 1
|
|
5341
|
+
if (psObj) {
|
|
5342
|
+
const sObj = { k: colKey }
|
|
5343
|
+
sortMaps[colKey] = sObj
|
|
5344
|
+
if (!psObj.c) {
|
|
5345
|
+
psObj.c = []
|
|
5346
|
+
}
|
|
5347
|
+
psObj.c.push(sObj)
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
} else {
|
|
5311
5351
|
if (isCustomSort) {
|
|
5312
5352
|
hasSort = 1
|
|
5313
|
-
|
|
5353
|
+
const sObj = { k: colKey }
|
|
5354
|
+
sortMaps[colKey] = sObj
|
|
5355
|
+
sortData.push(sObj)
|
|
5314
5356
|
}
|
|
5357
|
+
// 只支持一级
|
|
5315
5358
|
if (isCustomFixed && column.fixed !== column.defaultFixed) {
|
|
5316
5359
|
hasFixed = 1
|
|
5317
5360
|
fixedData[colKey] = column.fixed
|
|
@@ -233,6 +233,7 @@ export function assembleColumn (_vm: any) {
|
|
|
233
233
|
if (!groupConfig.children) {
|
|
234
234
|
groupConfig.children = []
|
|
235
235
|
}
|
|
236
|
+
columnConfig.defaultParentId = groupConfig.id
|
|
236
237
|
groupConfig.children.splice(XEUtils.arrayIndexOf($xeColumn.$el.children, $el), 0, columnConfig)
|
|
237
238
|
} else {
|
|
238
239
|
staticColumns.splice(XEUtils.arrayIndexOf(($xeTable.$refs.hideColumn as any).children, $el), 0, columnConfig)
|
|
@@ -446,6 +447,15 @@ export function isColumnInfo (column: any) {
|
|
|
446
447
|
return column instanceof ColumnInfo
|
|
447
448
|
}
|
|
448
449
|
|
|
450
|
+
// 获取所有的列,排除分组
|
|
451
|
+
export function getColumnList (columns: VxeTableDefines.ColumnInfo[]) {
|
|
452
|
+
const result: VxeTableDefines.ColumnInfo[] = []
|
|
453
|
+
columns.forEach((column) => {
|
|
454
|
+
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
|
|
455
|
+
})
|
|
456
|
+
return result
|
|
457
|
+
}
|
|
458
|
+
|
|
449
459
|
export function createColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, options: any, renderOptions: any): any {
|
|
450
460
|
return isColumnInfo(options) ? options : new ColumnInfo($xeTable, options, renderOptions)
|
|
451
461
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|