浏览代码

feat: :sparkles: feat(importação exames) Foi adicionado o aviso para o associado caso tente cadastra datas

Foi adicionado o aviso para o associado caso tente cadastra datas fora da regra do sistema de dois dias de atencedencia!

fase:dev | origin:escopo
kayo henrique 1 周之前
父节点
当前提交
b1b8acfaba

+ 15 - 2
src/components/ApproveAppointmentDialog.vue

@@ -10,7 +10,9 @@
           <DefaultInputDatePicker
             v-model:untreated-date="date"
             :label="$t('common.terms.date')"
-            :rules="[inputRules.required]"
+            :rules="[inputRules.required, inputRules.exactAdvanceDays(ADVANCE_DAYS)]"
+            :hint="$t('agendamento.data_disponivel', { date: allowedDateLabel })"
+            :date-options="allowedDateOptions"
             placeholder="dd/mm/aaaa"
             lazy-rules
           />
@@ -33,9 +35,10 @@
 </template>
 
 <script setup>
-import { ref, useTemplateRef } from "vue";
+import { computed, ref, useTemplateRef } from "vue";
 import { useDialogPluginComponent } from "quasar";
 import { useInputRules } from "src/composables/useInputRules";
+import { addDaysToToday, formatDateBR } from "src/helpers/utils";
 import DefaultInput from "src/components/defaults/DefaultInput.vue";
 import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePicker.vue";
 
@@ -47,6 +50,16 @@ const { inputRules } = useInputRules();
 const formRef = useTemplateRef("formRef");
 const date = ref("");
 const time = ref("");
+const ADVANCE_DAYS = 2;
+
+const allowedDateLabel = computed(() => formatDateBR(addDaysToToday(ADVANCE_DAYS)));
+const allowedDateOptions = computed(() => {
+  const allowedDate = addDaysToToday(ADVANCE_DAYS);
+  const month = String(allowedDate.getMonth() + 1).padStart(2, "0");
+  const day = String(allowedDate.getDate()).padStart(2, "0");
+
+  return [`${allowedDate.getFullYear()}/${month}/${day}`];
+});
 
 const onConfirm = async () => {
   const valid = await formRef.value?.validate();

+ 7 - 1
src/pages/parceiros-convenios/components/NovaGuiaExameForm.vue

@@ -55,6 +55,8 @@
       <DefaultInputDatePicker
         v-model:untreated-date="form.date"
         :label="$t('agendamento.data_opcional')"
+        :rules="[optionalExactAdvanceDaysRule]"
+        :hint="$t('agendamento.data_disponivel', { date: allowedDateLabel })"
         :date-options="allowedDateOptions"
         placeholder="dd/mm/aaaa"
         class="col-12 col-md-6"
@@ -99,7 +101,7 @@
 import { ref, computed, onMounted, nextTick } from "vue";
 import { createPartnerExam } from "src/api/appointment";
 import { getMyPartnerAgreement } from "src/api/partnerAgreement";
-import { formatToBRLCurrency, addDaysToToday } from "src/helpers/utils";
+import { formatToBRLCurrency, addDaysToToday, formatDateBR } from "src/helpers/utils";
 import { useInputRules } from "src/composables/useInputRules";
 import DefaultInput from "src/components/defaults/DefaultInput.vue";
 import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePicker.vue";
@@ -117,6 +119,7 @@ const partnerAgreementId = ref(null);
 
 const ADVANCE_DAYS = 2;
 
+const allowedDateLabel = computed(() => formatDateBR(addDaysToToday(ADVANCE_DAYS)));
 const allowedDateOptions = computed(() => {
   const date = addDaysToToday(ADVANCE_DAYS);
   const month = String(date.getMonth() + 1).padStart(2, "0");
@@ -124,6 +127,9 @@ const allowedDateOptions = computed(() => {
   return [`${date.getFullYear()}/${month}/${day}`];
 });
 
+const optionalExactAdvanceDaysRule = (value) =>
+  !value || inputRules.exactAdvanceDays(ADVANCE_DAYS)(value);
+
 const emptyForm = () => ({
   associado: null,
   forDependent: false,