作者 yangfu

fix: decimal problem

... ... @@ -494,7 +494,7 @@ func GetItemValues(transactionContext application.TransactionContext, q *query.C
var result = make([]itemValue, 0)
result = append(result, itemValue{
Name: querySet.Name,
Value: value,
Value: domain.RoundValue(value),
})
for _, f := range q.Formula.TableFields {
... ... @@ -511,7 +511,7 @@ func GetItemValues(transactionContext application.TransactionContext, q *query.C
})
result = append(result, itemValue{
Name: f.FieldName,
Value: value,
Value: domain.RoundValue(value),
})
}
return querySet, result
... ...
... ... @@ -96,7 +96,7 @@ func (t *DataTable) Values(f *Field) []string {
for i := range t.Data {
for j := range t.Data[i] {
if j == index {
res = append(res, t.Data[i][j])
res = append(res, RoundFieldValue(f, t.Data[i][j]))
break
}
}
... ...
... ... @@ -264,6 +264,14 @@ func RoundFieldValue(f *Field, v string) string {
//return fmt.Sprintf("%v", fv)
}
func RoundValue(v string) string {
fv, err := strconv.ParseFloat(v, 64)
if err != nil {
return v
}
return fmt.Sprintf("%v", fv)
}
func GripData(data []map[string]string, total int64) map[string]interface{} {
if len(data) == 0 {
data = make([]map[string]string, 0)
... ...
... ... @@ -372,7 +372,7 @@ func (d *DataLayoutDataTable) BlockData(cells *domain.LayoutCell) ([]string, int
if !ok {
return block, 0
}
values := table.Values(&domain.Field{SQLName: cells.Data.TableField.FieldSqlName})
values := table.Values(&domain.Field{SQLName: cells.Data.TableField.FieldSqlName, SQLType: cells.Data.TableField.FieldSQLType})
if len(values) == 0 {
return block, 0
}
... ...
... ... @@ -216,9 +216,9 @@ func (c Condition) CastTypeByField(f *domain.Field, t string) string {
}
func formatFiled(f *domain.Field) string {
if f.SQLType == domain.Float.ToString() || f.SQLType == domain.DECIMAL279.ToString() {
return castTypeAlias(f.SQLName, domain.DECIMALV2.ToString())
}
//if f.SQLType == domain.Float.ToString() || f.SQLType == domain.DECIMAL279.ToString() {
// return castTypeAlias(f.SQLName, domain.DECIMALV2.ToString())
//}
return f.SQLName
}
... ...