@@ -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 * 删除指定行数据
0 commit comments