v-sistec-features 1.31.11 → 1.31.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v-sistec-features.css +1 -1
- package/dist/vDataAgenda.d.ts +595 -18
- package/dist/vDataAgenda.js +3638 -2753
- package/package.json +1 -1
- package/src/DataAgenda/VDataAgenda.vue +167 -182
- package/src/DataAgenda/components/AgendaMatrix.vue +30 -19
- package/src/DataAgenda/components/AgendaMatrixBase.vue +392 -264
- package/src/DataAgenda/components/AgendaMatrixUnico.vue +21 -29
- package/src/DataAgenda/components/AgendaTabelaHorario.vue +506 -0
- package/src/DataAgenda/components/AgendaVueCal.vue +118 -199
- package/src/DataAgenda/components/BlocoArrastavel.vue +62 -0
- package/src/DataAgenda/components/HeaderTabela.vue +13 -4
- package/src/DataAgenda/components/ModalReserva.vue +268 -133
- package/src/DataAgenda/composables/useAgenda.ts +13 -0
- package/src/DataAgenda/composables/useCoresAgenda.ts +40 -0
- package/src/DataAgenda/composables/useGradeCompartilhada.ts +216 -0
- package/src/DataAgenda/composables/useSelecaoArrasto.ts +167 -0
- package/src/DataAgenda/components/AgendaMatrixAntigo.vue +0 -403
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
========
|
|
3
3
|
Este arquivo representa o componente de modal para criação e edição de reservas em uma agenda.
|
|
4
4
|
Ele gerencia o formulário de reserva, valida a disponibilidade de horários baseando-se na grade
|
|
5
|
-
do recurso selecionado,
|
|
5
|
+
do recurso selecionado, permite ativar repetição semanal até uma data limite, disponibiliza slots
|
|
6
|
+
individuais para cada seção do formulário e salva os dados na API.
|
|
6
7
|
========
|
|
7
8
|
-->
|
|
8
9
|
<script setup lang="ts">
|
|
9
|
-
import { ref, watch, inject } from 'vue';
|
|
10
|
+
import { ref, computed, watch, inject } from 'vue';
|
|
10
11
|
import { useAgenda } from '../composables/useAgenda';
|
|
12
|
+
import { criarDataLocal } from '../composables/useGradeCompartilhada';
|
|
11
13
|
|
|
12
14
|
const api = inject('api-instance-agenda') as any;
|
|
13
15
|
const props = defineProps({
|
|
@@ -21,64 +23,100 @@ const emit = defineEmits(['update:modelValue', 'salvo', 'cancelado', 'before-sav
|
|
|
21
23
|
|
|
22
24
|
const {
|
|
23
25
|
minutosInicio, minutosFim, recursosDisponiveis, agendasDisponiveis,
|
|
24
|
-
criarReserva, converterParaUtc, reservasBrutas
|
|
26
|
+
criarReserva, criarReservaRecorrente, converterParaUtc, reservasBrutas
|
|
25
27
|
} = useAgenda(api);
|
|
26
28
|
|
|
27
|
-
// Indica se o formulário está em processo de salvamento na API.
|
|
28
29
|
const salvando = ref(false);
|
|
29
|
-
|
|
30
|
-
// Indica se o usuário alterou manualmente algum horário e precisa revalidar contra a grade.
|
|
31
30
|
const precisaValidar = ref(false);
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const mostrarAjusteHorario = ref(false);
|
|
32
|
+
const repetirReserva = ref(false);
|
|
34
33
|
const exibirHorariosModal = ref(false);
|
|
35
|
-
|
|
36
|
-
// Armazena as strings de blocos disponíveis para exibição ao usuário.
|
|
37
34
|
const horariosDisponiveisFormatados = ref<string[]>([]);
|
|
38
35
|
|
|
39
|
-
// Armazena o estado dos campos do formulário do modal.
|
|
40
36
|
const formReserva = ref({
|
|
41
37
|
id_recurso: '',
|
|
42
38
|
titulo_reserva: '',
|
|
43
39
|
data_inicio: '',
|
|
44
40
|
hora_inicio: '',
|
|
45
41
|
data_fim: '',
|
|
46
|
-
hora_fim: ''
|
|
42
|
+
hora_fim: '',
|
|
43
|
+
data_limite_repeticao: ''
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const dataInicioLocal = computed(() => {
|
|
47
|
+
if (!formReserva.value.data_inicio || formReserva.value.data_inicio.split('-').length !== 3) return null;
|
|
48
|
+
const dt = criarDataLocal(formReserva.value.data_inicio);
|
|
49
|
+
return isNaN(dt.getTime()) ? null : dt;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const textoDiaSelecionado = computed(() => {
|
|
53
|
+
if (!dataInicioLocal.value) return formReserva.value.data_inicio || 'Data não definida';
|
|
54
|
+
const diaSemana = dataInicioLocal.value.toLocaleDateString('pt-BR', { weekday: 'long' });
|
|
55
|
+
const diaSemanaCap = diaSemana.charAt(0).toUpperCase() + diaSemana.slice(1);
|
|
56
|
+
const dataBr = dataInicioLocal.value.toLocaleDateString('pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
|
57
|
+
return `${diaSemanaCap}, ${dataBr}`;
|
|
47
58
|
});
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
const nomeDiaSemana = computed(() => {
|
|
61
|
+
return dataInicioLocal.value ? dataInicioLocal.value.toLocaleDateString('pt-BR', { weekday: 'long' }) : 'semana';
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const textoIntervaloHorario = computed(() => {
|
|
65
|
+
return `Das ${formReserva.value.hora_inicio || '--:--'} até as ${formReserva.value.hora_fim || '--:--'}`;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const alternarAjusteHorario = () => { mostrarAjusteHorario.value = !mostrarAjusteHorario.value; };
|
|
69
|
+
const definirRepetirReserva = (valor: boolean) => { repetirReserva.value = valor; };
|
|
70
|
+
|
|
50
71
|
const marcarComoAlterado = () => {
|
|
72
|
+
if (formReserva.value.data_inicio) {
|
|
73
|
+
formReserva.value.data_fim = formReserva.value.data_inicio;
|
|
74
|
+
if (formReserva.value.data_limite_repeticao && formReserva.value.data_limite_repeticao < formReserva.value.data_inicio) {
|
|
75
|
+
formReserva.value.data_limite_repeticao = formReserva.value.data_inicio;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
51
78
|
precisaValidar.value = true;
|
|
52
79
|
};
|
|
53
80
|
|
|
54
|
-
|
|
81
|
+
const converterHoraParaMinutos = (horaStr: string) => {
|
|
82
|
+
const [h, m] = horaStr.split(':').map(Number) as [number, number];
|
|
83
|
+
return h * 60 + m;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Localiza e ordena os períodos reserváveis do dia selecionado na agenda vinculada ao recurso.
|
|
87
|
+
const obterPeriodosReservaveisDoDia = () => {
|
|
88
|
+
if (!formReserva.value.id_recurso || !dataInicioLocal.value) return null;
|
|
89
|
+
|
|
90
|
+
const recurso = recursosDisponiveis.value.find((r: any) => Number(r.id_recurso) === Number(formReserva.value.id_recurso));
|
|
91
|
+
const agenda = agendasDisponiveis.value.find((a: any) => Number(a.id_agenda) === Number(recurso?.id_agenda));
|
|
92
|
+
const periodosAgenda = agenda?.detalhes?.periodos_agenda;
|
|
93
|
+
if (!periodosAgenda) return null;
|
|
94
|
+
|
|
95
|
+
const diaDaSemanaPython = (dataInicioLocal.value.getDay() + 6) % 7;
|
|
96
|
+
const periodosDoDia = periodosAgenda[diaDaSemanaPython] || [];
|
|
97
|
+
|
|
98
|
+
return periodosDoDia
|
|
99
|
+
.filter((s: any) => s.reservavel_periodo)
|
|
100
|
+
.map((s: any) => ({
|
|
101
|
+
...s,
|
|
102
|
+
inicioMin: converterHoraParaMinutos(s.hora_inicio_periodo),
|
|
103
|
+
fimMin: converterHoraParaMinutos(s.hora_fim_periodo)
|
|
104
|
+
}))
|
|
105
|
+
.sort((a: any, b: any) => a.inicioMin - b.inicioMin);
|
|
106
|
+
};
|
|
107
|
+
|
|
55
108
|
const mostrarHorariosPossiveis = () => {
|
|
56
109
|
if (!formReserva.value.id_recurso || !formReserva.value.data_inicio) {
|
|
57
110
|
alert("Selecione um recurso e uma data para ver os horários possíveis.");
|
|
58
111
|
return;
|
|
59
112
|
}
|
|
60
113
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const agenda = agendasDisponiveis.value.find((a: any) => Number(a.id_agenda) === Number(idAg));
|
|
64
|
-
|
|
65
|
-
if (!agenda || !agenda.detalhes || !agenda.detalhes.periodos_agenda) {
|
|
114
|
+
const slotsReservaveis = obterPeriodosReservaveisDoDia();
|
|
115
|
+
if (!slotsReservaveis) {
|
|
66
116
|
alert("Nenhuma grade de horários encontrada.");
|
|
67
117
|
return;
|
|
68
118
|
}
|
|
69
119
|
|
|
70
|
-
const inicioDate = new Date(`${formReserva.value.data_inicio}T00:00:00`);
|
|
71
|
-
const diaDaSemanaPython = (inicioDate.getDay() + 6) % 7;
|
|
72
|
-
const periodosDoDia = agenda.detalhes.periodos_agenda[diaDaSemanaPython] || [];
|
|
73
|
-
|
|
74
|
-
const slotsReservaveis = periodosDoDia
|
|
75
|
-
.filter((s: any) => s.reservavel_periodo)
|
|
76
|
-
.sort((a: any, b: any) => {
|
|
77
|
-
const [hA, mA] = a.hora_inicio_periodo.split(':').map(Number) as [number, number];
|
|
78
|
-
const [hB, mB] = b.hora_inicio_periodo.split(':').map(Number) as [number, number];
|
|
79
|
-
return (hA * 60 + mA) - (hB * 60 + mB);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
120
|
if (slotsReservaveis.length === 0) {
|
|
83
121
|
alert("Nenhum horário disponível para este dia na grade.");
|
|
84
122
|
return;
|
|
@@ -88,56 +126,32 @@ const mostrarHorariosPossiveis = () => {
|
|
|
88
126
|
exibirHorariosModal.value = true;
|
|
89
127
|
};
|
|
90
128
|
|
|
91
|
-
// Ajusta os horários de início e fim informados para que englobem o bloco reservável completo da agenda.
|
|
92
129
|
const ajustarHorarios = (silencioso = false) => {
|
|
93
130
|
if (!formReserva.value.id_recurso || !formReserva.value.data_inicio || !formReserva.value.hora_inicio || !formReserva.value.hora_fim) return;
|
|
94
131
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const agenda = agendasDisponiveis.value.find((a: any) => Number(a.id_agenda) === Number(idAg));
|
|
98
|
-
|
|
99
|
-
if (!agenda || !agenda.detalhes || !agenda.detalhes.periodos_agenda) return;
|
|
100
|
-
|
|
101
|
-
const inicioDate = new Date(`${formReserva.value.data_inicio}T00:00:00`);
|
|
102
|
-
const diaDaSemanaPython = (inicioDate.getDay() + 6) % 7;
|
|
103
|
-
const periodosDoDia = agenda.detalhes.periodos_agenda[diaDaSemanaPython] || [];
|
|
104
|
-
|
|
105
|
-
const slotsReservaveis = periodosDoDia
|
|
106
|
-
.filter((s: any) => s.reservavel_periodo)
|
|
107
|
-
.map((s: any) => {
|
|
108
|
-
const [hI, mI] = s.hora_inicio_periodo.split(':').map(Number) as [number, number];
|
|
109
|
-
const [hF, mF] = s.hora_fim_periodo.split(':').map(Number) as [number, number];
|
|
110
|
-
return { inicio: hI * 60 + mI, fim: hF * 60 + mF };
|
|
111
|
-
})
|
|
112
|
-
.sort((a: any, b: any) => a.inicio - b.inicio);
|
|
132
|
+
const slotsReservaveis = obterPeriodosReservaveisDoDia();
|
|
133
|
+
if (!slotsReservaveis) return;
|
|
113
134
|
|
|
114
135
|
if (slotsReservaveis.length === 0) {
|
|
115
136
|
if (!silencioso) alert("Nenhum horário disponível para este dia na grade.");
|
|
116
137
|
return;
|
|
117
138
|
}
|
|
118
139
|
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const minInicio = hI * 60 + mI;
|
|
122
|
-
const minFim = hF * 60 + mF;
|
|
123
|
-
|
|
124
|
-
let blocoInicio = [...slotsReservaveis].reverse().find(b => b.inicio <= minInicio);
|
|
125
|
-
if (!blocoInicio) blocoInicio = slotsReservaveis[0];
|
|
126
|
-
const novoInicioMin = blocoInicio.inicio;
|
|
140
|
+
const minInicio = converterHoraParaMinutos(formReserva.value.hora_inicio);
|
|
141
|
+
const minFim = converterHoraParaMinutos(formReserva.value.hora_fim);
|
|
127
142
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
const invertidos = [...slotsReservaveis].reverse();
|
|
144
|
+
const blocoInicio = invertidos.find(b => b.inicioMin <= minInicio) || slotsReservaveis[0];
|
|
145
|
+
const blocoFim = invertidos.find(b => b.inicioMin < minFim) || slotsReservaveis[0];
|
|
131
146
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
147
|
+
const novoInicioMin = blocoInicio.inicioMin;
|
|
148
|
+
const novoFimMin = blocoFim.fimMin <= novoInicioMin ? blocoInicio.fimMin : blocoFim.fimMin;
|
|
135
149
|
|
|
136
150
|
const formatarMin = (m: number) => `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
|
|
137
151
|
|
|
138
152
|
formReserva.value.hora_inicio = formatarMin(novoInicioMin);
|
|
139
153
|
formReserva.value.hora_fim = formatarMin(novoFimMin);
|
|
140
|
-
|
|
154
|
+
formReserva.value.data_fim = formReserva.value.data_inicio;
|
|
141
155
|
precisaValidar.value = false;
|
|
142
156
|
|
|
143
157
|
if (!silencioso) {
|
|
@@ -147,30 +161,39 @@ const ajustarHorarios = (silencioso = false) => {
|
|
|
147
161
|
|
|
148
162
|
watch(() => props.modelValue, (aberto) => {
|
|
149
163
|
if (aberto && props.dadosIniciais) {
|
|
164
|
+
const dataIni = props.dadosIniciais.data_inicio ?? '';
|
|
150
165
|
formReserva.value = {
|
|
151
166
|
id_recurso: props.dadosIniciais.id_recurso ?? '',
|
|
152
167
|
titulo_reserva: props.dadosIniciais.titulo_reserva ?? '',
|
|
153
|
-
data_inicio:
|
|
168
|
+
data_inicio: dataIni,
|
|
154
169
|
hora_inicio: props.dadosIniciais.hora_inicio ?? '',
|
|
155
|
-
data_fim: props.dadosIniciais.data_fim
|
|
156
|
-
hora_fim: props.dadosIniciais.hora_fim ?? ''
|
|
170
|
+
data_fim: props.dadosIniciais.data_fim || dataIni,
|
|
171
|
+
hora_fim: props.dadosIniciais.hora_fim ?? '',
|
|
172
|
+
data_limite_repeticao: dataIni
|
|
157
173
|
};
|
|
158
174
|
precisaValidar.value = false;
|
|
175
|
+
mostrarAjusteHorario.value = false;
|
|
176
|
+
repetirReserva.value = false;
|
|
159
177
|
exibirHorariosModal.value = false;
|
|
160
178
|
ajustarHorarios(true);
|
|
161
179
|
}
|
|
162
180
|
});
|
|
163
181
|
|
|
164
|
-
// Emite os eventos para fechar o modal.
|
|
165
182
|
const fecharModal = () => {
|
|
166
183
|
emit('update:modelValue', false);
|
|
167
184
|
emit('cancelado');
|
|
168
185
|
};
|
|
169
186
|
|
|
170
|
-
// Envia o payload de criação para a API e trata possíveis erros HTTP retornados pelo backend.
|
|
171
187
|
const executarCriacaoAPI = async (payloadParaEnviar: any) => {
|
|
172
188
|
try {
|
|
173
|
-
|
|
189
|
+
if (repetirReserva.value) {
|
|
190
|
+
await criarReservaRecorrente({
|
|
191
|
+
...payloadParaEnviar,
|
|
192
|
+
data_limite_repeticao: formReserva.value.data_limite_repeticao
|
|
193
|
+
});
|
|
194
|
+
} else {
|
|
195
|
+
await criarReserva(payloadParaEnviar);
|
|
196
|
+
}
|
|
174
197
|
emit('salvo');
|
|
175
198
|
emit('update:modelValue', false);
|
|
176
199
|
} catch (erro: any) {
|
|
@@ -185,10 +208,11 @@ const executarCriacaoAPI = async (payloadParaEnviar: any) => {
|
|
|
185
208
|
}
|
|
186
209
|
};
|
|
187
210
|
|
|
188
|
-
// Valida os campos, checa colisões locais e dispara a gravação da reserva com o contrato em português.
|
|
189
211
|
const salvarReserva = async () => {
|
|
190
212
|
if (precisaValidar.value) return;
|
|
191
213
|
|
|
214
|
+
formReserva.value.data_fim = formReserva.value.data_inicio;
|
|
215
|
+
|
|
192
216
|
const inicioNovaReserva = new Date(`${formReserva.value.data_inicio}T${formReserva.value.hora_inicio}`);
|
|
193
217
|
const fimNovaReserva = new Date(`${formReserva.value.data_fim}T${formReserva.value.hora_fim}`);
|
|
194
218
|
|
|
@@ -205,6 +229,17 @@ const salvarReserva = async () => {
|
|
|
205
229
|
return;
|
|
206
230
|
}
|
|
207
231
|
|
|
232
|
+
if (repetirReserva.value) {
|
|
233
|
+
if (!formReserva.value.data_limite_repeticao) {
|
|
234
|
+
alert("Informe a data final para a repetição do agendamento.");
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (formReserva.value.data_limite_repeticao < formReserva.value.data_inicio) {
|
|
238
|
+
alert("A data final da repetição deve ser igual ou posterior à data inicial do agendamento.");
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
208
243
|
const conflito = reservasBrutas.value.some((reserva: any) => {
|
|
209
244
|
if (Number(reserva.id_recurso) !== Number(formReserva.value.id_recurso)) return false;
|
|
210
245
|
const inicioEvento = new Date(reserva.data_inicio_reserva);
|
|
@@ -219,25 +254,27 @@ const salvarReserva = async () => {
|
|
|
219
254
|
|
|
220
255
|
salvando.value = true;
|
|
221
256
|
|
|
222
|
-
const payloadBase = {
|
|
257
|
+
const payloadBase: any = {
|
|
223
258
|
id_recurso: Number(formReserva.value.id_recurso),
|
|
224
259
|
titulo_reserva: formReserva.value.titulo_reserva.trim(),
|
|
225
260
|
data_inicio_reserva: converterParaUtc(formReserva.value.data_inicio, formReserva.value.hora_inicio),
|
|
226
261
|
data_fim_reserva: converterParaUtc(formReserva.value.data_fim, formReserva.value.hora_fim)
|
|
227
262
|
};
|
|
228
263
|
|
|
264
|
+
if (repetirReserva.value) {
|
|
265
|
+
payloadBase.data_limite_repeticao = formReserva.value.data_limite_repeticao;
|
|
266
|
+
}
|
|
267
|
+
|
|
229
268
|
if (props.usaInterceptador) {
|
|
230
269
|
emit('before-save', {
|
|
231
|
-
payloadBase
|
|
232
|
-
dadosReserva: { ...formReserva.value },
|
|
270
|
+
payloadBase,
|
|
271
|
+
dadosReserva: { ...formReserva.value, repetir_reserva: repetirReserva.value },
|
|
233
272
|
proceed: (novoPayloadModificado: any) => {
|
|
234
273
|
executarCriacaoAPI(novoPayloadModificado || payloadBase);
|
|
235
274
|
},
|
|
236
275
|
abort: (callbackAcaoCustomizada?: Function) => {
|
|
237
276
|
salvando.value = false;
|
|
238
|
-
if (typeof callbackAcaoCustomizada === 'function')
|
|
239
|
-
callbackAcaoCustomizada();
|
|
240
|
-
}
|
|
277
|
+
if (typeof callbackAcaoCustomizada === 'function') callbackAcaoCustomizada();
|
|
241
278
|
}
|
|
242
279
|
});
|
|
243
280
|
} else {
|
|
@@ -255,40 +292,134 @@ const salvarReserva = async () => {
|
|
|
255
292
|
</div>
|
|
256
293
|
|
|
257
294
|
<div class="modal-body">
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
295
|
+
<slot
|
|
296
|
+
name="topo-modal"
|
|
297
|
+
:dados-reserva="formReserva"
|
|
298
|
+
:texto-dia-selecionado="textoDiaSelecionado"
|
|
299
|
+
:texto-intervalo-horario="textoIntervaloHorario"
|
|
300
|
+
></slot>
|
|
301
|
+
|
|
302
|
+
<slot
|
|
303
|
+
name="visualizacao-dados"
|
|
304
|
+
:dados-reserva="formReserva"
|
|
305
|
+
:recursos-disponiveis="recursosDisponiveis"
|
|
306
|
+
:texto-dia-selecionado="textoDiaSelecionado"
|
|
307
|
+
:texto-intervalo-horario="textoIntervaloHorario"
|
|
308
|
+
:nome-dia-semana="nomeDiaSemana"
|
|
309
|
+
:repetir-reserva="repetirReserva"
|
|
310
|
+
:definir-repetir-reserva="definirRepetirReserva"
|
|
311
|
+
:mostrar-ajuste-horario="mostrarAjusteHorario"
|
|
312
|
+
:alternar-ajuste-horario="alternarAjusteHorario"
|
|
313
|
+
:precisa-validar="precisaValidar"
|
|
314
|
+
:marcar-como-alterado="marcarComoAlterado"
|
|
315
|
+
:ajustar-horarios="ajustarHorarios"
|
|
316
|
+
>
|
|
317
|
+
<slot
|
|
318
|
+
name="campo-nome"
|
|
319
|
+
:dados-reserva="formReserva"
|
|
320
|
+
:recursos-disponiveis="recursosDisponiveis"
|
|
321
|
+
:ocultar-titulo-modal="props.ocultarTituloModal"
|
|
322
|
+
>
|
|
323
|
+
<div class="form-group" v-if="!props.ocultarTituloModal">
|
|
324
|
+
<label>Nome da Reserva (opcional)</label>
|
|
325
|
+
<input type="text" v-model="formReserva.titulo_reserva" placeholder="Ex: Treinamento" autofocus />
|
|
326
|
+
</div>
|
|
271
327
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
328
|
+
<div class="form-group">
|
|
329
|
+
<label>Calendário / Recurso</label>
|
|
330
|
+
<select v-model="formReserva.id_recurso" disabled>
|
|
331
|
+
<option v-for="rec in recursosDisponiveis" :key="rec.id_recurso" :value="rec.id_recurso">
|
|
332
|
+
{{ rec.nome_recurso }}
|
|
333
|
+
</option>
|
|
334
|
+
</select>
|
|
335
|
+
</div>
|
|
336
|
+
</slot>
|
|
337
|
+
|
|
338
|
+
<slot
|
|
339
|
+
name="campo-horario"
|
|
340
|
+
:dados-reserva="formReserva"
|
|
341
|
+
:texto-dia-selecionado="textoDiaSelecionado"
|
|
342
|
+
:texto-intervalo-horario="textoIntervaloHorario"
|
|
343
|
+
:mostrar-ajuste-horario="mostrarAjusteHorario"
|
|
344
|
+
:alternar-ajuste-horario="alternarAjusteHorario"
|
|
345
|
+
:precisa-validar="precisaValidar"
|
|
346
|
+
:marcar-como-alterado="marcarComoAlterado"
|
|
347
|
+
:ajustar-horarios="ajustarHorarios"
|
|
348
|
+
>
|
|
349
|
+
<div class="resumo-horario-box">
|
|
350
|
+
<div class="resumo-horario-textos">
|
|
351
|
+
<span class="resumo-label">Período selecionado</span>
|
|
352
|
+
<div class="resumo-dia">{{ textoDiaSelecionado }}</div>
|
|
353
|
+
<div class="resumo-horas">{{ textoIntervaloHorario }}</div>
|
|
354
|
+
</div>
|
|
355
|
+
|
|
356
|
+
<button
|
|
357
|
+
type="button"
|
|
358
|
+
class="btn-toggle-ajuste"
|
|
359
|
+
@click="alternarAjusteHorario"
|
|
360
|
+
>
|
|
361
|
+
{{ mostrarAjusteHorario ? 'Ocultar ajuste' : 'Ajustar horário' }}
|
|
362
|
+
</button>
|
|
278
363
|
</div>
|
|
279
|
-
</div>
|
|
280
364
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
365
|
+
<div class="painel-ajuste-horario" v-if="mostrarAjusteHorario">
|
|
366
|
+
<div class="form-group">
|
|
367
|
+
<label>Data do Agendamento</label>
|
|
368
|
+
<input type="date" v-model="formReserva.data_inicio" @input="marcarComoAlterado" />
|
|
369
|
+
</div>
|
|
370
|
+
|
|
371
|
+
<div class="form-row-lado-a-lado">
|
|
372
|
+
<div class="form-group metade">
|
|
373
|
+
<label>Início</label>
|
|
374
|
+
<input type="time" v-model="formReserva.hora_inicio" @input="marcarComoAlterado" />
|
|
375
|
+
</div>
|
|
376
|
+
|
|
377
|
+
<div class="form-group metade">
|
|
378
|
+
<label>Fim</label>
|
|
379
|
+
<input type="time" v-model="formReserva.hora_fim" @input="marcarComoAlterado" />
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
286
382
|
</div>
|
|
287
|
-
</
|
|
288
|
-
|
|
383
|
+
</slot>
|
|
384
|
+
|
|
385
|
+
<slot
|
|
386
|
+
name="campo-recorrencia"
|
|
387
|
+
:dados-reserva="formReserva"
|
|
388
|
+
:repetir-reserva="repetirReserva"
|
|
389
|
+
:definir-repetir-reserva="definirRepetirReserva"
|
|
390
|
+
:nome-dia-semana="nomeDiaSemana"
|
|
391
|
+
>
|
|
392
|
+
<div class="recorrencia-box">
|
|
393
|
+
<label class="recorrencia-toggle">
|
|
394
|
+
<input type="checkbox" v-model="repetirReserva" />
|
|
395
|
+
<span class="recorrencia-titulo">Repetir agendamento semanalmente</span>
|
|
396
|
+
</label>
|
|
397
|
+
|
|
398
|
+
<div class="recorrencia-detalhes" v-if="repetirReserva">
|
|
399
|
+
<div class="form-group">
|
|
400
|
+
<label>Repetir até o dia:</label>
|
|
401
|
+
<input
|
|
402
|
+
type="date"
|
|
403
|
+
v-model="formReserva.data_limite_repeticao"
|
|
404
|
+
:min="formReserva.data_inicio"
|
|
405
|
+
/>
|
|
406
|
+
</div>
|
|
407
|
+
<span class="recorrencia-dica">
|
|
408
|
+
O agendamento será replicado toda <strong>{{ nomeDiaSemana }}</strong> das
|
|
409
|
+
<strong>{{ formReserva.hora_inicio }}</strong> às <strong>{{ formReserva.hora_fim }}</strong> até a data selecionada.
|
|
410
|
+
</span>
|
|
411
|
+
</div>
|
|
412
|
+
</div>
|
|
413
|
+
</slot>
|
|
414
|
+
</slot>
|
|
289
415
|
|
|
290
416
|
<div class="area-customizada">
|
|
291
|
-
<slot
|
|
417
|
+
<slot
|
|
418
|
+
name="campos-extras"
|
|
419
|
+
:dados-reserva="formReserva"
|
|
420
|
+
:texto-dia-selecionado="textoDiaSelecionado"
|
|
421
|
+
:texto-intervalo-horario="textoIntervaloHorario"
|
|
422
|
+
></slot>
|
|
292
423
|
</div>
|
|
293
424
|
</div>
|
|
294
425
|
|
|
@@ -328,22 +459,38 @@ const salvarReserva = async () => {
|
|
|
328
459
|
</template>
|
|
329
460
|
|
|
330
461
|
<style scoped>
|
|
331
|
-
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.4); display: flex; align-items: center; justify-content: center; z-index: 1050; backdrop-filter: blur(2px); }
|
|
332
|
-
.modal-card { background: var(--bg-modal); width: 100%; max-width:
|
|
333
|
-
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-light); background: var(--bg-primary); }
|
|
462
|
+
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; padding: 16px; box-sizing: border-box; background: rgba(0, 0, 0, 0.4); display: flex; align-items: center; justify-content: center; z-index: 1050; backdrop-filter: blur(2px); }
|
|
463
|
+
.modal-card { background: var(--bg-modal); width: 100%; max-width: 500px; max-height: calc(100vh - 32px); border-radius: 12px; box-shadow: var(--shadow-float); display: flex; flex-direction: column; overflow: hidden; position: relative; }
|
|
464
|
+
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-light); background: var(--bg-primary); flex-shrink: 0; }
|
|
334
465
|
.modal-header h3 { margin: 0; font-size: 16px; color: var(--text-primary); font-weight: 600; }
|
|
335
466
|
.btn-fechar { background: transparent; border: none; font-size: 24px; color: var(--text-secondary); cursor: pointer; line-height: 1; transition: color 0.2s; }
|
|
336
467
|
.btn-fechar:hover { color: var(--text-primary); }
|
|
337
|
-
.modal-body { padding: 20px; display: flex; flex-direction: column; gap:
|
|
468
|
+
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; background: var(--bg-primary); flex: 1 1 auto; min-height: 0; overflow-y: auto; }
|
|
338
469
|
.form-group { display: flex; flex-direction: column; gap: 6px; }
|
|
339
470
|
.form-group label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
|
|
340
|
-
.form-group input[type="text"],
|
|
341
|
-
.form-group input[type="
|
|
471
|
+
.form-group input[type="text"],
|
|
472
|
+
.form-group input[type="date"],
|
|
473
|
+
.form-group input[type="time"],
|
|
474
|
+
.form-group select { width: 100%; padding: 10px; border: 1px solid var(--border-light); background: var(--bg-primary); border-radius: 6px; font-size: 14px; color: var(--text-primary); box-sizing: border-box; transition: border-color 0.2s; }
|
|
475
|
+
.form-group input:focus { border-color: var(--color-brand); outline: none; }
|
|
342
476
|
.form-group select:disabled { background-color: var(--bg-secondary); color: var(--text-secondary); cursor: not-allowed; opacity: 1; }
|
|
343
|
-
.
|
|
344
|
-
.
|
|
345
|
-
.
|
|
346
|
-
.
|
|
477
|
+
.resumo-horario-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 8px; background: var(--bg-secondary); border: 1px solid var(--border-light); flex-shrink: 0; }
|
|
478
|
+
.resumo-horario-textos { display: flex; flex-direction: column; gap: 2px; }
|
|
479
|
+
.resumo-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-secondary); }
|
|
480
|
+
.resumo-dia { font-size: 14px; font-weight: 700; color: var(--text-primary); }
|
|
481
|
+
.resumo-horas { font-size: 13px; font-weight: 600; color: var(--color-brand); }
|
|
482
|
+
.btn-toggle-ajuste { background: var(--bg-primary); border: 1px solid var(--border-light); color: var(--text-primary); font-weight: 600; font-size: 12.5px; padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
|
|
483
|
+
.btn-toggle-ajuste:hover { background: var(--bg-hover); border-color: var(--color-brand); color: var(--color-brand); }
|
|
484
|
+
.painel-ajuste-horario { display: flex; flex-direction: column; gap: 12px; padding: 12px 14px; border-radius: 8px; background: var(--bg-secondary); border: 1px dashed var(--border-light); flex-shrink: 0; }
|
|
485
|
+
.form-row-lado-a-lado { display: flex; flex-direction: row; gap: 12px; }
|
|
486
|
+
.metade { flex: 1; min-width: 0; }
|
|
487
|
+
.recorrencia-box { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--bg-secondary); border: 1px solid var(--border-light); flex-shrink: 0; }
|
|
488
|
+
.recorrencia-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
|
|
489
|
+
.recorrencia-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-brand); cursor: pointer; }
|
|
490
|
+
.recorrencia-titulo { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
|
|
491
|
+
.recorrencia-detalhes { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--border-light); }
|
|
492
|
+
.recorrencia-dica { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
|
|
493
|
+
.modal-footer { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-top: 1px solid var(--border-light); background: var(--bg-secondary); flex-shrink: 0; }
|
|
347
494
|
.acoes-validacao { display: flex; align-items: center; gap: 10px; }
|
|
348
495
|
.acoes-salvar { display: flex; gap: 12px; }
|
|
349
496
|
.aviso-validar { font-size: 12px; color: var(--color-danger); font-weight: 600; }
|
|
@@ -356,31 +503,19 @@ const salvarReserva = async () => {
|
|
|
356
503
|
.btn-salvar { background: var(--color-brand); border: none; color: var(--text-inverse); font-weight: 600; font-size: 14px; cursor: pointer; padding: 8px 24px; border-radius: 6px; transition: background 0.2s; }
|
|
357
504
|
.btn-salvar:hover:not(:disabled) { filter: brightness(0.9); }
|
|
358
505
|
.btn-salvar:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
359
|
-
.horarios-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-primary); z-index: 10; display: flex; flex-direction: column; }
|
|
360
|
-
.horarios-lista-container { flex: 1; overflow-y: auto; padding: 20px; margin: 0; }
|
|
506
|
+
.horarios-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-primary); z-index: 10; display: flex; flex-direction: column; overflow: hidden; }
|
|
507
|
+
.horarios-lista-container { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px; margin: 0; }
|
|
361
508
|
.horarios-lista { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
|
|
362
509
|
.horarios-lista li { background: var(--bg-secondary); padding: 12px 16px; border-radius: 8px; color: var(--text-primary); font-weight: 500; font-size: 14px; text-align: center; border: 1px solid var(--border-light); }
|
|
363
|
-
|
|
364
|
-
|
|
365
510
|
</style>
|
|
511
|
+
|
|
366
512
|
<style>
|
|
367
|
-
/*
|
|
368
|
-
========
|
|
369
|
-
Estilo global para garantir que o tema dark sobreponha qualquer escopo do componente.
|
|
370
|
-
Força a cor do texto dos botões para branco no dark mode.
|
|
371
|
-
========
|
|
372
|
-
*/
|
|
373
513
|
[data-bs-theme="dark"] .modal-card .btn-salvar,
|
|
374
514
|
[data-bs-theme="dark"] .modal-card .btn-cancelar {
|
|
375
515
|
color: #ffffff !important;
|
|
376
|
-
|
|
377
|
-
/* text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.5); */
|
|
378
|
-
|
|
379
|
-
/* -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.5); */
|
|
380
516
|
font-weight: bold;
|
|
381
|
-
|
|
382
517
|
}
|
|
383
|
-
[data-bs-theme="dark"] .modal-card .btn-salvar{
|
|
384
|
-
|
|
518
|
+
[data-bs-theme="dark"] .modal-card .btn-salvar {
|
|
519
|
+
background: color-mix(in srgb, var(--color-brand) 70%, black) !important;
|
|
385
520
|
}
|
|
386
521
|
</style>
|
|
@@ -259,6 +259,18 @@ export function useAgenda(api: any) {
|
|
|
259
259
|
throw erro;
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
// Recebe o objeto padronizado da reserva recorrente (com data_limite_repeticao) e envia para a rota em lote.
|
|
265
|
+
const criarReservaRecorrente = async (payload: any) => {
|
|
266
|
+
try {
|
|
267
|
+
const resposta = await api.post('/reservas/recorrentes/', payload);
|
|
268
|
+
return resposta;
|
|
269
|
+
} catch (erro) {
|
|
270
|
+
console.error("Erro na API ao criar reserva recorrente:", erro);
|
|
271
|
+
throw erro;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
262
274
|
return {
|
|
263
275
|
reservasBrutas,
|
|
264
276
|
recursosDisponiveis,
|
|
@@ -281,5 +293,6 @@ export function useAgenda(api: any) {
|
|
|
281
293
|
buscarPeriodosAgenda,
|
|
282
294
|
obterDetalhesReserva,
|
|
283
295
|
excluirReserva,
|
|
296
|
+
criarReservaRecorrente
|
|
284
297
|
};
|
|
285
298
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
========
|
|
3
|
+
Este arquivo centraliza a paleta de cores dos blocos da agenda e a lógica de escurecimento
|
|
4
|
+
automático no modo noturno (dark theme).
|
|
5
|
+
========
|
|
6
|
+
*/
|
|
7
|
+
import { useTheme } from '@/iframeCommunicator/useThemeFromParent.ts';
|
|
8
|
+
|
|
9
|
+
const PALETA_CORES_BLOCOS: string[] = [
|
|
10
|
+
'#FFE0B2', '#C8E6C9', '#BBDEFB', '#E1BEE7', '#F8BBD0',
|
|
11
|
+
'#FFF59D', '#B2EBF2', '#FFCCBC', '#D1C4E9', '#DCEDC8'
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const PALETA_BORDAS_BLOCOS: string[] = [
|
|
15
|
+
'#DF9A00', '#5C9E31', '#4A89C7', '#8E24AA', '#D81B60',
|
|
16
|
+
'#F9A825', '#0097A7', '#E64A19', '#5E35B1', '#689F38'
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export function useCoresAgenda() {
|
|
20
|
+
const { theme } = useTheme();
|
|
21
|
+
|
|
22
|
+
// Recebe o índice numérico do bloco e devolve a cor de fundo e de borda correspondentes,
|
|
23
|
+
// aplicando automaticamente a mistura (color-mix) com preto caso o tema atual seja 'dark'.
|
|
24
|
+
const obterCoresBloco = (indiceBloco: number) => {
|
|
25
|
+
const corFundoBase = PALETA_CORES_BLOCOS[indiceBloco % PALETA_CORES_BLOCOS.length] ?? '#FFE0B2';
|
|
26
|
+
const corBordaBase = PALETA_BORDAS_BLOCOS[indiceBloco % PALETA_BORDAS_BLOCOS.length] ?? '#DF9A00';
|
|
27
|
+
|
|
28
|
+
const corFundo = theme.value === 'dark'
|
|
29
|
+
? `color-mix(in srgb, ${corFundoBase} 20%, black)`
|
|
30
|
+
: corFundoBase;
|
|
31
|
+
|
|
32
|
+
const corBorda = theme.value === 'dark'
|
|
33
|
+
? `color-mix(in srgb, ${corBordaBase} 40%, black)`
|
|
34
|
+
: corBordaBase;
|
|
35
|
+
|
|
36
|
+
return { corFundo, corBorda };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return { obterCoresBloco, theme };
|
|
40
|
+
}
|