mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
-
This commit is contained in:
@@ -1,17 +1,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { UserPlusIcon, PencilIcon } from 'lucide-vue-next';
|
|
||||||
import { departments } from '@/utils/constants';
|
import { departments } from '@/utils/constants';
|
||||||
import EmployeeFormModal from './employee/EmployeeFormModal.vue';
|
|
||||||
import Notification from '@/components/ui/Notification.vue';
|
|
||||||
import type { Employee } from '@/types/employee';
|
import type { Employee } from '@/types/employee';
|
||||||
|
|
||||||
const employees = ref<Employee[]>([]); // Добавляем типизацию массива сотрудников
|
const employees = ref<Employee[]>([]); // Добавляем типизацию массива сотрудников
|
||||||
const showAddForm = ref(false);
|
const showAddForm = ref(false);
|
||||||
const editingEmployee = ref<Employee | null>(null);
|
const editingEmployee = ref<Employee | null>(null);
|
||||||
const showNotification = ref(false);
|
|
||||||
const notificationMessage = ref('');
|
|
||||||
|
|
||||||
function getDepartmentLabel(value: string) {
|
function getDepartmentLabel(value: string) {
|
||||||
return departments.find(d => d.value === value)?.label || value;
|
return departments.find(d => d.value === value)?.label || value;
|
||||||
|
|||||||
@@ -8,16 +8,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{
|
defineProps<{
|
||||||
status: 'new' | 'in_progress' | 'resolved' | 'closed'
|
status: 'new' | 'in_progress' | 'resolved' | 'closed'
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const statusClasses = {
|
const statusClasses = {
|
||||||
new: 'bg-blue-100 text-blue-800',
|
new: 'bg-blue-100 text-blue-800',
|
||||||
in_progress: 'bg-yellow-100 text-yellow-800',
|
in_progress: 'bg-yellow-100 text-yellow-800',
|
||||||
resolved: 'bg-green-100 text-green-800',
|
resolved: 'bg-green-100 text-green-800',
|
||||||
closed: 'bg-gray-100 text-gray-800'
|
closed: 'bg-gray-100 text-gray-800'
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
const statusLabels = {
|
const statusLabels = {
|
||||||
new: 'Новая',
|
new: 'Новая',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="p-2 bg-blue-50 rounded-lg">
|
<div class="p-2 bg-blue-50 rounded-lg">
|
||||||
<component
|
<component
|
||||||
:is="employee ? UserIcon : UserPlusIcon"
|
:is="employee ? UserIcon : UserPlusIcon"
|
||||||
size="24"
|
:size="24"
|
||||||
class="text-blue-600"
|
class="text-blue-600"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
@click="$emit('close')"
|
@click="$emit('close')"
|
||||||
class="text-gray-400 hover:text-gray-500 transition-colors"
|
class="text-gray-400 hover:text-gray-500 transition-colors"
|
||||||
>
|
>
|
||||||
<XIcon size="20" />
|
<XIcon :size="20" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
label="Отдел"
|
label="Отдел"
|
||||||
type="select"
|
type="select"
|
||||||
required
|
required
|
||||||
:options="departments"
|
:options="departmentOptions"
|
||||||
:icon="BuildingIcon"
|
:icon="BuildingIcon"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -76,14 +76,14 @@
|
|||||||
@click="$emit('close')"
|
@click="$emit('close')"
|
||||||
class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors flex items-center gap-2"
|
class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors flex items-center gap-2"
|
||||||
>
|
>
|
||||||
<XIcon size="16" />
|
<XIcon :size="16" />
|
||||||
Отмена
|
Отмена
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors flex items-center gap-2"
|
class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors flex items-center gap-2"
|
||||||
>
|
>
|
||||||
<component :is="employee ? SaveIcon : UserPlusIcon" size="16" />
|
<component :is="employee ? SaveIcon : UserPlusIcon" :size="16" />
|
||||||
{{ employee ? 'Сохранить' : 'Добавить' }}
|
{{ employee ? 'Сохранить' : 'Добавить' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -98,10 +98,24 @@ import { XIcon, UserIcon, BuildingIcon, DoorClosedIcon, LockIcon, UserPlusIcon,
|
|||||||
import { departments } from '@/utils/constants';
|
import { departments } from '@/utils/constants';
|
||||||
import FormField from '@/components/ui/FormField.vue';
|
import FormField from '@/components/ui/FormField.vue';
|
||||||
|
|
||||||
|
interface Employee {
|
||||||
|
id: number;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
department: string;
|
||||||
|
office: string;
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
employee?: any;
|
employee?: Employee;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const departmentOptions = departments.map(d => ({
|
||||||
|
value: d.value,
|
||||||
|
label: d.label
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'close'): void;
|
(e: 'close'): void;
|
||||||
(e: 'submit', data: any): void;
|
(e: 'submit', data: any): void;
|
||||||
@@ -130,7 +144,7 @@ onMounted(() => {
|
|||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
const data = { ...formData.value };
|
const data = { ...formData.value };
|
||||||
if (props.employee && !data.password) {
|
if (props.employee && !data.password) {
|
||||||
delete data.password;
|
formData.value.password = ''; // Вместо delete используем присваивание пустой строки
|
||||||
}
|
}
|
||||||
emit('submit', data);
|
emit('submit', data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user