CategoryList.vue
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template>
<v-container>
<div height="100" class="pa-2">
<v-row>
<div class="tw-pr-0 tw-font-bold tw-w-[95px] tw-h-[36px] tw-leading-[36px]">Category:</div>
<v-col class="pa-0">
<v-btn
v-for="(item, index) in categoryStore.list"
:key="index"
variant="text"
@click="handleCategoryClick(item)"
:color="
categoryStore.selectedCategory === item.categoryDisplayName ? 'blue-accent-2' : ''
"
>
{{ item.categoryDisplayName }}
</v-btn>
</v-col>
</v-row>
<v-row>
<div class="tw-pr-0 tw-font-bold tw-w-[95px] tw-h-[36px] tw-leading-[36px]"></div>
<v-col class="pa-0">
<v-divider></v-divider>
<v-btn
v-for="(item, index) in subCategoryList"
:key="index"
variant="text"
@click="handleSubCategoryClick(item.id)"
:color="categoryStore.selectedSubCategory === item.id ? 'blue-accent-2' : ''"
>
{{ item.name }}
</v-btn>
</v-col>
</v-row>
<v-row v-if="funcCategoryList.length">
<div class="tw-pr-0 tw-font-bold tw-w-[95px] tw-h-[36px] tw-leading-[36px]"></div>
<v-col class="pa-0">
<v-divider></v-divider>
<v-btn
v-for="(item, index) in funcCategoryList"
:key="index"
variant="text"
@click="handleFuncCategoryClick(item.id)"
:color="categoryStore.selectedFuncCategory === item.id ? 'blue-accent-2' : ''"
>
{{ item.name }}
</v-btn>
</v-col>
</v-row>
</div>
</v-container>
</template>
<script setup lang="ts">
import { useCategoryStore } from '@/stores/category'
import type { CategoryRootType } from '@/type'
import { computed } from 'vue'
const categoryStore = useCategoryStore()
const handleCategoryClick = (item: CategoryRootType) => {
categoryStore.updateCategory(item.categoryDisplayName)
categoryStore.updateSubCategory(item.list[0].id)
}
const handleSubCategoryClick = (value: string) => {
categoryStore.updateSubCategory(value)
}
const handleFuncCategoryClick = (value: string) => {
categoryStore.updateFuncCategory(value)
}
const subCategoryList = computed(() => {
if (categoryStore.selectedCategory) {
const tmp = categoryStore.list.filter(
(item) => item.categoryDisplayName === categoryStore.selectedCategory
)
return tmp?.[0]?.list || []
}
return []
})
const funcCategoryList = computed(() => {
if (categoryStore.selectedCategory) {
const tmp = categoryStore.list.filter(
(item) => item.categoryDisplayName === categoryStore.selectedCategory
)
return tmp?.[0]?.productFunctions || []
}
return []
})
</script>