fix [P-255]: ограничил ввод дат в самом датепикере
This commit is contained in:
1 parent
99661b2271
commit
a39b962d0a
2 files changed
+59
-71
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user