feat: enhance AdvanceSearch component to support date range selection and workflow template advance search
This commit is contained in:
parent
d95d72806d
commit
d7e53b764c
3 changed files with 52 additions and 25 deletions
|
|
@ -9,7 +9,7 @@ defineProps<{
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const date = defineModel<Date[]>();
|
const date = defineModel<string[]>();
|
||||||
|
|
||||||
const dateRange = ref<string>('');
|
const dateRange = ref<string>('');
|
||||||
const isDateSelect = ref(false);
|
const isDateSelect = ref(false);
|
||||||
|
|
@ -64,13 +64,14 @@ function mapDateRange(val: string) {
|
||||||
end = today.endOf('day');
|
end = today.endOf('day');
|
||||||
break;
|
break;
|
||||||
case 'customDateRange':
|
case 'customDateRange':
|
||||||
// Do nothing or allow manual date picking
|
start = today.startOf('day');
|
||||||
return;
|
end = today.endOf('day');
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [start.toDate(), end.toDate()];
|
return [start.toDate().toISOString(), end.toDate().toISOString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, reactive, ref, watch } from 'vue';
|
import { onMounted, reactive, ref, watch } from 'vue';
|
||||||
import { QSelect, QTableProps } from 'quasar';
|
import { QTableProps } from 'quasar';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
|
@ -22,6 +22,7 @@ import NoData from 'src/components/NoData.vue';
|
||||||
import KebabAction from 'src/components/shared/KebabAction.vue';
|
import KebabAction from 'src/components/shared/KebabAction.vue';
|
||||||
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
|
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
import AdvanceSearch from 'src/components/shared/AdvanceSearch.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const workflowStore = useWorkflowTemplate();
|
const workflowStore = useWorkflowTemplate();
|
||||||
|
|
@ -45,6 +46,7 @@ const pageState = reactive({
|
||||||
addModal: false,
|
addModal: false,
|
||||||
viewDrawer: false,
|
viewDrawer: false,
|
||||||
isDrawerEdit: true,
|
isDrawerEdit: true,
|
||||||
|
searchDate: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const fieldSelected = ref<('order' | 'name' | 'step')[]>([
|
const fieldSelected = ref<('order' | 'name' | 'step')[]>([
|
||||||
|
|
@ -68,7 +70,6 @@ const fieldSelectedOption = ref<{ label: string; value: string }[]>([
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const refFilter = ref<InstanceType<typeof QSelect>>();
|
|
||||||
const currWorkflowData = ref<WorkflowTemplate>();
|
const currWorkflowData = ref<WorkflowTemplate>();
|
||||||
const formDataWorkflow = ref<WorkflowTemplatePayload>({
|
const formDataWorkflow = ref<WorkflowTemplatePayload>({
|
||||||
status: 'CREATED',
|
status: 'CREATED',
|
||||||
|
|
@ -282,6 +283,8 @@ async function fetchWorkflowList(mobileFetch?: boolean) {
|
||||||
: statusFilter.value === 'statusACTIVE'
|
: statusFilter.value === 'statusACTIVE'
|
||||||
? 'ACTIVE'
|
? 'ACTIVE'
|
||||||
: 'INACTIVE',
|
: 'INACTIVE',
|
||||||
|
startDate: pageState.searchDate[0] || undefined,
|
||||||
|
endDate: pageState.searchDate[1] || undefined,
|
||||||
});
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
workflowData.value =
|
workflowData.value =
|
||||||
|
|
@ -311,11 +314,14 @@ watch(
|
||||||
fetchWorkflowList();
|
fetchWorkflowList();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
watch([() => pageState.inputSearch, workflowPageSize], () => {
|
watch(
|
||||||
workflowData.value = [];
|
[() => pageState.inputSearch, workflowPageSize, () => pageState.searchDate],
|
||||||
workflowPage.value = 1;
|
() => {
|
||||||
fetchWorkflowList();
|
workflowData.value = [];
|
||||||
});
|
workflowPage.value = 1;
|
||||||
|
fetchWorkflowList();
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FloatingActionButton
|
<FloatingActionButton
|
||||||
|
|
@ -392,26 +398,44 @@ watch([() => pageState.inputSearch, workflowPageSize], () => {
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<q-icon name="mdi-magnify" />
|
<q-icon name="mdi-magnify" />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="$q.screen.lt.md" v-slot:append>
|
<template v-slot:append>
|
||||||
<span class="row">
|
<q-separator vertical inset class="q-mr-xs" />
|
||||||
<q-separator vertical />
|
<AdvanceSearch
|
||||||
<q-btn
|
v-model="pageState.searchDate"
|
||||||
icon="mdi-filter-variant"
|
:active="$q.screen.lt.md && statusFilter !== 'all'"
|
||||||
unelevated
|
>
|
||||||
class="q-ml-sm"
|
<div
|
||||||
padding="4px"
|
v-if="$q.screen.lt.md"
|
||||||
size="sm"
|
class="q-mt-sm text-weight-medium"
|
||||||
rounded
|
>
|
||||||
@click="refFilter?.showPopup"
|
{{ $t('general.status') }}
|
||||||
|
</div>
|
||||||
|
<q-select
|
||||||
|
v-if="$q.screen.lt.md"
|
||||||
|
v-model="statusFilter"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
option-value="value"
|
||||||
|
option-label="label"
|
||||||
|
map-options
|
||||||
|
emit-value
|
||||||
|
:for="'field-select-status'"
|
||||||
|
:options="[
|
||||||
|
{ label: $t('general.all'), value: 'all' },
|
||||||
|
{ label: $t('general.active'), value: 'statusACTIVE' },
|
||||||
|
{
|
||||||
|
label: $t('general.inactive'),
|
||||||
|
value: 'statusINACTIVE',
|
||||||
|
},
|
||||||
|
]"
|
||||||
/>
|
/>
|
||||||
</span>
|
</AdvanceSearch>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
<div class="row col-md-5" style="white-space: nowrap">
|
<div class="row col-md-5" style="white-space: nowrap">
|
||||||
<q-select
|
<q-select
|
||||||
v-show="$q.screen.gt.sm"
|
v-if="$q.screen.gt.sm"
|
||||||
ref="refFilter"
|
|
||||||
v-model="statusFilter"
|
v-model="statusFilter"
|
||||||
outlined
|
outlined
|
||||||
dense
|
dense
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ export const useWorkflowTemplate = defineStore('workflow-store', () => {
|
||||||
query?: string;
|
query?: string;
|
||||||
status?: Status;
|
status?: Status;
|
||||||
activeOnly?: boolean;
|
activeOnly?: boolean;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
}) {
|
}) {
|
||||||
const res = await api.get<PaginationResult<WorkflowTemplate>>(
|
const res = await api.get<PaginationResult<WorkflowTemplate>>(
|
||||||
'/workflow-template',
|
'/workflow-template',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue