From b622f9cca7dfc9bf7b4bb0b2948e4a7f9ca0156a Mon Sep 17 00:00:00 2001 From: Kevin Martinez Date: Thu, 4 Jan 2024 02:27:43 -0400 Subject: [PATCH] Add order orderBy filter --- src/pages/Order/Card/OrderCatalogFilter.vue | 50 +++++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue index 00606d57c..09e243959 100644 --- a/src/pages/Order/Card/OrderCatalogFilter.vue +++ b/src/pages/Order/Card/OrderCatalogFilter.vue @@ -31,6 +31,12 @@ const resetCategory = () => { typeList.value = null; }; +const selectedOrder = ref(null); +const orderList = [ + { way: 'ASC', name: 'Ascendant' }, + { way: 'DESC', name: 'Descendant' }, +]; + const clearFilter = (key) => { if (key === 'categoryFk') { resetCategory(); @@ -64,6 +70,10 @@ const onFilterInit = async ({ params }) => { await loadTypes(params.categoryFk); selectedCategoryFk.value = params.categoryFk; } + if (params.orderBy) { + selectedOrder.value = JSON.parse(params.orderBy).way; + orderByParam.value = JSON.parse(params.orderBy); + } }; const selectedCategory = computed(() => @@ -104,6 +114,14 @@ const applyTagFilter = (params, search) => { }); search(); }; + +const orderByParam = ref(null); + +const onOrderChange = (value, params, search) => { + const orderBy = Object.assign({}, orderByParam.value, { way: value.way }); + params.orderBy = JSON.stringify(orderBy); + search(); +};