fix: 参数配置index为0新增不累加问题
This commit is contained in:
@@ -853,13 +853,13 @@ function arrayEditInit(data: Record<string, any>, 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user