修复懒加载树编辑状态无效问题

This commit is contained in:
xuliangzhan
2023-08-31 08:39:12 +08:00
parent 1222b85105
commit f0e35ed402
5 changed files with 31 additions and 7 deletions

View File

@@ -19,6 +19,10 @@
"type": "number | string",
"description": "表格的高度;支持铺满父容器或者固定高度,如果设置 auto 为铺满父容器(如果设置为 auto则必须确保存在父节点且不允许存在相邻元素"
},
"vxe-table/min-height": {
"type": "number | string",
"description": "表格最小高度"
},
"vxe-table/max-height": {
"type": "number | string",
"description": "表格的最大高度"
@@ -297,7 +301,7 @@
},
"vxe-table/custom-config": {
"type": "any",
"description": "自定义列配置项"
"description": "个性化信息配置项"
},
"vxe-table/scroll-x": {
"type": "any",
@@ -531,6 +535,10 @@
"type": "number | string",
"description": "表格的高度;支持铺满父容器或者固定高度,如果设置 auto 为铺满父容器(如果设置为 auto则必须确保存在父节点且不允许存在相邻元素"
},
"vxe-grid/min-height": {
"type": "number | string",
"description": "表格最小高度"
},
"vxe-grid/max-height": {
"type": "number | string",
"description": "表格的最大高度"
@@ -809,7 +817,7 @@
},
"vxe-grid/custom-config": {
"type": "any",
"description": "自定义列配置项"
"description": "个性化信息配置项"
},
"vxe-grid/scroll-x": {
"type": "any",
@@ -1203,6 +1211,14 @@
"type": "boolean",
"description": "只对 type=number|integer|float 有效,是否显示控制按钮"
},
"vxe-input/show-word-count": {
"type": "boolean",
"description": "只对 type=text|search 有效,是否显示字数统计"
},
"vxe-input/count-method": {
"type": "boolean",
"description": "只对 showWordCount 有效,自定义字数计算方法"
},
"vxe-input/start-date": {
"type": "number | string | date",
"description": "只对 type=date|datetime|week|month|quarter|year 有效,设置面板起始日期"

View File

@@ -11,6 +11,7 @@
"id",
"data",
"height",
"min-height",
"max-height",
"auto-resize",
"sync-resize",
@@ -161,6 +162,7 @@
"columns",
"data",
"height",
"min-height",
"max-height",
"auto-resize",
"sync-resize",
@@ -381,6 +383,8 @@
"align",
"exponential",
"controls",
"show-word-count",
"count-method",
"start-date",
"end-date",
"start-week",

View File

@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.5.8",
"version": "4.5.9",
"description": "一个基于 vue 的 PC 端表单/表格组件支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
@@ -68,7 +68,7 @@
"vue-i18n": "^9.1.7",
"vue-router": "^4.0.11",
"vuex": "^4.0.2",
"xe-utils": "^3.5.12"
"xe-utils": "^3.5.13"
},
"peerDependencies": {
"vue": "^3.2.28",

View File

@@ -1,4 +1,4 @@
import { nextTick } from 'vue'
import { reactive, nextTick } from 'vue'
import XEUtils from 'xe-utils'
import GlobalConfig from '../../v-x-e-table/src/conf'
import { renderer } from '../../v-x-e-table'
@@ -113,7 +113,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
if (!XEUtils.isArray(records)) {
records = [records]
}
const newRecords: any[] = $xetable.defineField(records.map((record: any) => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record)))
const newRecords: any[] = reactive($xetable.defineField(records.map((record: any) => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record))))
if (!row) {
// 如果为虚拟树
if (treeConfig && transform) {

View File

@@ -2796,7 +2796,7 @@ export default defineComponent({
*/
loadTreeChildren (row, childRecords) {
const { keepSource } = props
const { tableSourceData, fullDataRowIdData, fullAllDataRowIdData } = internalData
const { tableSourceData, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = internalData
const treeOpts = computeTreeOpts.value
const { transform, mapChildrenField } = treeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
@@ -2809,6 +2809,10 @@ export default defineComponent({
if (matchObj) {
matchObj.item[childrenField] = XEUtils.clone(rows, true)
}
rows.forEach(childRow => {
const rowid = getRowid($xetable, childRow)
sourceDataRowIdData[rowid] = XEUtils.clone(childRow, true)
})
}
XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
const rowid = getRowid($xetable, childRow)