Files
astra-frontend/src/pages/newCalendar/components/CalendarRecordCard.vue
2023-06-27 17:59:15 +03:00

197 lines
5.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template lang="pug">
.card-wrapper.w-full.flex.gap-y-2px.flex-col
.header.w-full.flex.gap-x-2px.text-sm
.first-item.color-black.justify-center.gap-x-2(:class="timeClass")
span.font-semibold.color-black(v-if="expandedType || expandedTime") {{ recordTime }}
q-icon(
name="arrow_back_ios_new",
size="10px",
v-if="expandedTime",
@click="changeTimeDisplay(false)"
)
q-icon.cursor-pointer(
v-if="!expandedType && !expandedTime",
name="app:time",
size="16px",
@click="changeTimeDisplay(true)"
)
.color-black.pl-4.flex-1.font-semibold.py-6px.relative(
:class="{'pl-6px': expandedTime}"
)
.flex.items-center(
:class="{'collapsed-name': expandedTime}"
) {{trimPatientName(record?.member?.last_name, record?.member?.first_name, record?.member?.patronymic)}}
.gradient.absolute.w-5.h-full.right-0(v-if="expandedTime")
.info-block.justify-center
img.w-5.h-5(:src="recordingStatus?.icon")
.last-item.info-block.justify-center(v-if="expandedType")
img.w-5.h-5(:src="medicalСardStatus?.icon")
.body.background-grey.flex.flex-col.justify-between.pl-4.pr-2.py-10px.color-grey(
:style="bodyHeight",
:class="{'py-6px': collapsedDisplayCondition}"
)
.flex.gap-x-14(:class="bodyClass")
.flex.gap-x-2.items-center(
v-for="contact in contacts",
:key="contact.value",
)
q-icon(:name="contact.icon", size="14px")
.text-xxs {{ contact.value }}
.h-6.w-6.color-black.background-dark-grey.text-xxs.rounded.flex.items-center.justify-center(
v-if="collapsedDisplayCondition"
) +1
span.text-xxs.self-end(v-if="servicesCount && bodyClass?.['flex-col']") {{`${servicesCount} услуги`}}
</template>
<script>
import * as moment from "moment/moment";
import {
recordingStatuses,
medicalСardStatuses,
networks,
} from "@/pages/newCalendar/utils/calendarConfig.js";
import { trimName } from "@/pages/newCalendar/utils/calendarFunctions.js";
export default {
name: "CalendarRecordCard",
props: {
expandedType: Boolean,
record: Object,
},
data() {
return {
pixelsPerHalfHour: 33,
servicesCount: 4,
trimPatientName: trimName,
expandedTime: false,
};
},
computed: {
contacts() {
let contactList = this.record?.member?.contacts
?.filter((elem) => elem.kind === "PHONE" || elem.kind === "EMAIL")
?.map((elem) => ({
kind: elem.kind,
icon: networks.find((item) => item.id === elem.kind)?.icon,
value: elem.value,
}));
if (this.collapsedDisplayCondition) {
contactList.length = 1;
return contactList;
}
return contactList;
},
collapsedDisplayCondition() {
return !this.bodyClass?.["flex-col"] && !this.expandedType;
},
recordingStatus() {
return recordingStatuses.find(
(elem) => elem.value === this.record?.status
);
},
medicalСardStatus() {
return medicalСardStatuses.find(
(elem) => elem.value === this.record?.medicalCard?.status
);
},
startTime() {
return moment.parseZone(this.record?.start);
},
endTime() {
return moment.parseZone(this.record?.end);
},
recordTime() {
return (
this.startTime?.format("HH:mm") + " " + this.endTime?.format("HH:mm")
);
},
recordDuration() {
if (this.endTime.isAfter(this.startTime))
return this.endTime.diff(this.startTime, "minutes");
return null;
},
bodyHeight() {
let halfHourCount = parseInt(this.recordDuration / 30, 10) - 1;
if (halfHourCount)
return {
height: `${36 + 40 * (halfHourCount - 1)}px`,
};
return {
display: "none",
};
},
bodyClass() {
if (parseInt(this.bodyHeight?.height, 10) >= 76)
return {
"flex-col": true,
"gap-y-2": true,
};
return {};
},
timeClass() {
if (this.expandedType)
return {
expanded: true,
};
if (this.expandedTime)
return {
"expanded-time": true,
};
return {
collapsed: true,
};
},
},
methods: {
changeTimeDisplay(value) {
this.expandedTime = value;
},
},
watch: {
expandedType(value) {
if (value) this.expandedTime = false;
},
},
};
</script>
<style lang="sass" scoped>
.header
height: 30px
& > div
background-color: var(--bg-light-grey)
display: flex
align-items: center
.first-item
border-top-left-radius: 4px
border-bottom-left-radius: 4px
.expanded
width: 130px
.collapsed
width: 30px
.collapsed-name
width: 30px
overflow: hidden
white-space: nowrap
.gradient
background: linear-gradient(270deg, #EFF1F4 0%, rgba(239, 241, 244, 0.00) 100%)
.expanded-time
width: 138px
.last-item
border-top-right-radius: 4px
border-bottom-right-radius: 4px
.background-grey
background-color: var(--bg-light-grey)
.background-dark-grey
background-color: var(--border-light-grey-color)
.color-black
color: var(--font-dark-blue-color)
.color-grey
color: var(--font-dark-blue-color-0)
.info-block
width: 30px
height: 30px
.body
border-bottom-left-radius: 4px
border-bottom-right-radius: 4px
</style>