Merge branch 'ASTRA-70' into 'master'

WIP Сделала сортировку

See merge request andrusyakka/urban-couscous!346
This commit is contained in:
Daria Golova
2023-05-03 14:09:39 +00:00
3 changed files with 82 additions and 22 deletions

View File

@@ -14,7 +14,8 @@
dense, dense,
:behavior="behavior", :behavior="behavior",
emit-value, emit-value,
map-options map-options,
:clearable="clearable"
) )
template(v-slot:selected) template(v-slot:selected)
span(v-if="!value?.icon") {{ textSelect }} span(v-if="!value?.icon") {{ textSelect }}
@@ -76,13 +77,9 @@ export default {
label: String, label: String,
readonly: Boolean, readonly: Boolean,
width: String, width: String,
clearable: Boolean,
}, },
emits: ["update:modelValue"], emits: ["update:modelValue"],
data() {
return {
open: false,
};
},
computed: { computed: {
value: { value: {
get() { get() {
@@ -93,6 +90,7 @@ export default {
}, },
}, },
textSelect() { textSelect() {
if (typeof this.modelValue === "string") return this.value;
return this.value?.label ? this.value.label : this.placeholder; return this.value?.label ? this.value.label : this.placeholder;
}, },
iconSelect() { iconSelect() {
@@ -102,6 +100,8 @@ export default {
}; };
</script> </script>
<style lang="sass"> <style lang="sass">
.q-menu
font-feature-settings: 'pnum' on, 'lnum' on !important
.q-btn--outline:before, .q-field--outlined .q-field__control:before .q-btn--outline:before, .q-field--outlined .q-field__control:before
border-width: 1px !important border-width: 1px !important
.q-field__marginal .q-field__marginal

View File

@@ -6,7 +6,7 @@
.text-smm.color-grey.flex.items-center.gap-x-6px.line-height .text-smm.color-grey.flex.items-center.gap-x-6px.line-height
span.align-middle {{ protocolDate?.dayMonth }} span.align-middle {{ protocolDate?.dayMonth }}
.rounded-full.h-1.w-1.background-grey .rounded-full.h-1.w-1.background-grey
span.align-middle {{ `${protocolData?.start_time} - ${protocolData?.end_time}` }} span.align-middle {{ `${time?.start} - ${time?.end}` }}
.flex.items-center.justify-center.h-6.w-6.rounded( .flex.items-center.justify-center.h-6.w-6.rounded(
:style="statusСolors" :style="statusСolors"
) )
@@ -66,7 +66,8 @@ export default {
} }
}, },
protocolDate() { protocolDate() {
let date = moment(this.protocolData?.date) let date = moment
.parseZone(this.protocolData?.start)
.format("DD.MM.YYYY") .format("DD.MM.YYYY")
.split("."); .split(".");
return { return {
@@ -74,6 +75,12 @@ export default {
dayMonth: date[0] + "." + date[1], dayMonth: date[0] + "." + date[1],
}; };
}, },
time() {
return {
start: moment.parseZone(this.protocolData?.start).format("HH:mm"),
end: moment.parseZone(this.protocolData?.end).format("HH:mm"),
};
},
}, },
}; };
</script> </script>

View File

@@ -14,6 +14,9 @@
.flex .flex
base-select( base-select(
:style="{flex: 1}", :style="{flex: 1}",
:items="sortingYears",
v-model="sortingYear",
clearable
) )
q-btn.ml-2( q-btn.ml-2(
icon="app:sort-number", icon="app:sort-number",
@@ -23,10 +26,10 @@
@click="invertSorting" @click="invertSorting"
) )
.flex.py-4.w-full.color-grey.text-base.justify-center .flex.py-4.w-full.color-grey.text-base.justify-center
span.opacity-50 Осмотров: 5 span.opacity-50 {{ `Осмотров: ${protocolsData?.length}` }}
.flex.flex-col.gap-y-2 .flex.flex-col.gap-y-2
medical-protocol-card( medical-protocol-card(
v-for="protocol in protocolsData", :key="protocol.id", v-for="protocol in sortingProtocols", :key="protocol.id",
:protocol-data="protocol", :protocol-data="protocol",
@click="openInspection" @click="openInspection"
) )
@@ -43,6 +46,7 @@ export default {
data() { data() {
return { return {
sorting: false, sorting: false,
sortingYear: "",
activeProtocolId: 1, activeProtocolId: 1,
protocolsData: [ protocolsData: [
{ {
@@ -54,9 +58,8 @@ export default {
job_title: "Хирург", job_title: "Хирург",
photo: "", photo: "",
}, },
date: "2023-04-20", start: "2023-03-23T13:00:00+03:00",
start_time: "18:30", end: "2023-03-23T13:40:00+03:00",
end_time: "19:00",
status: "filled", status: "filled",
}, },
{ {
@@ -68,9 +71,8 @@ export default {
job_title: "Терапевт", job_title: "Терапевт",
photo: "", photo: "",
}, },
date: "2077-03-20", start: "2023-04-11T18:00:00+03:00",
start_time: "15:30", end: "2023-04-11T18:30:00+03:00",
end_time: "16:00",
status: "partially filled", status: "partially filled",
}, },
{ {
@@ -82,9 +84,8 @@ export default {
job_title: "Хирург", job_title: "Хирург",
photo: "", photo: "",
}, },
date: "2023-02-15", start: "2021-08-23T10:00:00+03:00",
start_time: "18:30", end: "2021-08-23T13:00:00+03:00",
end_time: "19:00",
status: "filled", status: "filled",
}, },
{ {
@@ -96,11 +97,23 @@ export default {
job_title: "Ортодонт", job_title: "Ортодонт",
photo: "", photo: "",
}, },
date: "2023-05-21", start: "2023-05-23T14:10:00+03:00",
start_time: "13:30", end: "2023-05-23T15:10:00+03:00",
end_time: "15:00",
status: "", status: "",
}, },
{
id: 5,
employee: {
last_name: "Захаров",
first_name: "Алексей",
patronymic: "Сергеевич",
job_title: "Хирург",
photo: "",
},
start: "2022-01-23T13:10:00+03:00",
end: "2022-01-23T13:30:00+03:00",
status: "filled",
},
], ],
}; };
}, },
@@ -114,6 +127,46 @@ export default {
"sort-icon-default": true, "sort-icon-default": true,
}; };
}, },
sortingYears() {
let years = this.protocolsData
.map((elem) => {
return elem?.start.slice(0, 4);
})
.sort((first, second) => first - second);
return [...new Set(years)];
},
sortingProtocols() {
let protocols = [];
this.protocolsData.forEach((elem) =>
protocols.push({
id: elem.id,
employee: {
last_name: elem.employee?.last_name,
first_name: elem.employee?.first_name,
patronymic: elem.employee?.patronymic,
job_title: elem.employee?.job_title,
photo: elem.employee?.photo,
},
start: elem.start,
end: elem.end,
status: elem.status,
})
);
if (this.sortingYear) {
protocols = protocols.filter(
(elem) => elem.start.slice(0, 4) === this.sortingYear
);
}
let sorted = protocols.sort((first, second) => {
let firstDate = first?.start.split("T")[0];
let secondDate = second?.start.split("T")[0];
if (firstDate > secondDate) return 1;
if (firstDate < secondDate) return -1;
return 0;
});
if (this.sorting) return sorted;
return sorted.reverse();
},
}, },
methods: { methods: {
invertSorting() { invertSorting() {