From 4ba95b3e88129c219fc5938d39aaa2a5f90126d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20BENOIST?= Date: Fri, 19 Jan 2024 00:09:59 +0100 Subject: [PATCH] fix: updateOption values and type AppSelect --- src/pages/obi/order/list/index.vue | 42 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/pages/obi/order/list/index.vue b/src/pages/obi/order/list/index.vue index 6e8f3a8..eca945b 100644 --- a/src/pages/obi/order/list/index.vue +++ b/src/pages/obi/order/list/index.vue @@ -32,12 +32,12 @@ const status = [ const selectedType = ref() const type = [ - 'Delivery Order', - 'Pickup Order', - 'Retail Pickup Order', - 'Ship-for-Pickup Order', - 'Ship-to-Store Order', - 'unknown transaction type', + { id: 'PICKUP', title: 'Pickup Order' }, + { id: 'DELIVERY', title: 'Delivery Order' }, + { id: 'SHIPTOSTORE', title: 'Ship-to-Store Order' }, + { id: 'RETAILPICKUP', title: 'Retail Pickup Order' }, + { id: 'SHIPFORPICKUP', title: 'Ship-for-Pickup Order' }, + { id: 'UNKNOWN', title: 'unknown transaction type' }, ] const searchQuery = ref('') @@ -45,19 +45,9 @@ const searchQuery = ref('') // Data table options const itemsPerPage = ref(10) const page = ref(1) -const sortBy = ref('meta.id') +const sortBy = ref('request_id') const orderBy = ref('desc') -const updateOptions = (options: any) => { - page.value = options.page - - // updateOptions was called systematically by VDataTableServer with an empty object - if (options.sortBy[0]?.key) { - sortBy.value = options.sortBy[0].key - orderBy.value = options.sortBy[0].order - } -} - const sortByMapping = (sortby: string) => { const headerMapping: { [key: string]: string } = { 'meta.id': 'request_id', @@ -70,19 +60,31 @@ const sortByMapping = (sortby: string) => { return headerMapping[sortby] || sortby } +const updateOptions = (options: any) => { + page.value = options.page + + // updateOptions was called systematically by VDataTableServer with an empty object + if (options.sortBy[0]?.key) { + sortBy.value = sortByMapping(options.sortBy[0].key) + orderBy.value = options.sortBy[0].order + } +} + const { data: ordersData } = await useApi(createUrl('/obi/order', { query: { q: searchQuery, page, itemsPerPage, - sortBy: sortByMapping(sortBy.value), + sortBy, orderBy, + status: selectedStatus, + type: selectedType, }, }, )) -const widgetData = ref(ordersData.value.statistics) +const widgetData = computed(() => ordersData.value.statistics) const orders = computed(() => ordersData.value.orders) const totalOrder = computed(() => ordersData.value.total) @@ -198,6 +200,8 @@ const formattedEndDate = computed(() => format(new Date(dateRange.value[1]), 'dd :items="type" clearable clear-icon="tabler-x" + item-text="title" + item-value="id" />