fix: updateOption values and type AppSelect
parent
6d9ccbc57a
commit
4ba95b3e88
|
|
@ -32,12 +32,12 @@ const status = [
|
||||||
const selectedType = ref()
|
const selectedType = ref()
|
||||||
|
|
||||||
const type = [
|
const type = [
|
||||||
'Delivery Order',
|
{ id: 'PICKUP', title: 'Pickup Order' },
|
||||||
'Pickup Order',
|
{ id: 'DELIVERY', title: 'Delivery Order' },
|
||||||
'Retail Pickup Order',
|
{ id: 'SHIPTOSTORE', title: 'Ship-to-Store Order' },
|
||||||
'Ship-for-Pickup Order',
|
{ id: 'RETAILPICKUP', title: 'Retail Pickup Order' },
|
||||||
'Ship-to-Store Order',
|
{ id: 'SHIPFORPICKUP', title: 'Ship-for-Pickup Order' },
|
||||||
'unknown transaction type',
|
{ id: 'UNKNOWN', title: 'unknown transaction type' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
|
|
@ -45,19 +45,9 @@ const searchQuery = ref('')
|
||||||
// Data table options
|
// Data table options
|
||||||
const itemsPerPage = ref(10)
|
const itemsPerPage = ref(10)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const sortBy = ref('meta.id')
|
const sortBy = ref('request_id')
|
||||||
const orderBy = ref('desc')
|
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 sortByMapping = (sortby: string) => {
|
||||||
const headerMapping: { [key: string]: string } = {
|
const headerMapping: { [key: string]: string } = {
|
||||||
'meta.id': 'request_id',
|
'meta.id': 'request_id',
|
||||||
|
|
@ -70,19 +60,31 @@ const sortByMapping = (sortby: string) => {
|
||||||
return headerMapping[sortby] || sortby
|
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<any>(createUrl('/obi/order',
|
const { data: ordersData } = await useApi<any>(createUrl('/obi/order',
|
||||||
{
|
{
|
||||||
query: {
|
query: {
|
||||||
q: searchQuery,
|
q: searchQuery,
|
||||||
page,
|
page,
|
||||||
itemsPerPage,
|
itemsPerPage,
|
||||||
sortBy: sortByMapping(sortBy.value),
|
sortBy,
|
||||||
orderBy,
|
orderBy,
|
||||||
|
status: selectedStatus,
|
||||||
|
type: selectedType,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
||||||
const widgetData = ref(ordersData.value.statistics)
|
const widgetData = computed(() => ordersData.value.statistics)
|
||||||
const orders = computed(() => ordersData.value.orders)
|
const orders = computed(() => ordersData.value.orders)
|
||||||
const totalOrder = computed(() => ordersData.value.total)
|
const totalOrder = computed(() => ordersData.value.total)
|
||||||
|
|
||||||
|
|
@ -198,6 +200,8 @@ const formattedEndDate = computed(() => format(new Date(dateRange.value[1]), 'dd
|
||||||
:items="type"
|
:items="type"
|
||||||
clearable
|
clearable
|
||||||
clear-icon="tabler-x"
|
clear-icon="tabler-x"
|
||||||
|
item-text="title"
|
||||||
|
item-value="id"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue