fix: variables affectation
parent
d7df6793b7
commit
59cb81177a
|
|
@ -19,47 +19,49 @@ const selectedCountry = ref()
|
||||||
const selectedBrand = ref()
|
const selectedBrand = ref()
|
||||||
const selectedNbPos = ref()
|
const selectedNbPos = ref()
|
||||||
|
|
||||||
|
// for reload process
|
||||||
const storesList = ref<any>('')
|
const storesList = ref<any>('')
|
||||||
|
const isLoading = ref(false)
|
||||||
|
|
||||||
const searchQuery = ref<any>('')
|
const searchQuery = ref<any>('')
|
||||||
|
|
||||||
// Data table options
|
// Data table options
|
||||||
const { data: storesListData } = await useApi<any>(createUrl('/stores'))
|
const { data: dtListData } = await useApi<any>(createUrl('/stores'))
|
||||||
const isLoading = ref(false)
|
|
||||||
|
|
||||||
storesList.value = storesListData.value
|
storesList.value = dtListData.value
|
||||||
|
|
||||||
const options = ref({ page: 1, itemsPerPage: 10, sortBy: [''], sortDesc: [false] })
|
const options = ref({ page: 1, itemsPerPage: 10, sortBy: [''], sortDesc: [false] })
|
||||||
|
|
||||||
const brand = computed(() => {
|
const country = computed(() => {
|
||||||
const allBrands = storesList.value.map((store: { enseigne: any }) => store.enseigne)
|
const allItems = storesList.value.map((store: { pays: any }) => store.pays)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
const uniqueBrands = allBrands.filter((brand: any, index: any, self: string | any[]) => self.indexOf(brand) === index)
|
const uniqueItems = allItems.filter((country: any, index: any, self: string | any[]) => self.indexOf(country) === index)
|
||||||
const sortedBrands = uniqueBrands.sort()
|
const sortedItems = uniqueItems.sort()
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
return sortedBrands.map((brand: any) => ({ title: brand, value: brand }))
|
return sortedItems.map((country: any) => ({ title: country, value: country }))
|
||||||
})
|
})
|
||||||
|
|
||||||
const country = computed(() => {
|
const brand = computed(() => {
|
||||||
const allCountries = storesList.value.map((store: { pays: any }) => store.pays)
|
const allItems = storesList.value.map((store: { enseigne: any }) => store.enseigne)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
const uniqueCountries = allCountries.filter((country: any, index: any, self: string | any[]) => self.indexOf(country) === index)
|
const uniqueItems = allItems.filter((brand: any, index: any, self: string | any[]) => self.indexOf(brand) === index)
|
||||||
const sortedCountries = uniqueCountries.sort()
|
const sortedItems = uniqueItems.sort()
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
return sortedCountries.map((country: any) => ({ title: country, value: country }))
|
return sortedItems.map((brand: any) => ({ title: brand, value: brand }))
|
||||||
})
|
})
|
||||||
|
|
||||||
const nbPos = computed(() => {
|
const nbPos = computed(() => {
|
||||||
const allNbPos = storesList.value.map((store: { nbcaisses: number }) => store.nbcaisses)
|
const allItems = storesList.value.map((store: { nbcaisses: number }) => store.nbcaisses)
|
||||||
const uniqueNbPos = Array.from(new Set(allNbPos)) as number[] // Utilisez une assertion de type
|
const uniqueItems = Array.from(new Set(allItems)) as number[] // Utilisez une assertion de type
|
||||||
const sortedNbPos = uniqueNbPos.sort((a, b) => a - b) // Triez les nombres en ordre croissant
|
const sortedItems = uniqueItems.sort((a, b) => a - b) // Triez les nombres en ordre croissant
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
return sortedNbPos.map((nbPos: number) => ({ title: nbPos, value: nbPos }))
|
return sortedItems.map((nbPos: number) => ({ title: nbPos, value: nbPos }))
|
||||||
})
|
})
|
||||||
|
|
||||||
const filteredStoresList = computed(() => {
|
const filteredData = computed(() => {
|
||||||
let filtered = storesList.value
|
let filtered = storesList.value
|
||||||
|
|
||||||
// If a brand is selected, filter the records for this brand
|
// If a brand is selected, filter the records for this brand
|
||||||
|
|
@ -212,7 +214,7 @@ const reloadStores = async () => {
|
||||||
<VDataTable
|
<VDataTable
|
||||||
v-else
|
v-else
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:items="filteredStoresList"
|
:items="filteredData"
|
||||||
:items-per-page="options.itemsPerPage"
|
:items-per-page="options.itemsPerPage"
|
||||||
:page="options.page"
|
:page="options.page"
|
||||||
:options="options"
|
:options="options"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue