mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
чиним билд001
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-100">
|
||||
<div class="max-w-4xl mx-auto p-6">
|
||||
<h1 class="text-2xl font-bold text-gray-900 mb-6">Создание заявки</h1>
|
||||
|
||||
<form @submit.prevent="handleSubmit" class="space-y-6 bg-white shadow-sm rounded-lg p-6">
|
||||
<form @submit.prevent="handleSubmit" class="space-y-6 bg-white shadow-lg rounded-lg p-6">
|
||||
<div>
|
||||
<label for="department" class="block text-sm font-medium text-gray-700">Отдел</label>
|
||||
<select
|
||||
@@ -69,37 +70,62 @@
|
||||
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
|
||||
:disabled="loading"
|
||||
>
|
||||
<span v-if="loading">Отправка...</span>
|
||||
<span v-if="loading">
|
||||
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
Отправка...
|
||||
</span>
|
||||
<span v-else>Отправить заявку</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="mt-2 text-sm text-red-600">
|
||||
<div v-if="error" class="mt-2 text-sm text-red-600 bg-red-50 p-3 rounded-md">
|
||||
{{ error }}
|
||||
</div>
|
||||
|
||||
<div v-if="success" class="mt-2 text-sm text-green-600">
|
||||
<div v-if="success" class="mt-2 text-sm text-green-600 bg-green-50 p-3 rounded-md">
|
||||
Заявка успешно создана!
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
interface Employee {
|
||||
id: number
|
||||
first_name: string
|
||||
last_name: string
|
||||
department: string
|
||||
office: string
|
||||
}
|
||||
|
||||
const formData = reactive({
|
||||
department: '',
|
||||
request_type: '',
|
||||
priority: '',
|
||||
description: ''
|
||||
description: '',
|
||||
employee_id: 0
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const success = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
// Получаем данные сотрудника из localStorage
|
||||
const employeeData = localStorage.getItem('employee')
|
||||
if (employeeData) {
|
||||
const employee = JSON.parse(employeeData) as Employee
|
||||
formData.employee_id = employee.id
|
||||
}
|
||||
})
|
||||
|
||||
const handleSubmit = async () => {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
@@ -124,6 +150,7 @@ const handleSubmit = async () => {
|
||||
formData.priority = ''
|
||||
formData.description = ''
|
||||
} catch (e: any) {
|
||||
console.error('Ошибка при создании заявки:', e)
|
||||
error.value = e.response?.data?.detail || 'Произошла ошибка при создании заявки'
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
Reference in New Issue
Block a user