This commit is contained in:
Daniel 2025-07-06 16:54:55 +08:00
parent 2e444d899b
commit 05f4d2995c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 89 additions and 124 deletions

View file

@ -1318,72 +1318,7 @@ func renderViewableInstance(viewable av.Viewable, view *av.View, attrView *av.At
av.Filter(viewable, attrView)
av.Sort(viewable, attrView)
av.Calc(viewable)
if groupCalc := viewable.GetGroupCalc(); nil != groupCalc {
if groupCalcKey, _ := attrView.GetKey(groupCalc.Field); nil != groupCalcKey {
collection := viewable.(av.Collection)
var calcResult *av.GroupCalc
field := collection.GetField(groupCalcKey.ID)
if nil != field {
if calc := field.GetCalc(); nil != calc && field.GetID() == groupCalcKey.ID {
// 直接使用字段计算结果
calcResult = &av.GroupCalc{Field: groupCalcKey.ID, FieldCalc: calc}
}
if nil == calcResult {
for i, f := range collection.GetFields() {
if f.GetID() != groupCalcKey.ID {
continue
}
field.SetCalc(groupCalc.FieldCalc)
switch field.GetType() {
case av.KeyTypeBlock:
av.CalcFieldBlock(collection, field, i)
case av.KeyTypeText:
av.CalcFieldText(collection, field, i)
case av.KeyTypeNumber:
av.CalcFieldNumber(collection, field, i)
case av.KeyTypeDate:
av.CalcFieldDate(collection, field, i)
case av.KeyTypeSelect:
av.CalcFieldSelect(collection, field, i)
case av.KeyTypeMSelect:
av.CalcFieldMSelect(collection, field, i)
case av.KeyTypeURL:
av.CalcFieldURL(collection, field, i)
case av.KeyTypeEmail:
av.CalcFieldEmail(collection, field, i)
case av.KeyTypePhone:
av.CalcFieldPhone(collection, field, i)
case av.KeyTypeMAsset:
av.CalcFieldMAsset(collection, field, i)
case av.KeyTypeTemplate:
av.CalcFieldTemplate(collection, field, i)
case av.KeyTypeCreated:
av.CalcFieldCreated(collection, field, i)
case av.KeyTypeUpdated:
av.CalcFieldUpdated(collection, field, i)
case av.KeyTypeCheckbox:
av.CalcFieldCheckbox(collection, field, i)
case av.KeyTypeRelation:
av.CalcFieldRelation(collection, field, i)
case av.KeyTypeRollup:
av.CalcFieldRollup(collection, field, i)
}
break
}
calcResult = &av.GroupCalc{Field: groupCalcKey.ID, FieldCalc: field.GetCalc()}
field.SetCalc(nil)
}
}
viewable.SetGroupCalc(calcResult)
}
}
av.Calc(viewable, attrView)
// 分页
switch viewable.GetType() {