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) {
|
function arrayAddInit(data: any[], dataRule: any) {
|
||||||
let newIndex = 0;
|
|
||||||
|
|
||||||
// 有数据时取得最后的index
|
// 有数据时取得最后的index
|
||||||
|
let dataLastIndex = 0;
|
||||||
if (data.length !== 0) {
|
if (data.length !== 0) {
|
||||||
const lastFrom = Object.assign({}, JSON.parse(JSON.stringify(data.at(-1))));
|
const lastFrom = Object.assign({}, JSON.parse(JSON.stringify(data.at(-1))));
|
||||||
if (lastFrom.record.length > 0) {
|
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 = [];
|
row.value = [];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const value = row.value;
|
// index值
|
||||||
if (row.name === 'index') {
|
if (row.name === 'index') {
|
||||||
if (newIndex !== 0) {
|
let newIndex = dataLastIndex !== 0 ? dataLastIndex : parseInt(row.value);
|
||||||
newIndex += 1;
|
|
||||||
} else {
|
|
||||||
newIndex = parseInt(value);
|
|
||||||
}
|
|
||||||
if (isNaN(newIndex)) {
|
if (isNaN(newIndex)) {
|
||||||
newIndex = 0;
|
newIndex = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user