@@ -5,6 +5,8 @@ const emits = defineEmits<{
55 ' device-select' : [string ],
66}>();
77
8+ const { lab } = useLab ();
9+
810const searchText = ref (' ' );
911const { isActive : isDropdownActive, setInactive } = useClick (useTemplateRef (' dropdown' ));
1012
@@ -17,7 +19,7 @@ watch(searchText, async () => {
1719 searchItems .value = [];
1820 return ;
1921 }
20- const data = await deviceKindService .getDeviceKinds ( 0 , numberOfSearchItemsShown , { searchText: searchText .value || undefined , searchFields: [' device_name' , ' device_id' ] });
22+ const data = await deviceKindService .getDeviceKindsByLabId ( lab . value . id , 0 , numberOfSearchItemsShown , { searchText: searchText .value || undefined , searchFields: [' device_name' , ' device_id' ] });
2123 searchItems .value = data .deviceKinds .map (({ name , mainImage , id }) => ({ id , name , image: mainImage }));
2224});
2325function focusNextSearchItem () {
@@ -41,18 +43,26 @@ function unfocusSearchItem () {
4143 <div ref =" dropdown" class =" relative" >
4244 <div class =" relative" >
4345 <input
44- v-model =" searchText"
46+ v-model =" searchText"
4547 class =" bg-white text-primary-light placeholder:text-primary-light border-2 h-11 w-[100%] pl-10 pr-3 rounded-md text-md placeholder:text-normal"
46- type =" search" placeholder =" Tên/Mã loại thiết bị" @keydown.down =" focusNextSearchItem" @keydown.up =" focusPrevSearchItem" @keydown.enter =" focusedSearchItemIndex !== null && goToSearchItem(searchItems[focusedSearchItemIndex!].id)" @keydown.esc =" unfocusSearchItem" >
48+ type =" search" placeholder =" Tên/Mã loại thiết bị" @keydown.down =" focusNextSearchItem"
49+ @keydown.up =" focusPrevSearchItem"
50+ @keydown.enter =" focusedSearchItemIndex !== null && goToSearchItem(searchItems[focusedSearchItemIndex!].id)"
51+ @keydown.esc =" unfocusSearchItem" >
4752 <Icon
48- aria-hidden class =" absolute left-3 top-[12px] text-xl text-primary-dark"
53+ aria-hidden class =" absolute left-3 top-[12px] text-xl text-primary-dark"
4954 name =" i-heroicons-magnifying-glass" />
5055 </div >
5156
52- <div :class =" `${isDropdownActive && searchItems.length ? 'flex' : 'hidden'} flex-col gap-1 absolute bg-white p-1 mt-1 w-[120%] z-50 shadow-[0_0px_16px_-3px_rgba(0,0,0,0.3)]`" >
53- <a v-for =" (item, index) in searchItems" :key =" item.id" :class =" `px-2 text-normal p-1 flex justify-start gap-2 hover:bg-gray-100 ${focusedSearchItemIndex === index ? 'bg-secondary-light' : ''}`" @click =" goToSearchItem(searchItems[index].id)" >
57+ <div
58+ :class =" `${isDropdownActive && searchItems.length ? 'flex' : 'hidden'} flex-col gap-1 absolute bg-white p-1 mt-1 w-[120%] z-50 shadow-[0_0px_16px_-3px_rgba(0,0,0,0.3)]`" >
59+ <a
60+ v-for =" (item, index) in searchItems" :key =" item.id"
61+ :class =" `px-2 text-normal p-1 flex justify-start gap-2 hover:bg-gray-100 ${focusedSearchItemIndex === index ? 'bg-secondary-light' : ''}`"
62+ @click =" goToSearchItem(searchItems[index].id)" >
5463 <img :src =" item.image" class =" h-6 w-6 block" >
55- <p class =" p-1 px-2 text-nowrap bg-gray-100 border border-gray-300 rounded-md text-normal font-normal leading-none" >
64+ <p
65+ class =" p-1 px-2 text-nowrap bg-gray-100 border border-gray-300 rounded-md text-normal font-normal leading-none" >
5666 {{ item.id.toUpperCase() }}
5767 </p >
5868 <HighlightText class =" line-clamp-1" :text =" item.name" :match-text =" searchText || undefined" />
0 commit comments