|
|
@ -211,9 +211,11 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const filterJSON = computed(() => { |
|
|
|
const filterJSON = computed(() => { |
|
|
|
if (!meta.value?.columns || !calendarRange.value || !calendarRange.value[0]) return [] |
|
|
|
const combinedFilters = { |
|
|
|
const fromCol = calendarRange.value[0].fk_from_col |
|
|
|
is_group: true, |
|
|
|
const toCol = calendarRange.value[0].fk_to_col |
|
|
|
logical_op: 'and', |
|
|
|
|
|
|
|
children: [], |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let fromDate |
|
|
|
let fromDate |
|
|
|
let toDate |
|
|
|
let toDate |
|
|
@ -231,99 +233,117 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
fromDate = dayjs(selectedDate.value).startOf('year').format('YYYY-MM-DD') |
|
|
|
fromDate = dayjs(selectedDate.value).startOf('year').format('YYYY-MM-DD') |
|
|
|
toDate = dayjs(selectedDate.value).endOf('year').format('YYYY-MM-DD') |
|
|
|
toDate = dayjs(selectedDate.value).endOf('year').format('YYYY-MM-DD') |
|
|
|
} |
|
|
|
} |
|
|
|
if (fromCol && toCol) { |
|
|
|
|
|
|
|
return [ |
|
|
|
calendarRange.value.forEach((range) => { |
|
|
|
{ |
|
|
|
const fromCol = range.fk_from_col |
|
|
|
is_group: true, |
|
|
|
const toCol = range.fk_to_col |
|
|
|
logical_op: 'and', |
|
|
|
let rangeFilter = [] |
|
|
|
children: [ |
|
|
|
|
|
|
|
{ |
|
|
|
if (fromCol && toCol) { |
|
|
|
is_group: true, |
|
|
|
rangeFilter = [ |
|
|
|
logical_op: 'or', |
|
|
|
{ |
|
|
|
children: [ |
|
|
|
is_group: true, |
|
|
|
{ |
|
|
|
logical_op: 'and', |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
children: [ |
|
|
|
comparison_op: 'btw', |
|
|
|
{ |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
is_group: true, |
|
|
|
value: `${fromDate},${toDate}`, |
|
|
|
logical_op: 'or', |
|
|
|
}, |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
fk_column_id: toCol.id, |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
comparison_op: 'btw', |
|
|
|
comparison_op: 'btw', |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
value: `${fromDate},${toDate}`, |
|
|
|
value: `${fromDate},${toDate}`, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
{ |
|
|
|
}, |
|
|
|
fk_column_id: toCol.id, |
|
|
|
{ |
|
|
|
comparison_op: 'btw', |
|
|
|
is_group: true, |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
logical_op: 'or', |
|
|
|
value: `${fromDate},${toDate}`, |
|
|
|
children: [ |
|
|
|
}, |
|
|
|
{ |
|
|
|
], |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
}, |
|
|
|
comparison_op: 'lte', |
|
|
|
{ |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
is_group: true, |
|
|
|
value: fromDate, |
|
|
|
logical_op: 'or', |
|
|
|
}, |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
fk_column_id: toCol.id, |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
comparison_op: 'gte', |
|
|
|
comparison_op: 'lte', |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
value: toDate, |
|
|
|
value: fromDate, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
{ |
|
|
|
}, |
|
|
|
fk_column_id: toCol.id, |
|
|
|
{ |
|
|
|
comparison_op: 'gte', |
|
|
|
is_group: true, |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
logical_op: 'or', |
|
|
|
value: toDate, |
|
|
|
children: [ |
|
|
|
}, |
|
|
|
{ |
|
|
|
], |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
}, |
|
|
|
comparison_op: 'gte', |
|
|
|
{ |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
is_group: true, |
|
|
|
value: fromDate, |
|
|
|
logical_op: 'or', |
|
|
|
}, |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
fk_column_id: toCol.id, |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
comparison_op: 'lte', |
|
|
|
comparison_op: 'gte', |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
value: toDate, |
|
|
|
value: fromDate, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
{ |
|
|
|
}, |
|
|
|
fk_column_id: toCol.id, |
|
|
|
], |
|
|
|
comparison_op: 'lte', |
|
|
|
}, |
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
{ |
|
|
|
value: toDate, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
is_group: true, |
|
|
|
|
|
|
|
logical_op: 'or', |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: fromCol.id, |
|
|
|
|
|
|
|
comparison_op: 'eq', |
|
|
|
|
|
|
|
logical_op: 'or', |
|
|
|
|
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
|
|
|
|
value: fromDate, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: toCol.id, |
|
|
|
|
|
|
|
comparison_op: 'eq', |
|
|
|
|
|
|
|
logical_op: 'or', |
|
|
|
|
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
|
|
|
|
value: toDate, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} else if (fromCol) { |
|
|
|
|
|
|
|
rangeFilter = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: fromCol.id, |
|
|
|
|
|
|
|
comparison_op: 'btw', |
|
|
|
|
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
|
|
|
|
value: `${fromDate},${toDate}`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (rangeFilter.length > 0) { |
|
|
|
|
|
|
|
combinedFilters.children.push({ |
|
|
|
is_group: true, |
|
|
|
is_group: true, |
|
|
|
logical_op: 'or', |
|
|
|
logical_op: 'or', |
|
|
|
children: [ |
|
|
|
children: rangeFilter, |
|
|
|
{ |
|
|
|
}) |
|
|
|
fk_column_id: fromCol.id, |
|
|
|
} |
|
|
|
comparison_op: 'eq', |
|
|
|
}) |
|
|
|
logical_op: 'or', |
|
|
|
|
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
console.log('combinedFilters', combinedFilters) |
|
|
|
value: fromDate, |
|
|
|
|
|
|
|
}, |
|
|
|
return combinedFilters.children.length > 0 ? [combinedFilters] : [] |
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: toCol.id, |
|
|
|
|
|
|
|
comparison_op: 'eq', |
|
|
|
|
|
|
|
logical_op: 'or', |
|
|
|
|
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
|
|
|
|
value: toDate, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} else if (fromCol) { |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: fromCol.id, |
|
|
|
|
|
|
|
comparison_op: 'btw', |
|
|
|
|
|
|
|
comparison_sub_op: 'exactDate', |
|
|
|
|
|
|
|
value: `${fromDate},${toDate}`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} else return [] |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// Set of Dates that have data
|
|
|
|
// Set of Dates that have data
|
|
|
|