fix [P-255]: ограничил ввод дат в самом датепикере
This commit is contained in:
1 parent
99661b2271
commit
a39b962d0a
2 files changed
+28
-40
No files matched your search
@@ -35,6 +35,7 @@
|
|||||||
v-model="selectedDate"
|
v-model="selectedDate"
|
||||||
show-adjacent-months
|
show-adjacent-months
|
||||||
hide-header
|
hide-header
|
||||||
|
:min="new Date().toISOString().slice(0, 10)"
|
||||||
@update:modelValue="dateStart"
|
@update:modelValue="dateStart"
|
||||||
border
|
border
|
||||||
/>
|
/>
|
||||||
@@ -53,24 +54,21 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
datedefault: {
|
datedefault: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: ''
|
default: () => new Date()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setup(props, {emit}) {
|
setup(props, {emit}) {
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const maxdate = formatDash(new Date())
|
|
||||||
const menudate = ref(false)
|
const menudate = ref(false)
|
||||||
const selectedDate = ref(null)
|
const selectedDate = ref(props.datedefault ? formatDash(new Date(props.datedefault)) : formatDash(new Date()))
|
||||||
|
|
||||||
const dateStart = () => {
|
const dateStart = () => {
|
||||||
|
if (selectedDate.value) {
|
||||||
emit('returndate', selectedDate.value)
|
emit('returndate', selectedDate.value)
|
||||||
menudate.value=false
|
menudate.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
menudate,
|
menudate,
|
||||||
|
|||||||
@@ -180,12 +180,18 @@ export default {
|
|||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const selectedEmployees = ref([]);
|
const selectedEmployees = ref([]);
|
||||||
const publishNews = ref(false);
|
const publishNews = ref(false);
|
||||||
const defaultEndDate = new Date();
|
|
||||||
defaultEndDate.setHours(18, 0, 0, 0);
|
// Устанавливаем начальные даты
|
||||||
const defaultStartDate = new Date();
|
const currentDate = new Date();
|
||||||
|
const defaultStartDate = new Date(currentDate);
|
||||||
defaultStartDate.setHours(9, 0, 0, 0);
|
defaultStartDate.setHours(9, 0, 0, 0);
|
||||||
const completionDate = ref(defaultEndDate);
|
|
||||||
|
const defaultEndDate = new Date(currentDate);
|
||||||
|
defaultEndDate.setHours(18, 0, 0, 0);
|
||||||
|
|
||||||
const startDate = ref(defaultStartDate);
|
const startDate = ref(defaultStartDate);
|
||||||
|
const completionDate = ref(defaultEndDate);
|
||||||
|
|
||||||
const snackbar = ref({
|
const snackbar = ref({
|
||||||
show: false,
|
show: false,
|
||||||
text: '',
|
text: '',
|
||||||
@@ -205,40 +211,24 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDateChange = (date, type = 'end') => {
|
const handleDateChange = (date, type = 'end') => {
|
||||||
if (date) {
|
if (!date) return;
|
||||||
|
|
||||||
const newDate = new Date(date);
|
const newDate = new Date(date);
|
||||||
if (type === 'end') {
|
if (type === 'end') {
|
||||||
newDate.setHours(18, 0, 0, 0);
|
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 {
|
} else {
|
||||||
newDate.setHours(9, 0, 0, 0);
|
newDate.setHours(9, 0, 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
startDate.value = newDate;
|
||||||
|
|
||||||
|
if (completionDate.value && newDate > completionDate.value) {
|
||||||
|
completionDate.value = newDate;
|
||||||
|
completionDate.value.setHours(18, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user