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