vxe-table 3.4.0 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -3
- package/README.md +2 -2
- package/README.zh-TW.md +2 -2
- package/lib/edit/src/mixin.js +155 -59
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/header/src/header.js +1 -1
- package/lib/header/src/header.min.js +1 -1
- package/lib/index.umd.js +294 -969
- package/lib/index.umd.min.js +1 -1
- package/lib/table/src/body.js +10 -7
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +92 -35
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +38 -36
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +5 -3
- package/lib/table/src/table.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +2 -2
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/package.json +2 -2
- package/packages/edit/src/mixin.js +97 -36
- package/packages/header/src/header.js +1 -1
- package/packages/table/src/body.js +8 -7
- package/packages/table/src/cell.js +74 -41
- package/packages/table/src/methods.js +32 -34
- package/packages/table/src/table.js +5 -3
- package/packages/v-x-e-table/src/conf.js +2 -2
- package/types/index.d.ts +1 -1
- package/types/table.d.ts +8 -8
|
@@ -325,11 +325,11 @@ const Methods = {
|
|
|
325
325
|
// 树结构自动转换
|
|
326
326
|
if (treeOpts.transform) {
|
|
327
327
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
328
|
-
if (!treeOpts.
|
|
329
|
-
UtilTools.error('vxe.error.reqProp', ['table.tree-config.
|
|
328
|
+
if (!treeOpts.rowField) {
|
|
329
|
+
UtilTools.error('vxe.error.reqProp', ['table.tree-config.rowField'])
|
|
330
330
|
}
|
|
331
|
-
if (!treeOpts.
|
|
332
|
-
UtilTools.error('vxe.error.reqProp', ['table.tree-config.
|
|
331
|
+
if (!treeOpts.parentField) {
|
|
332
|
+
UtilTools.error('vxe.error.reqProp', ['table.tree-config.parentField'])
|
|
333
333
|
}
|
|
334
334
|
if (!treeOpts.children) {
|
|
335
335
|
UtilTools.error('vxe.error.reqProp', ['tree-config.children'])
|
|
@@ -340,7 +340,7 @@ const Methods = {
|
|
|
340
340
|
}
|
|
341
341
|
})
|
|
342
342
|
}
|
|
343
|
-
treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.
|
|
343
|
+
treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.rowField, parentKey: treeOpts.parentField, children: treeOpts.children })
|
|
344
344
|
fullData = treeData.slice(0)
|
|
345
345
|
} else {
|
|
346
346
|
treeData = fullData.slice(0)
|
|
@@ -464,16 +464,12 @@ const Methods = {
|
|
|
464
464
|
const oRow = tableSourceData[rowIndex]
|
|
465
465
|
if (oRow && row) {
|
|
466
466
|
if (field) {
|
|
467
|
-
|
|
467
|
+
const newValue = XEUtils.get(record || row, field)
|
|
468
|
+
XEUtils.set(row, field, newValue)
|
|
469
|
+
XEUtils.set(oRow, field, newValue)
|
|
468
470
|
} else {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
XEUtils.clear(row, undefined)
|
|
472
|
-
Object.assign(row, this.defineField(Object.assign({}, record)))
|
|
473
|
-
this.cacheRowMap(true)
|
|
474
|
-
} else {
|
|
475
|
-
XEUtils.destructuring(oRow, XEUtils.clone(row, true))
|
|
476
|
-
}
|
|
471
|
+
const newRecord = XEUtils.clone({ ...record }, true)
|
|
472
|
+
XEUtils.destructuring(oRow, Object.assign(row, newRecord))
|
|
477
473
|
}
|
|
478
474
|
}
|
|
479
475
|
this.tableData = tableData.slice(0)
|
|
@@ -2135,7 +2131,7 @@ const Methods = {
|
|
|
2135
2131
|
// 该行为只对当前激活的表格有效
|
|
2136
2132
|
if (this.isActivated) {
|
|
2137
2133
|
this.preventEvent(evnt, 'event.keydown', null, () => {
|
|
2138
|
-
const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu } = this
|
|
2134
|
+
const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu, rowOpts } = this
|
|
2139
2135
|
const { selected, actived } = editStore
|
|
2140
2136
|
const { keyCode } = evnt
|
|
2141
2137
|
const isBack = keyCode === 8
|
|
@@ -2198,7 +2194,7 @@ const Methods = {
|
|
|
2198
2194
|
this.keyCtxTimeout = setTimeout(() => {
|
|
2199
2195
|
this._keyCtx = false
|
|
2200
2196
|
}, 1000)
|
|
2201
|
-
} else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && highlightCurrentRow && currentRow))) {
|
|
2197
|
+
} else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
|
|
2202
2198
|
// 退出选中
|
|
2203
2199
|
if (hasCtrlKey) {
|
|
2204
2200
|
// 如果是激活编辑状态,则取消编辑
|
|
@@ -2227,7 +2223,7 @@ const Methods = {
|
|
|
2227
2223
|
this.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt)
|
|
2228
2224
|
}
|
|
2229
2225
|
}
|
|
2230
|
-
} else if (treeConfig && highlightCurrentRow && currentRow) {
|
|
2226
|
+
} else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
|
|
2231
2227
|
// 如果是树形表格当前行回车移动到子节点
|
|
2232
2228
|
const childrens = currentRow[treeOpts.children]
|
|
2233
2229
|
if (childrens && childrens.length) {
|
|
@@ -2245,7 +2241,7 @@ const Methods = {
|
|
|
2245
2241
|
// 如果按下了方向键
|
|
2246
2242
|
if (selected.row && selected.column) {
|
|
2247
2243
|
this.moveSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
2248
|
-
} else if ((isUpArrow || isDwArrow) && highlightCurrentRow) {
|
|
2244
|
+
} else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
|
|
2249
2245
|
// 当前行按键上下移动
|
|
2250
2246
|
this.moveCurrentRow(isUpArrow, isDwArrow, evnt)
|
|
2251
2247
|
}
|
|
@@ -2257,7 +2253,7 @@ const Methods = {
|
|
|
2257
2253
|
} else if (actived.row || actived.column) {
|
|
2258
2254
|
this.moveTabSelected(actived.args, hasShiftKey, evnt)
|
|
2259
2255
|
}
|
|
2260
|
-
} else if (keyboardConfig && (isDel || (treeConfig && highlightCurrentRow && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
|
|
2256
|
+
} else if (keyboardConfig && (isDel || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
|
|
2261
2257
|
if (!isEditStatus) {
|
|
2262
2258
|
const { delMethod, backMethod } = keyboardOpts
|
|
2263
2259
|
// 如果是删除键
|
|
@@ -2289,7 +2285,7 @@ const Methods = {
|
|
|
2289
2285
|
// 如果按下 del 键,更新表尾数据
|
|
2290
2286
|
this.updateFooter()
|
|
2291
2287
|
}
|
|
2292
|
-
} else if (isBack && keyboardOpts.isArrow && treeConfig && highlightCurrentRow && currentRow) {
|
|
2288
|
+
} else if (isBack && keyboardOpts.isArrow && treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
|
|
2293
2289
|
// 如果树形表格回退键关闭当前行返回父节点
|
|
2294
2290
|
const { parent: parentRow } = XEUtils.findTree(this.afterFullData, item => item === currentRow, treeOpts)
|
|
2295
2291
|
if (parentRow) {
|
|
@@ -3052,11 +3048,11 @@ const Methods = {
|
|
|
3052
3048
|
* @param {Row} row 行对象
|
|
3053
3049
|
*/
|
|
3054
3050
|
setCurrentRow (row) {
|
|
3055
|
-
const { $el } = this
|
|
3051
|
+
const { $el, rowOpts } = this
|
|
3056
3052
|
this.clearCurrentRow()
|
|
3057
3053
|
this.clearCurrentColumn()
|
|
3058
3054
|
this.currentRow = row
|
|
3059
|
-
if (this.highlightCurrentRow) {
|
|
3055
|
+
if (rowOpts.isCurrent || this.highlightCurrentRow) {
|
|
3060
3056
|
if ($el) {
|
|
3061
3057
|
XEUtils.arrayEach($el.querySelectorAll(`[rowid="${getRowid(this, row)}"]`), elem => addClass(elem, 'row--current'))
|
|
3062
3058
|
}
|
|
@@ -3102,7 +3098,7 @@ const Methods = {
|
|
|
3102
3098
|
* 用于当前行,获取当前行的数据
|
|
3103
3099
|
*/
|
|
3104
3100
|
getCurrentRecord () {
|
|
3105
|
-
return this.highlightCurrentRow ? this.currentRow : null
|
|
3101
|
+
return this.rowOpts.isCurrent || this.highlightCurrentRow ? this.currentRow : null
|
|
3106
3102
|
},
|
|
3107
3103
|
/**
|
|
3108
3104
|
* 用于单选行,获取当已选中的数据
|
|
@@ -3164,7 +3160,7 @@ const Methods = {
|
|
|
3164
3160
|
this.triggerSortEvent(evnt, column, getNextSortOrder(this, column))
|
|
3165
3161
|
}
|
|
3166
3162
|
this.emitEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
|
|
3167
|
-
if (this.highlightCurrentColumn) {
|
|
3163
|
+
if (this.columnOpts.isCurrent || this.highlightCurrentColumn) {
|
|
3168
3164
|
return this.setCurrentColumn(column)
|
|
3169
3165
|
}
|
|
3170
3166
|
return this.$nextTick()
|
|
@@ -3173,7 +3169,7 @@ const Methods = {
|
|
|
3173
3169
|
this.emitEvent('header-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, params), evnt)
|
|
3174
3170
|
},
|
|
3175
3171
|
getCurrentColumn () {
|
|
3176
|
-
return this.highlightCurrentColumn ? this.currentColumn : null
|
|
3172
|
+
return this.columnOpts.isCurrent || this.highlightCurrentColumn ? this.currentColumn : null
|
|
3177
3173
|
},
|
|
3178
3174
|
/**
|
|
3179
3175
|
* 用于当前列,设置某列行为高亮状态
|
|
@@ -3220,7 +3216,7 @@ const Methods = {
|
|
|
3220
3216
|
* 如果是双击模式,则单击后选中状态
|
|
3221
3217
|
*/
|
|
3222
3218
|
triggerCellClickEvent (evnt, params) {
|
|
3223
|
-
const { highlightCurrentRow, editStore, radioOpts, expandOpts, treeOpts, editConfig, editOpts, checkboxOpts } = this
|
|
3219
|
+
const { highlightCurrentRow, editStore, radioOpts, expandOpts, treeOpts, editConfig, editOpts, checkboxOpts, rowOpts } = this
|
|
3224
3220
|
const { actived } = editStore
|
|
3225
3221
|
const { row, column } = params
|
|
3226
3222
|
const { type, treeNode } = column
|
|
@@ -3247,7 +3243,7 @@ const Methods = {
|
|
|
3247
3243
|
if (!triggerTreeNode) {
|
|
3248
3244
|
if (!triggerExpandNode) {
|
|
3249
3245
|
// 如果是高亮行
|
|
3250
|
-
if (highlightCurrentRow) {
|
|
3246
|
+
if (rowOpts.isCurrent || highlightCurrentRow) {
|
|
3251
3247
|
if (!triggerCheckbox && !triggerRadio) {
|
|
3252
3248
|
this.triggerCurrentRowEvent(evnt, params)
|
|
3253
3249
|
}
|
|
@@ -3487,7 +3483,7 @@ const Methods = {
|
|
|
3487
3483
|
* 重新懒加载展开行,并展开内容
|
|
3488
3484
|
* @param {Row} row 行对象
|
|
3489
3485
|
*/
|
|
3490
|
-
|
|
3486
|
+
reloadRowExpand (row) {
|
|
3491
3487
|
const { expandOpts, expandLazyLoadeds } = this
|
|
3492
3488
|
const { lazy } = expandOpts
|
|
3493
3489
|
if (lazy && expandLazyLoadeds.indexOf(row) === -1) {
|
|
@@ -3498,10 +3494,10 @@ const Methods = {
|
|
|
3498
3494
|
},
|
|
3499
3495
|
reloadExpandContent (row) {
|
|
3500
3496
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
3501
|
-
UtilTools.warn('vxe.error.delFunc', ['reloadExpandContent', '
|
|
3497
|
+
UtilTools.warn('vxe.error.delFunc', ['reloadExpandContent', 'reloadRowExpand'])
|
|
3502
3498
|
}
|
|
3503
3499
|
// 即将废弃
|
|
3504
|
-
return this.
|
|
3500
|
+
return this.reloadRowExpand(row)
|
|
3505
3501
|
},
|
|
3506
3502
|
/**
|
|
3507
3503
|
* 展开行事件
|
|
@@ -3686,7 +3682,7 @@ const Methods = {
|
|
|
3686
3682
|
* 重新懒加载树节点,并展开该节点
|
|
3687
3683
|
* @param {Row} row 行对象
|
|
3688
3684
|
*/
|
|
3689
|
-
|
|
3685
|
+
reloadTreeExpand (row) {
|
|
3690
3686
|
const { treeOpts, treeLazyLoadeds } = this
|
|
3691
3687
|
const { transform, lazy, hasChild } = treeOpts
|
|
3692
3688
|
if (lazy && row[hasChild] && treeLazyLoadeds.indexOf(row) === -1) {
|
|
@@ -3704,10 +3700,10 @@ const Methods = {
|
|
|
3704
3700
|
},
|
|
3705
3701
|
reloadTreeChilds (row) {
|
|
3706
3702
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
3707
|
-
UtilTools.warn('vxe.error.delFunc', ['reloadTreeChilds', '
|
|
3703
|
+
UtilTools.warn('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
|
|
3708
3704
|
}
|
|
3709
3705
|
// 即将废弃
|
|
3710
|
-
return this.
|
|
3706
|
+
return this.reloadTreeExpand(row)
|
|
3711
3707
|
},
|
|
3712
3708
|
/**
|
|
3713
3709
|
* 展开树节点事件
|
|
@@ -3843,8 +3839,10 @@ const Methods = {
|
|
|
3843
3839
|
updateVirtualTreeData () {
|
|
3844
3840
|
const { scrollYLoad: oldScrollYLoad, treeExpandeds, treeOpts, treeFullData } = this
|
|
3845
3841
|
const fullData = []
|
|
3842
|
+
const expandMaps = new Map()
|
|
3846
3843
|
XEUtils.eachTree(treeFullData, (row, index, items, path, parent) => {
|
|
3847
|
-
if (!parent || treeExpandeds.indexOf(parent) > -1) {
|
|
3844
|
+
if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
|
|
3845
|
+
expandMaps.set(row, 1)
|
|
3848
3846
|
fullData.push(row)
|
|
3849
3847
|
}
|
|
3850
3848
|
}, treeOpts)
|
|
@@ -976,7 +976,9 @@ export default {
|
|
|
976
976
|
ctxMenuStore,
|
|
977
977
|
ctxMenuOpts,
|
|
978
978
|
footerTableData,
|
|
979
|
-
hasTip
|
|
979
|
+
hasTip,
|
|
980
|
+
columnOpts,
|
|
981
|
+
rowOpts
|
|
980
982
|
} = this
|
|
981
983
|
const { leftList, rightList } = columnStore
|
|
982
984
|
return h('div', {
|
|
@@ -985,8 +987,8 @@ export default {
|
|
|
985
987
|
'cell--highlight': highlightCell,
|
|
986
988
|
'cell--selected': mouseConfig && mouseOpts.selected,
|
|
987
989
|
'cell--area': mouseConfig && mouseOpts.area,
|
|
988
|
-
'row--highlight': highlightHoverRow,
|
|
989
|
-
'column--highlight': highlightHoverColumn,
|
|
990
|
+
'row--highlight': rowOpts.isHover || highlightHoverRow,
|
|
991
|
+
'column--highlight': columnOpts.isHover || highlightHoverColumn,
|
|
990
992
|
'is--header': showHeader,
|
|
991
993
|
'is--footer': showFooter,
|
|
992
994
|
'is--group': isGroup,
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as VXETableExport from './all'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* 一个基于 vue 的 PC
|
|
4
|
+
* 一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...
|
|
5
5
|
*/
|
|
6
6
|
declare const VXETable: typeof VXETableExport
|
|
7
7
|
|
package/types/table.d.ts
CHANGED
|
@@ -634,7 +634,7 @@ export declare class Table extends VXETableComponent {
|
|
|
634
634
|
* 用于懒加载展开行,重新加载展开行的内容
|
|
635
635
|
* @param rows 指定行
|
|
636
636
|
*/
|
|
637
|
-
|
|
637
|
+
reloadRowExpand(rows: RowInfo | RowInfo[]): Promise<any>;
|
|
638
638
|
/**
|
|
639
639
|
* 用于 type=expand,切换展开行的状态
|
|
640
640
|
* @param row 指定行
|
|
@@ -859,9 +859,9 @@ export declare class Table extends VXETableComponent {
|
|
|
859
859
|
*/
|
|
860
860
|
clearActived(): Promise<any>;
|
|
861
861
|
/**
|
|
862
|
-
* 用于 mouse-config.area
|
|
862
|
+
* 用于 mouse-config.area,用于清除鼠标选择的区域,可以指定清除的区域
|
|
863
863
|
*/
|
|
864
|
-
clearCellAreas(): Promise<any>;
|
|
864
|
+
clearCellAreas(area?: number | MouseCellArea): Promise<any>;
|
|
865
865
|
/**
|
|
866
866
|
* 用于 edit-config,获取已激活的行数据
|
|
867
867
|
*/
|
|
@@ -901,9 +901,9 @@ export declare class Table extends VXETableComponent {
|
|
|
901
901
|
* @param areaConfigs 指定区域
|
|
902
902
|
*/
|
|
903
903
|
setCellAreas(areaConfigs: CellAreaConfig[], activeArea?: {
|
|
904
|
-
area?: MouseCellArea;
|
|
905
|
-
column
|
|
906
|
-
row
|
|
904
|
+
area?: number | MouseCellArea;
|
|
905
|
+
column?: number | ColumnInfo;
|
|
906
|
+
row?: number | RowInfo;
|
|
907
907
|
}): Promise<any>;
|
|
908
908
|
/**
|
|
909
909
|
* 用于 mouse-config.area,设置活动的区域的单元格
|
|
@@ -911,8 +911,8 @@ export declare class Table extends VXETableComponent {
|
|
|
911
911
|
*/
|
|
912
912
|
setActiveCellArea(activeArea: {
|
|
913
913
|
area: MouseCellArea;
|
|
914
|
-
column: ColumnInfo;
|
|
915
|
-
row: RowInfo;
|
|
914
|
+
column: number | ColumnInfo;
|
|
915
|
+
row: number | RowInfo;
|
|
916
916
|
}): Promise<any>;
|
|
917
917
|
/**
|
|
918
918
|
* 临时合并单元格,如果为数组则合并多个
|