|
|
@ -2,6 +2,7 @@ import type { Ref } from 'vue' |
|
|
|
import { |
|
|
|
import { |
|
|
|
type ColumnType, |
|
|
|
type ColumnType, |
|
|
|
CommonAggregations, |
|
|
|
CommonAggregations, |
|
|
|
|
|
|
|
type FormulaType, |
|
|
|
type TableType, |
|
|
|
type TableType, |
|
|
|
UITypes, |
|
|
|
UITypes, |
|
|
|
type ViewType, |
|
|
|
type ViewType, |
|
|
@ -123,6 +124,32 @@ const [useProvideViewAggregate, useViewAggregate] = useInjectionState( |
|
|
|
await updateGridViewColumn(fieldId, { aggregation: agg }) |
|
|
|
await updateGridViewColumn(fieldId, { aggregation: agg }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const aggregateFormulaFields = computed(() => { |
|
|
|
|
|
|
|
return fields.value |
|
|
|
|
|
|
|
.filter((field) => { |
|
|
|
|
|
|
|
if (!field?.id || !field?.title) return false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
!isFormula(field) || |
|
|
|
|
|
|
|
!gridViewCols.value[field.id] || |
|
|
|
|
|
|
|
!gridViewCols.value[field.id]?.aggregation || |
|
|
|
|
|
|
|
gridViewCols.value[field.id]?.aggregation === CommonAggregations.None || |
|
|
|
|
|
|
|
!(field.colOptions as FormulaType)?.formula_raw |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.map((field) => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
id: field.id, |
|
|
|
|
|
|
|
aggregation: gridViewCols.value[field.id!]?.aggregation ?? CommonAggregations.None, |
|
|
|
|
|
|
|
formula_raw: (field.colOptions as FormulaType)?.formula_raw ?? '', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
reloadAggregate?.on(async (_fields) => { |
|
|
|
reloadAggregate?.on(async (_fields) => { |
|
|
|
if (!_fields || !_fields?.fields.length) { |
|
|
|
if (!_fields || !_fields?.fields.length) { |
|
|
|
await loadViewAggregate() |
|
|
|
await loadViewAggregate() |
|
|
@ -135,6 +162,12 @@ const [useProvideViewAggregate, useViewAggregate] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
acc[f.id] = field.aggregation ?? gridViewCols.value[f.id].aggregation ?? CommonAggregations.None |
|
|
|
acc[f.id] = field.aggregation ?? gridViewCols.value[f.id].aggregation ?? CommonAggregations.None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const formulaField of aggregateFormulaFields.value) { |
|
|
|
|
|
|
|
if (!acc[formulaField.id!] && formulaField.formula_raw.includes(field.title)) { |
|
|
|
|
|
|
|
acc[formulaField.id!] = formulaField.aggregation |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return acc |
|
|
|
return acc |
|
|
|
}, {} as Record<string, string>) |
|
|
|
}, {} as Record<string, string>) |
|
|
|
|
|
|
|
|
|
|
|