Compare commits
2 Commits
e0a359acb9
...
ef244b730c
| Author | SHA1 | Date | |
|---|---|---|---|
| ef244b730c | |||
| b990a88325 |
@ -219,13 +219,13 @@ watch(isOpen, (val) => emit('update:modelValue', val));
|
||||
|
||||
// Mapeamento de nomes para valores de dias
|
||||
const diaSemanaMap = {
|
||||
'Domingo': 0,
|
||||
'Segunda-feira': 1,
|
||||
'Terça-feira': 2,
|
||||
'Quarta-feira': 3,
|
||||
'Quinta-feira': 4,
|
||||
'Sexta-feira': 5,
|
||||
'Sábado': 6
|
||||
'Domingo': 1,
|
||||
'Segunda-feira': 2,
|
||||
'Terça-feira': 3,
|
||||
'Quarta-feira': 4,
|
||||
'Quinta-feira': 5,
|
||||
'Sexta-feira': 6,
|
||||
'Sábado': 7
|
||||
};
|
||||
|
||||
// Atualiza os dados do formulário com shiftData recebido
|
||||
|
||||
@ -112,11 +112,11 @@ export const useShiftStore = defineStore('shifts', {
|
||||
end_time: shiftData.end_time,
|
||||
interval_start: shiftData.interval_start,
|
||||
interval_end: shiftData.interval_end,
|
||||
type_interval: shiftData.type_interval, // "manual" ou "automatic" dependendo da checkbox
|
||||
type_interval: shiftData.type_interval || 'manual', // "manual" ou "automatic" dependendo da checkbox
|
||||
description: shiftData.description || '',
|
||||
tolerance: shiftData.tolerance || 0,
|
||||
service_instance_id: authStore.service_instance_id,
|
||||
time_schedule_ids: shiftData.time_schedule_ids || []
|
||||
time_schedule_ids: shiftData.time_schedule_ids || [],
|
||||
};
|
||||
|
||||
console.log('Enviando dados para a API:', payload);
|
||||
@ -153,18 +153,24 @@ export const useShiftStore = defineStore('shifts', {
|
||||
/**
|
||||
* Atualiza os dados de um turno
|
||||
*/
|
||||
async updateShift(id, shift) {
|
||||
async updateShift(id, shiftData) {
|
||||
const url = `/shift/${id}`;
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
const authStore = useAuthStore();
|
||||
|
||||
try {
|
||||
const response = await api.put(url, {
|
||||
name: shift.name,
|
||||
days: shift.days,
|
||||
break_time: shift.break_time,
|
||||
break_type: shift.break_type,
|
||||
status: shift.status,
|
||||
name: shiftData.nome,
|
||||
start_time: shiftData.entrada,
|
||||
end_time: shiftData.saida_final,
|
||||
interval_start: shiftData.saida_almoco,
|
||||
interval_end: shiftData.retorno_almoco,
|
||||
type_interval: shiftData.almoco_automatico ? 'Automatico' : 'Manual', // "manual" ou "automatic" dependendo da checkbox
|
||||
description: shiftData.descricao || '',
|
||||
tolerance: shiftData.tolerancia || 0,
|
||||
service_instance_id: authStore.service_instance_id,
|
||||
time_schedule_ids: shiftData.dias_semana || []
|
||||
});
|
||||
|
||||
const index = this.shifts.findIndex((s) => s.id === id);
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:item.almoco_type="{ item }">
|
||||
{{ item.type_interval === 'auto' ? 'Automático' : 'Manual' }}
|
||||
{{ item.type_interval === 'automatic' ? 'Automatico' : 'Manual' }}
|
||||
</template>
|
||||
<template v-slot:item.actions="{ item }">
|
||||
<v-icon size="small" class="mr-2" @click="openEditShiftDialog(item.id)">mdi-pencil</v-icon>
|
||||
@ -200,7 +200,10 @@ export default {
|
||||
interval_start: data.interval_start || '',
|
||||
interval_end: data.interval_end || '',
|
||||
type_interval: data.type_interval || '',
|
||||
tolerance: data.tolerance || ''
|
||||
tolerance: data.tolerance || '',
|
||||
description: data.description || '',
|
||||
time_schedules: data.time_schedules || []
|
||||
|
||||
};
|
||||
dialogs.value.editShift = true;
|
||||
};
|
||||
@ -219,19 +222,19 @@ export default {
|
||||
};
|
||||
|
||||
const submitEdit = async (data) => {
|
||||
await shiftStore.updateShift(data.id, data);
|
||||
await fetchShifts();
|
||||
//await shiftStore.updateShift(data.id, data);
|
||||
await shiftStore.fetchShifts();
|
||||
showNotification('Escala atualizada com sucesso');
|
||||
dialogs.value.editShift = false;
|
||||
};
|
||||
|
||||
const handleCreatedShift = async () => {
|
||||
await fetchShifts(); // função que carrega os turnos da API
|
||||
await shiftStore.fetchShifts(); // função que carrega os turnos da API
|
||||
showNotification('Escala criada com sucesso!');
|
||||
dialogs.value.createShift = false;
|
||||
};
|
||||
const handleEditedShift = async () => {
|
||||
await fetchShifts(); // 🔁 recarrega os dados atualizados da API
|
||||
await shiftStore.fetchShifts(); // 🔁 recarrega os dados atualizados da API
|
||||
dialogs.value.editShift = false; // ❌ fecha o modal
|
||||
showNotification('Escala atualizada com sucesso!');
|
||||
};
|
||||
@ -264,7 +267,7 @@ export default {
|
||||
dialogs, loading, filters, shifts, snackbar, forms,
|
||||
page, itemsPerPage, headers, itemToDelete,
|
||||
formatTimeRange, openCreateShiftDialog, openEditShiftDialog,
|
||||
confirmDelete, deleteItem, submitEdit, handleCreatedShift, filteredshifts
|
||||
confirmDelete, deleteItem, submitEdit, handleCreatedShift,handleEditedShift, filteredshifts
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user