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

чиним билд001

This commit is contained in:
MoonTestUse1
2025-01-02 02:18:29 +06:00
parent a2225419d7
commit dedba3bd91

View File

@@ -1,105 +1,131 @@
<template> <template>
<div class="max-w-4xl mx-auto p-6"> <div class="min-h-screen bg-gray-100">
<h1 class="text-2xl font-bold text-gray-900 mb-6">Создание заявки</h1> <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> <div>
<label for="department" class="block text-sm font-medium text-gray-700">Отдел</label> <label for="department" class="block text-sm font-medium text-gray-700">Отдел</label>
<select <select
id="department" id="department"
v-model="formData.department" v-model="formData.department"
class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
required required
> >
<option value="">Выберите отдел</option> <option value="">Выберите отдел</option>
<option value="IT">IT</option> <option value="IT">IT</option>
<option value="HR">HR</option> <option value="HR">HR</option>
<option value="Finance">Финансы</option> <option value="Finance">Финансы</option>
<option value="Marketing">Маркетинг</option> <option value="Marketing">Маркетинг</option>
</select> </select>
</div> </div>
<div> <div>
<label for="request_type" class="block text-sm font-medium text-gray-700">Тип заявки</label> <label for="request_type" class="block text-sm font-medium text-gray-700">Тип заявки</label>
<select <select
id="request_type" id="request_type"
v-model="formData.request_type" v-model="formData.request_type"
class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
required required
> >
<option value="">Выберите тип</option> <option value="">Выберите тип</option>
<option value="access">Доступ к системе</option> <option value="access">Доступ к системе</option>
<option value="software">Установка ПО</option> <option value="software">Установка ПО</option>
<option value="hardware">Проблема с оборудованием</option> <option value="hardware">Проблема с оборудованием</option>
<option value="other">Другое</option> <option value="other">Другое</option>
</select> </select>
</div> </div>
<div> <div>
<label for="priority" class="block text-sm font-medium text-gray-700">Приоритет</label> <label for="priority" class="block text-sm font-medium text-gray-700">Приоритет</label>
<select <select
id="priority" id="priority"
v-model="formData.priority" v-model="formData.priority"
class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
required required
> >
<option value="">Выберите приоритет</option> <option value="">Выберите приоритет</option>
<option value="low">Низкий</option> <option value="low">Низкий</option>
<option value="medium">Средний</option> <option value="medium">Средний</option>
<option value="high">Высокий</option> <option value="high">Высокий</option>
<option value="critical">Критический</option> <option value="critical">Критический</option>
</select> </select>
</div> </div>
<div> <div>
<label for="description" class="block text-sm font-medium text-gray-700">Описание</label> <label for="description" class="block text-sm font-medium text-gray-700">Описание</label>
<textarea <textarea
id="description" id="description"
v-model="formData.description" v-model="formData.description"
rows="4" rows="4"
class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
placeholder="Опишите вашу проблему..." placeholder="Опишите вашу проблему..."
required required
></textarea> ></textarea>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<button <button
type="submit" type="submit"
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" 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" :disabled="loading"
> >
<span v-if="loading">Отправка...</span> <span v-if="loading">
<span v-else>Отправить заявку</span> <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">
</button> <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
</div> <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 }} {{ error }}
</div> </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> </div>
</form> </form>
</div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue' import { ref, reactive, onMounted } from 'vue'
import axios from 'axios' import axios from 'axios'
interface Employee {
id: number
first_name: string
last_name: string
department: string
office: string
}
const formData = reactive({ const formData = reactive({
department: '', department: '',
request_type: '', request_type: '',
priority: '', priority: '',
description: '' description: '',
employee_id: 0
}) })
const loading = ref(false) const loading = ref(false)
const error = ref('') const error = ref('')
const success = ref(false) 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 () => { const handleSubmit = async () => {
loading.value = true loading.value = true
error.value = '' error.value = ''
@@ -124,6 +150,7 @@ const handleSubmit = async () => {
formData.priority = '' formData.priority = ''
formData.description = '' formData.description = ''
} catch (e: any) { } catch (e: any) {
console.error('Ошибка при создании заявки:', e)
error.value = e.response?.data?.detail || 'Произошла ошибка при создании заявки' error.value = e.response?.data?.detail || 'Произошла ошибка при создании заявки'
} finally { } finally {
loading.value = false loading.value = false