|
@@ -25,6 +25,18 @@
|
|
|
<q-card v-else flat class="form-card">
|
|
<q-card v-else flat class="form-card">
|
|
|
<q-card-section>
|
|
<q-card-section>
|
|
|
<q-form ref="appointmentFormRef" class="form-column" @submit="submitAppointment">
|
|
<q-form ref="appointmentFormRef" class="form-column" @submit="submitAppointment">
|
|
|
|
|
+ <q-checkbox
|
|
|
|
|
+ v-model="forDependent"
|
|
|
|
|
+ color="violet-normal"
|
|
|
|
|
+ :label="$t('agendamento.for_dependent_self')"
|
|
|
|
|
+ />
|
|
|
|
|
+ <DependenteSelect
|
|
|
|
|
+ v-if="forDependent"
|
|
|
|
|
+ v-model="selectedDependent"
|
|
|
|
|
+ :user-id="user.user?.id ?? null"
|
|
|
|
|
+ :rules="[inputRules.required]"
|
|
|
|
|
+ class="input-violet"
|
|
|
|
|
+ />
|
|
|
<PartnerAgreementSelect
|
|
<PartnerAgreementSelect
|
|
|
v-model="selectedPartner"
|
|
v-model="selectedPartner"
|
|
|
:label="$t('ui.navigation.convenios')"
|
|
:label="$t('ui.navigation.convenios')"
|
|
@@ -99,6 +111,12 @@
|
|
|
<span class="apmt-card__value">{{ apt.partner_agreement_service?.name || '—' }}</span>
|
|
<span class="apmt-card__value">{{ apt.partner_agreement_service?.name || '—' }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+ <div v-if="apt.user_dependent" class="apmt-card__row">
|
|
|
|
|
+ <q-icon name="mdi-account-child-outline" size="15px" class="apmt-card__icon" />
|
|
|
|
|
+ <span class="apmt-card__label">{{ $t('associado.dependent') }}:</span>
|
|
|
|
|
+ <span class="apmt-card__value">{{ apt.user_dependent.name }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<div class="apmt-card__row">
|
|
<div class="apmt-card__row">
|
|
|
<q-icon name="mdi-calendar-clock-outline" size="15px" class="apmt-card__icon" />
|
|
<q-icon name="mdi-calendar-clock-outline" size="15px" class="apmt-card__icon" />
|
|
|
<span class="apmt-card__value">{{ formatDateTime(apt.date, apt.time) }}</span>
|
|
<span class="apmt-card__value">{{ formatDateTime(apt.date, apt.time) }}</span>
|
|
@@ -110,8 +128,9 @@
|
|
|
<span class="apmt-card__value">{{ formatDate(apt.created_at) }}</span>
|
|
<span class="apmt-card__value">{{ formatDate(apt.created_at) }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div v-if="apt.status === 'pendente'" class="apmt-card__actions">
|
|
|
|
|
|
|
+ <div v-if="apt.status === 'pendente' || apt.can_issue_guide" class="apmt-card__actions">
|
|
|
<q-btn
|
|
<q-btn
|
|
|
|
|
+ v-if="apt.status === 'pendente'"
|
|
|
dense
|
|
dense
|
|
|
flat
|
|
flat
|
|
|
icon="mdi-pencil-outline"
|
|
icon="mdi-pencil-outline"
|
|
@@ -120,6 +139,17 @@
|
|
|
:label="$t('common.actions.edit')"
|
|
:label="$t('common.actions.edit')"
|
|
|
@click="onEditAppointment(apt)"
|
|
@click="onEditAppointment(apt)"
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <q-btn
|
|
|
|
|
+ v-if="apt.can_issue_guide"
|
|
|
|
|
+ dense
|
|
|
|
|
+ flat
|
|
|
|
|
+ icon="mdi-file-document-outline"
|
|
|
|
|
+ color="violet-normal"
|
|
|
|
|
+ size="sm"
|
|
|
|
|
+ :label="$t('agendamento.guia')"
|
|
|
|
|
+ :loading="guideId === apt.id"
|
|
|
|
|
+ @click="onDownloadGuide(apt)"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -144,11 +174,17 @@
|
|
|
import { ref, reactive, computed, watch, useTemplateRef } from "vue";
|
|
import { ref, reactive, computed, watch, useTemplateRef } from "vue";
|
|
|
import { useQuasar } from "quasar";
|
|
import { useQuasar } from "quasar";
|
|
|
import { useI18n } from "vue-i18n";
|
|
import { useI18n } from "vue-i18n";
|
|
|
-import { createAppointment, getMyAppointments, updateAppointment } from "src/api/appointment";
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ createAppointment,
|
|
|
|
|
+ getMyAppointments,
|
|
|
|
|
+ updateAppointment,
|
|
|
|
|
+ downloadMyAppointmentGuide,
|
|
|
|
|
+} from "src/api/appointment";
|
|
|
import { useInputRules } from "src/composables/useInputRules";
|
|
import { useInputRules } from "src/composables/useInputRules";
|
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
|
import PartnerAgreementSelect from "src/components/selects/PartnerAgreementSelect.vue";
|
|
import PartnerAgreementSelect from "src/components/selects/PartnerAgreementSelect.vue";
|
|
|
|
|
+import DependenteSelect from "src/components/selects/DependenteSelect.vue";
|
|
|
import PartnerAgreementServiceSelect from "src/components/selects/PartnerAgreementServiceSelect.vue";
|
|
import PartnerAgreementServiceSelect from "src/components/selects/PartnerAgreementServiceSelect.vue";
|
|
|
import { userStore } from "src/stores/user";
|
|
import { userStore } from "src/stores/user";
|
|
|
|
|
|
|
@@ -172,8 +208,15 @@ const tabs = computed(() => [
|
|
|
{ name: "meus", label: t("associado.my_appointments") },
|
|
{ name: "meus", label: t("associado.my_appointments") },
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
|
|
+const forDependent = ref(false);
|
|
|
|
|
+const selectedDependent = ref(null);
|
|
|
const selectedPartner = ref(null);
|
|
const selectedPartner = ref(null);
|
|
|
const selectedService = ref(null);
|
|
const selectedService = ref(null);
|
|
|
|
|
+const guideId = ref(null);
|
|
|
|
|
+
|
|
|
|
|
+watch(forDependent, (value) => {
|
|
|
|
|
+ if (!value) selectedDependent.value = null;
|
|
|
|
|
+});
|
|
|
const appointmentForm = reactive({ observations: "" });
|
|
const appointmentForm = reactive({ observations: "" });
|
|
|
const submitting = ref(false);
|
|
const submitting = ref(false);
|
|
|
const editingId = ref(null);
|
|
const editingId = ref(null);
|
|
@@ -224,6 +267,8 @@ watch(activeTab, (val) => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const resetForm = () => {
|
|
const resetForm = () => {
|
|
|
|
|
+ forDependent.value = false;
|
|
|
|
|
+ selectedDependent.value = null;
|
|
|
selectedPartner.value = null;
|
|
selectedPartner.value = null;
|
|
|
selectedService.value = null;
|
|
selectedService.value = null;
|
|
|
appointmentForm.observations = "";
|
|
appointmentForm.observations = "";
|
|
@@ -237,6 +282,7 @@ const submitAppointment = async () => {
|
|
|
const payload = {
|
|
const payload = {
|
|
|
partner_agreement_id: selectedPartner.value.value,
|
|
partner_agreement_id: selectedPartner.value.value,
|
|
|
partner_agreement_service_id: selectedService.value.value,
|
|
partner_agreement_service_id: selectedService.value.value,
|
|
|
|
|
+ user_dependent_id: selectedDependent.value?.value ?? null,
|
|
|
observations: appointmentForm.observations,
|
|
observations: appointmentForm.observations,
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|
|
@@ -256,8 +302,24 @@ const submitAppointment = async () => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const onDownloadGuide = async (apt) => {
|
|
|
|
|
+ if (!apt.can_issue_guide) return;
|
|
|
|
|
+ guideId.value = apt.id;
|
|
|
|
|
+ try {
|
|
|
|
|
+ await downloadMyAppointmentGuide(apt.id, apt.order_number);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ $q.notify({ type: "negative", message: e?.message || t("http.errors.failed") });
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ guideId.value = null;
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const onEditAppointment = (apt) => {
|
|
const onEditAppointment = (apt) => {
|
|
|
editingId.value = apt.id;
|
|
editingId.value = apt.id;
|
|
|
|
|
+ forDependent.value = !!apt.user_dependent_id;
|
|
|
|
|
+ selectedDependent.value = apt.user_dependent_id
|
|
|
|
|
+ ? { value: apt.user_dependent_id, label: apt.user_dependent?.name || "" }
|
|
|
|
|
+ : null;
|
|
|
selectedPartner.value = { value: apt.partner_agreement_id, label: apt.partner_agreement?.trade_name || apt.partner_agreement?.company_name || "" };
|
|
selectedPartner.value = { value: apt.partner_agreement_id, label: apt.partner_agreement?.trade_name || apt.partner_agreement?.company_name || "" };
|
|
|
selectedService.value = { value: apt.partner_agreement_service_id, label: apt.partner_agreement_service?.name || "" };
|
|
selectedService.value = { value: apt.partner_agreement_service_id, label: apt.partner_agreement_service?.name || "" };
|
|
|
appointmentForm.observations = apt.observations ?? "";
|
|
appointmentForm.observations = apt.observations ?? "";
|