From a39b962d0a56527f1ff7b9d084186c300cf2a775 Mon Sep 17 00:00:00 2001 From: Denis Voinovich Date: Tue, 3 Jun 2025 10:46:23 +0300 Subject: [PATCH] =?UTF-8?q?fix=20[P-255]:=20=D0=BE=D0=B3=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D0=B8=D0=BB=20=D0=B2=D0=B2=D0=BE=D0=B4=20=D0=B4?= =?UTF-8?q?=D0=B0=D1=82=20=D0=B2=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BC=20=D0=B4?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BF=D0=B8=D0=BA=D0=B5=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/front/src/components/UI/date-select.vue | 16 ++- .../components/testing/AssignTestDialog.vue | 114 ++++++++---------- 2 files changed, 59 insertions(+), 71 deletions(-) diff --git a/src/front/src/components/UI/date-select.vue b/src/front/src/components/UI/date-select.vue index 4628ca6fd..3688be6bd 100644 --- a/src/front/src/components/UI/date-select.vue +++ b/src/front/src/components/UI/date-select.vue @@ -35,6 +35,7 @@ v-model="selectedDate" show-adjacent-months hide-header + :min="new Date().toISOString().slice(0, 10)" @update:modelValue="dateStart" border /> @@ -53,25 +54,22 @@ export default { props: { datedefault: { type: Date, - default: '' + default: () => new Date() } }, - - setup(props, {emit}) { const appStore = useAppStore() - const maxdate = formatDash(new Date()) const menudate = ref(false) - const selectedDate = ref(null) + const selectedDate = ref(props.datedefault ? formatDash(new Date(props.datedefault)) : formatDash(new Date())) const dateStart = () => { - emit('returndate', selectedDate.value) - menudate.value=false + if (selectedDate.value) { + emit('returndate', selectedDate.value) + menudate.value = false + } } - - return { menudate, selectedDate, diff --git a/src/front/src/components/testing/AssignTestDialog.vue b/src/front/src/components/testing/AssignTestDialog.vue index df2002812..cfb6419e8 100644 --- a/src/front/src/components/testing/AssignTestDialog.vue +++ b/src/front/src/components/testing/AssignTestDialog.vue @@ -178,70 +178,60 @@ export default { }, emits: ['update:modelValue', 'assign', 'unassign'], setup(props, { emit }) { - const selectedEmployees = ref([]); - const publishNews = ref(false); - const defaultEndDate = new Date(); - defaultEndDate.setHours(18, 0, 0, 0); - const defaultStartDate = new Date(); - defaultStartDate.setHours(9, 0, 0, 0); - const completionDate = ref(defaultEndDate); - const startDate = ref(defaultStartDate); - const snackbar = ref({ - show: false, - text: '', - color: 'error' - }); - - const showSnackbar = (text, color = 'error') => { - snackbar.value = { - show: true, - text, - color - }; - }; - - const handleEmployeeSelection = (value) => { - selectedEmployees.value = value; - }; - - const handleDateChange = (date, type = 'end') => { - if (date) { - const newDate = new Date(date); - if (type === 'end') { - newDate.setHours(18, 0, 0, 0); - } else { - newDate.setHours(9, 0, 0, 0); - } + const selectedEmployees = ref([]); + const publishNews = ref(false); - const today = new Date(); - today.setHours(0, 0, 0, 0); - if (newDate < today) { - showSnackbar('Нельзя назначить прошедшую дату'); - if (type === 'end') { - completionDate.value = null; - } else { - startDate.value = null; - } - return; - } + // Устанавливаем начальные даты + const currentDate = new Date(); + const defaultStartDate = new Date(currentDate); + defaultStartDate.setHours(9, 0, 0, 0); + + const defaultEndDate = new Date(currentDate); + defaultEndDate.setHours(18, 0, 0, 0); + + const startDate = ref(defaultStartDate); + const completionDate = ref(defaultEndDate); + + const snackbar = ref({ + show: false, + text: '', + color: 'error' + }); - if (type === 'end') { - if (startDate.value && newDate < startDate.value) { - showSnackbar('Дата окончания не может быть раньше даты начала'); - completionDate.value = null; - return; - } - completionDate.value = newDate; - } else { - if (completionDate.value && newDate > completionDate.value) { - showSnackbar('Дата начала не может быть позже даты окончания'); - startDate.value = null; - return; - } - startDate.value = newDate; - } - } - }; + const showSnackbar = (text, color = 'error') => { + snackbar.value = { + show: true, + text, + color + }; + }; + + const handleEmployeeSelection = (value) => { + selectedEmployees.value = value; + }; + + const handleDateChange = (date, type = 'end') => { + if (!date) return; + + const newDate = new Date(date); + if (type === 'end') { + newDate.setHours(18, 0, 0, 0); + completionDate.value = newDate; + + if (startDate.value && newDate < startDate.value) { + startDate.value = newDate; + startDate.value.setHours(9, 0, 0, 0); + } + } else { + newDate.setHours(9, 0, 0, 0); + startDate.value = newDate; + + if (completionDate.value && newDate > completionDate.value) { + completionDate.value = newDate; + completionDate.value.setHours(18, 0, 0, 0); + } + } + }; const handleAssign = () => { if (!selectedEmployees.value.length) {