1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Починка добавления сотрудника10

This commit is contained in:
MoonTestUse1
2024-12-27 03:08:59 +06:00
parent e8136ec433
commit 4ba05a43d3

View File

@@ -3,7 +3,7 @@
<div class="flex justify-between items-center mb-6"> <div class="flex justify-between items-center mb-6">
<h2 class="text-lg font-semibold">Сотрудники</h2> <h2 class="text-lg font-semibold">Сотрудники</h2>
<button <button
@click="showAddForm = true" @click="openAddForm"
class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 flex items-center gap-2" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 flex items-center gap-2"
> >
<UserPlusIcon :size="18" /> <UserPlusIcon :size="18" />
@@ -51,9 +51,9 @@
</div> </div>
<!-- Модальное окно --> <!-- Модальное окно -->
<div v-show="showAddForm || editingEmployee" class="fixed inset-0 overflow-y-auto" style="z-index: 100;"> <div v-if="showAddForm || editingEmployee" class="fixed inset-0 overflow-y-auto" style="z-index: 100;">
<div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity" aria-hidden="true"> <div class="fixed inset-0 transition-opacity" aria-hidden="true" @click="closeForm">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div> <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div> </div>
@@ -167,6 +167,12 @@ const formData = ref<EmployeeFormData>({
password: '' password: ''
}); });
function openAddForm() {
console.log('Opening add form');
showAddForm.value = true;
console.log('showAddForm value:', showAddForm.value);
}
// Сброс формы при закрытии // Сброс формы при закрытии
function resetForm() { function resetForm() {
formData.value = { formData.value = {
@@ -178,8 +184,14 @@ function resetForm() {
}; };
} }
// Наблюдаем за изменением showAddForm
watch(showAddForm, (newValue) => {
console.log('showAddForm changed:', newValue);
});
// Наблюдаем за изменением editingEmployee // Наблюдаем за изменением editingEmployee
watch(editingEmployee, (newEmployee) => { watch(editingEmployee, (newEmployee) => {
console.log('editingEmployee changed:', newEmployee);
if (newEmployee) { if (newEmployee) {
formData.value = { formData.value = {
first_name: newEmployee.first_name, first_name: newEmployee.first_name,
@@ -198,17 +210,20 @@ function getDepartmentLabel(value: string) {
} }
function editEmployee(employee: Employee) { function editEmployee(employee: Employee) {
console.log('Editing employee:', employee);
editingEmployee.value = employee; editingEmployee.value = employee;
showAddForm.value = true; showAddForm.value = true;
} }
function closeForm() { function closeForm() {
console.log('Closing form');
showAddForm.value = false; showAddForm.value = false;
editingEmployee.value = null; editingEmployee.value = null;
resetForm(); resetForm();
} }
async function handleSubmit() { async function handleSubmit() {
console.log('Submitting form:', formData.value);
try { try {
const data = { ...formData.value }; const data = { ...formData.value };
if (editingEmployee.value && !data.password) { if (editingEmployee.value && !data.password) {
@@ -260,6 +275,17 @@ async function fetchEmployees() {
} }
onMounted(() => { onMounted(() => {
console.log('Component mounted');
fetchEmployees(); fetchEmployees();
}); });
</script> </script>
<style scoped>
.fixed {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
</style>