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

доработка админ панели2

This commit is contained in:
MoonTestUse1
2025-01-03 03:09:20 +06:00
parent aa29946e78
commit 01de5ddb81
3 changed files with 48 additions and 5 deletions

View File

@@ -126,6 +126,7 @@ export default {
this.isLoading = true this.isLoading = true
try { try {
console.log('Sending employee data:', this.formData)
const response = await axios.post('/api/employees', this.formData, { const response = await axios.post('/api/employees', this.formData, {
headers: { headers: {
Authorization: `Bearer ${localStorage.getItem('admin_token')}`, Authorization: `Bearer ${localStorage.getItem('admin_token')}`,
@@ -136,8 +137,11 @@ export default {
} }
}) })
console.log('Response:', response)
if (response.status === 307) { if (response.status === 307) {
const redirectUrl = response.headers.location const redirectUrl = response.headers.location
console.log('Redirecting to:', redirectUrl)
const finalResponse = await axios.post(redirectUrl, this.formData, { const finalResponse = await axios.post(redirectUrl, this.formData, {
headers: { headers: {
Authorization: `Bearer ${localStorage.getItem('admin_token')}`, Authorization: `Bearer ${localStorage.getItem('admin_token')}`,
@@ -145,6 +149,8 @@ export default {
} }
}) })
console.log('Final response:', finalResponse)
if (finalResponse.status === 200 || finalResponse.status === 201) { if (finalResponse.status === 200 || finalResponse.status === 201) {
this.$emit('employee-added') this.$emit('employee-added')
this.closeModal() this.closeModal()

View File

@@ -118,8 +118,11 @@ export default {
} else { } else {
this.employees = response.data this.employees = response.data
} }
console.log('Fetched employees:', this.employees) // Для отладки
} catch (error) { } catch (error) {
console.error('Error fetching employees:', error) console.error('Error fetching employees:', error)
this.employees = []
} }
}, },
editEmployee(employee) { editEmployee(employee) {
@@ -158,11 +161,17 @@ export default {
} }
}, },
watch: { watch: {
isOpen(newVal) { isOpen: {
if (newVal) { immediate: true,
this.fetchEmployees() handler(newVal) {
if (newVal) {
this.fetchEmployees()
}
} }
} }
},
mounted() {
this.fetchEmployees()
} }
} }
</script> </script>

View File

@@ -105,14 +105,33 @@ export default {
methods: { methods: {
async fetchStatistics() { async fetchStatistics() {
try { try {
const response = await axios.get('/api/statistics', { const response = await axios.get('/api/requests/statistics', {
headers: { headers: {
Authorization: `Bearer ${localStorage.getItem('admin_token')}` Authorization: `Bearer ${localStorage.getItem('admin_token')}`
},
validateStatus: function (status) {
return status < 500
} }
}) })
this.statistics = response.data
if (response.status === 307) {
const redirectUrl = response.headers.location
const finalResponse = await axios.get(redirectUrl, {
headers: {
Authorization: `Bearer ${localStorage.getItem('admin_token')}`
}
})
this.statistics = finalResponse.data
} else {
this.statistics = response.data
}
} catch (error) { } catch (error) {
console.error('Error fetching statistics:', error) console.error('Error fetching statistics:', error)
this.statistics = {
total_requests: 0,
by_status: {},
by_priority: {}
}
} }
}, },
handleEmployeeAdded() { handleEmployeeAdded() {
@@ -120,6 +139,15 @@ export default {
if (this.showEmployeesModal && this.$refs.employeesModal) { if (this.showEmployeesModal && this.$refs.employeesModal) {
this.$refs.employeesModal.fetchEmployees() this.$refs.employeesModal.fetchEmployees()
} }
// Также обновляем список, если окно закрыто
if (!this.showEmployeesModal) {
this.showEmployeesModal = true
this.$nextTick(() => {
if (this.$refs.employeesModal) {
this.$refs.employeesModal.fetchEmployees()
}
})
}
} }
}, },
async created() { async created() {