Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lazy insert #2380

Open
wants to merge 5 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "3.8.4",
"name": "vxe-table-ycjlazy",
"version": "3.8.4-ycj-beta",
"description": "一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -88,8 +88,8 @@
"vue grid"
],
"author": {
"name": "Xu Liangzhan",
"email": "xu_liangzhan@163.com"
"name": "Yuan Chengjie",
"email": "1210611769@qq.com"
},
"license": "MIT",
"bugs": {
Expand Down
10 changes: 8 additions & 2 deletions packages/edit/src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ function insertTreeRow (_vm, newRecords, isAppend) {
mapChilds = parentRow[childrenField] = []
}
parentChilds[funcName](item)
mapChilds[funcName](item)
// 在开启懒加载的情况下,首次 insert row 会导致重复添加
if (mapChilds !== parentChilds) {
mapChilds[funcName](item)
}
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
fullDataRowIdData[rowid] = rest
fullAllDataRowIdData[rowid] = rest
Expand Down Expand Up @@ -126,7 +129,10 @@ function handleInsertRowAt (_vm, records, row, isInsertNextRow) {
if (isInsertNextRow) {
targetIndex = targetIndex + 1
}
parentChilds.splice(targetIndex, 0, ...newRecords)
// 在开启懒加载的情况下,首次 insert row 会导致重复添加
if (parentChilds !== parentMapChilds) {
parentChilds.splice(targetIndex, 0, ...newRecords)
}
}
}
} else {
Expand Down