WIP Сделала фильтрацию

This commit is contained in:
Daria Golova
2023-07-27 16:54:16 +03:00
parent b49559ba5e
commit efd1f97041
4 changed files with 281 additions and 161 deletions

View File

@@ -1,17 +1,37 @@
<template lang="pug">
.header-wrapper.flex.w-full.justify-between.p-4
.flex.items-center.justify-center.gap-x-2
base-input.search(
:width="438",
base-select.search(
width="438px",
size="M",
placeholder="Найти медкарту",
iconLeft
icon-left,
hide-dropdown-icon,
use-input
:items="filteringMedcardsList",
custom-option,
:filter-fn="filterFn",
:popup-content-style="{height: filteringMedcardsList?.length > 3 ? '216px' : ''}"
)
template(v-slot:iconLeft)
q-icon.search-icon(name="app:search", size="20px")
template(v-slot:customOption="slotProps")
.w-full.item.px-4.py-2.flex.gap-x-3.cursor-pointer(
v-bind="slotProps.props"
)
q-avatar(size="40px")
img(:src="slotProps.avatar")
.flex.flex-col.gap-y-1
.text-dark.text-sm.font-medium {{ slotProps.label }}
.text-xsx.grey-color Медкарта {{ `#${slotProps.medcard?.split(" ")?.join("")}` }}
template(v-slot:beforeOptions)
.h-10.w-full.px-4.pt-3.pb-2.flex.items-center
span.text-sm.grey-color {{ filteringMedcardsList.length }} результатов
template(v-slot:noOption)
.w-full.px-4.py-3.flex.items-center.text-sm.grey-color.font-medium Результатов по запросу не найдено
base-select(
width="280px",
:items="items",
:items="sortingOptions",
size="M",
placeholder="Сортировать по ...",
v-model="sortingType"
@@ -25,40 +45,48 @@
import BaseInput from "@/components/base/BaseInput.vue";
import BaseSelect from "@/components/base/BaseSelect.vue";
import BaseButton from "@/components/base/BaseButton.vue";
import {
medcardsList,
sortingOptions,
} from "@/pages/medcards/utils/medcardsConfig.js";
export default {
name: "MedicalCardSearchHeader",
components: { BaseInput, BaseSelect, BaseButton },
data() {
return {
items: [
{
label: "ФИО",
id: "name",
},
{
label: "приоритету",
id: "priority",
},
{
label: "дате рождения",
id: "birthDate",
},
{
label: "номеру медкарты",
id: "medcardNumber",
},
{
label: "проценту заполнения",
id: "percent",
},
{
label: "дате создания медкарты",
id: "creationDate",
},
],
filteringMedcardsList: null,
sortingOptions: sortingOptions,
sortingType: null,
};
},
computed: {
serializedMedcardsList() {
return medcardsList.map((elem) => ({
label: `${elem?.last_name} ${elem?.first_name} ${elem?.patronymic}`,
id: elem?.id,
avatar: elem?.avatar,
medcard: elem?.medcard,
}));
},
},
methods: {
filterFn(val, update) {
update(() => {
this.filteringMedcardsList = this.serializedMedcardsList?.filter(
(elem) => {
let reg = new RegExp(`^${val}`, "ig");
if (reg.test(elem.label)) return elem;
}
);
});
},
initializeMedcardsList() {
this.filteringMedcardsList = this.serializedMedcardsList;
},
},
mounted() {
this.initializeMedcardsList();
},
};
</script>
@@ -75,4 +103,17 @@ export default {
.plus :deep(path)
fill: var(--default-white)
.grey-color
color: var(--font-grey-color)
.item
border-bottom: 1px solid var(--gray-secondary)
&:last-child
border-bottom: none
&:hover
background-color: var(--gray-thirdly)
span
cursor: default
</style>