diff --git a/src/views/configManage/configParamTreeTable/index.vue b/src/views/configManage/configParamTreeTable/index.vue index fec41f33..39b69e24 100644 --- a/src/views/configManage/configParamTreeTable/index.vue +++ b/src/views/configManage/configParamTreeTable/index.vue @@ -853,13 +853,13 @@ function arrayEditInit(data: Record, dataRule: any) { /**多列表新增行数据初始化 */ function arrayAddInit(data: any[], dataRule: any) { - let newIndex = 0; - // 有数据时取得最后的index + let dataLastIndex = 0; if (data.length !== 0) { const lastFrom = Object.assign({}, JSON.parse(JSON.stringify(data.at(-1)))); if (lastFrom.record.length > 0) { - newIndex = parseInt(lastFrom.key); + dataLastIndex = parseInt(lastFrom.key); + dataLastIndex += 1; } } @@ -870,13 +870,9 @@ function arrayAddInit(data: any[], dataRule: any) { row.value = []; continue; } - const value = row.value; + // index值 if (row.name === 'index') { - if (newIndex !== 0) { - newIndex += 1; - } else { - newIndex = parseInt(value); - } + let newIndex = dataLastIndex !== 0 ? dataLastIndex : parseInt(row.value); if (isNaN(newIndex)) { newIndex = 0; }