提交 c3e05ae7 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix loop range issue for both random and no-random field

上级 2be13791
......@@ -123,8 +123,8 @@ func GenerateFieldValuesForDef(field *model.DefField) []string {
values = append(values, val)
count++
isRandomAndLoopEnd := (*field).IsLoop && (*field).LoopIndex == (*field).LoopEnd
isNotRandomAndValOver := !(*field).IsLoop && indexOfRow >= len(fieldWithValues.Values)
isRandomAndLoopEnd := (*field).IsRand && (*field).LoopIndex == (*field).LoopEnd
isNotRandomAndValOver := !(*field).IsRand && indexOfRow >= len(fieldWithValues.Values)
if count >= vari.Total || isRandomAndLoopEnd || isNotRandomAndValOver {
break
}
......@@ -194,8 +194,8 @@ func loopFieldValues(field *model.DefField, oldValues []string, total int, withF
values = append(values, str)
count++
isRandomAndLoopEnd := (*field).IsLoop && (*field).LoopIndex == (*field).LoopEnd
isNotRandomAndValOver := !(*field).IsLoop && indexOfRow >= len(fieldValue.Values)
isRandomAndLoopEnd := (*field).IsRand && (*field).LoopIndex == (*field).LoopEnd
isNotRandomAndValOver := !(*field).IsRand && indexOfRow >= len(fieldValue.Values)
if count >= vari.Total || isRandomAndLoopEnd || isNotRandomAndValOver {
break
}
......@@ -272,10 +272,6 @@ func computerLoop(field *model.DefField) {
(*field).LoopEnd = 1
}
if (*field).LoopStart > 0 || (*field).LoopEnd > 0 {
(*field).IsLoop = false
}
(*field).LoopIndex = (*field).LoopStart
}
......
......@@ -47,6 +47,10 @@ func CreateFieldValuesFromList(field *model.DefField, fieldValue *model.FieldWit
if rangeItem == "" { continue }
entry, stepStr, repeat := ParseRangeItem(rangeItem)
if strings.ToLower(stepStr) == "r" {
(*field).IsRand = true
}
typ, desc := ParseEntry(entry) // 2
items := make([]interface{}, 0)
......
......@@ -72,7 +72,7 @@ type FieldSimple struct {
LoopStart int
LoopEnd int
LoopIndex int
IsLoop bool
IsRand bool
}
type FieldWithValues struct {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册