mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
доработка админ панели2
This commit is contained in:
@@ -126,6 +126,7 @@ export default {
|
||||
this.isLoading = true
|
||||
|
||||
try {
|
||||
console.log('Sending employee data:', this.formData)
|
||||
const response = await axios.post('/api/employees', this.formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem('admin_token')}`,
|
||||
@@ -136,8 +137,11 @@ export default {
|
||||
}
|
||||
})
|
||||
|
||||
console.log('Response:', response)
|
||||
|
||||
if (response.status === 307) {
|
||||
const redirectUrl = response.headers.location
|
||||
console.log('Redirecting to:', redirectUrl)
|
||||
const finalResponse = await axios.post(redirectUrl, this.formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem('admin_token')}`,
|
||||
@@ -145,6 +149,8 @@ export default {
|
||||
}
|
||||
})
|
||||
|
||||
console.log('Final response:', finalResponse)
|
||||
|
||||
if (finalResponse.status === 200 || finalResponse.status === 201) {
|
||||
this.$emit('employee-added')
|
||||
this.closeModal()
|
||||
|
@@ -118,8 +118,11 @@ export default {
|
||||
} else {
|
||||
this.employees = response.data
|
||||
}
|
||||
|
||||
console.log('Fetched employees:', this.employees) // Для отладки
|
||||
} catch (error) {
|
||||
console.error('Error fetching employees:', error)
|
||||
this.employees = []
|
||||
}
|
||||
},
|
||||
editEmployee(employee) {
|
||||
@@ -158,11 +161,17 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isOpen(newVal) {
|
||||
if (newVal) {
|
||||
this.fetchEmployees()
|
||||
isOpen: {
|
||||
immediate: true,
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.fetchEmployees()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchEmployees()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user