Skip to content

Commit f7be5a5

Browse files
committed
releases 4.17.35
1 parent d94b776 commit f7be5a5

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vxe-table",
3-
"version": "4.17.34",
3+
"version": "4.17.35",
44
"description": "A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.",
55
"scripts": {
66
"update": "npm install --legacy-peer-deps",

packages/table/module/edit/hook.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ hooks.add('tableEditModule', {
108108

109109
// }
110110

111-
const handleInsertRowAt = (records: any, targetRow: any, isInsertNextRow?: boolean) => {
111+
const handleInsertRowAt = (records: any, targetRowOrRowid: any, isInsertNextRow?: boolean) => {
112112
const { treeConfig } = props
113113
const { isRowGroupStatus } = reactData
114114
const { tableFullTreeData, afterFullData, mergeBodyList, tableFullData, fullDataRowIdData, fullAllDataRowIdData, insertRowMaps, removeRowMaps } = internalData
@@ -118,6 +118,13 @@ hooks.add('tableEditModule', {
118118
if (!XEUtils.isArray(records)) {
119119
records = [records]
120120
}
121+
let targetRow = targetRowOrRowid
122+
if (XEUtils.isString(targetRowOrRowid) || XEUtils.isNumber(targetRowOrRowid)) {
123+
const rowRest = fullAllDataRowIdData[targetRowOrRowid]
124+
if (rowRest) {
125+
targetRow = rowRest.row
126+
}
127+
}
121128
const newRecords: any[] = reactive($xeTable.defineField(records.map((record: any) => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record))))
122129
let treeRecords: any[] = []
123130
if (treeConfig && transform) {
@@ -317,14 +324,22 @@ hooks.add('tableEditModule', {
317324
})
318325
}
319326

320-
const handleInsertChildRowAt = (records: any, parentRow: any, targetRow: any, isInsertNextRow?: boolean) => {
327+
const handleInsertChildRowAt = (records: any, parentRowOrParentId: any, targetRow: any, isInsertNextRow?: boolean) => {
321328
const { treeConfig } = props
329+
const { fullAllDataRowIdData } = internalData
322330
const treeOpts = computeTreeOpts.value
323331
const { transform, rowField, parentField } = treeOpts
324332
if (treeConfig && transform) {
325333
if (!XEUtils.isArray(records)) {
326334
records = [records]
327335
}
336+
let parentRow = parentRowOrParentId
337+
if (XEUtils.isString(parentRowOrParentId) || XEUtils.isNumber(parentRowOrParentId)) {
338+
const rowRest = fullAllDataRowIdData[parentRowOrParentId]
339+
if (rowRest) {
340+
parentRow = rowRest.row
341+
}
342+
}
328343
return handleInsertRowAt(records.map((item: any) => Object.assign({}, item, { [parentField]: parentRow[rowField] })), targetRow, isInsertNextRow)
329344
} else {
330345
errLog('vxe.error.errProp', ['tree-config.transform=false', 'tree-config.transform=true'])
@@ -511,23 +526,22 @@ hooks.add('tableEditModule', {
511526
* 如果 row 为空则从插入到顶部,如果为树结构,则插入到目标节点顶部
512527
* 如果 row 为 -1 则从插入到底部,如果为树结构,则插入到目标节点底部
513528
* 如果 row 为有效行则插入到该行的位置,如果为树结构,则有插入到效的目标节点该行的位置
514-
* @param {Object/Array} records 新的数据
515-
* @param {Row} targetRow 指定行
516529
*/
517-
insertAt (records, targetRow) {
518-
return handleInsertRowAt(records, targetRow)
530+
insertAt (records, targetRowOrRowid) {
531+
return handleInsertRowAt(records, targetRowOrRowid)
519532
},
520-
insertNextAt (records, targetRow) {
521-
return handleInsertRowAt(records, targetRow, true)
533+
insertNextAt (records, targetRowOrRowid) {
534+
return handleInsertRowAt(records, targetRowOrRowid, true)
522535
},
523-
insertChild (records, parentRow) {
524-
return handleInsertChildRowAt(records, parentRow, null)
536+
insertChild (records, parentRowOrParentId) {
537+
(window as any).aa = internalData
538+
return handleInsertChildRowAt(records, parentRowOrParentId, null)
525539
},
526-
insertChildAt (records, parentRow, targetRow) {
527-
return handleInsertChildRowAt(records, parentRow, targetRow)
540+
insertChildAt (records, parentRowOrParentId, targetRow) {
541+
return handleInsertChildRowAt(records, parentRowOrParentId, targetRow)
528542
},
529-
insertChildNextAt (records, parentRow, targetRow) {
530-
return handleInsertChildRowAt(records, parentRow, targetRow, true)
543+
insertChildNextAt (records, parentRowOrParentId, targetRow) {
544+
return handleInsertChildRowAt(records, parentRowOrParentId, targetRow, true)
531545
},
532546
/**
533547
* 删除指定行数据

packages/table/src/table.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5896,22 +5896,6 @@ export default defineVxeComponent({
58965896
const { treeConfig } = props
58975897
const { tableFullData, tableFullTreeData } = internalData
58985898
if (treeConfig) {
5899-
const treeOpts = computeTreeOpts.value
5900-
const { transform, mapChildrenField, rowField, parentField } = treeOpts
5901-
const childrenField = treeOpts.children || treeOpts.childrenField
5902-
if (transform) {
5903-
return XEUtils.toArrayTree(
5904-
XEUtils.toTreeArray(tableFullTreeData, {
5905-
children: mapChildrenField
5906-
}),
5907-
{
5908-
key: rowField,
5909-
parentKey: parentField,
5910-
children: childrenField,
5911-
mapChildren: mapChildrenField
5912-
}
5913-
)
5914-
}
59155899
return tableFullTreeData.slice(0)
59165900
}
59175901
return tableFullData.slice(0)

0 commit comments

Comments
 (0)