diff --git a/src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue b/src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue index a53cdbe9b..918f16b4f 100644 --- a/src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue +++ b/src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue @@ -136,6 +136,7 @@ export default { }); let actRule = rule.all(); + console.log(actRule, '--------------------------------actRule') let lastDateMonth = new Date( new Date(dayNextMonth.value).setDate( @@ -330,6 +331,35 @@ export default { } + if (ev.rule.freq == 0) { + console.log(ev, 'ev') + if (zeroTime(day.date) == zeroTime(ev.start_event)) { + return "rounded-e-lg" + } + // let weeknumS = + // ev.rule.byweekday[0].weekday == 6 + // ? 0 + // : ev.rule.byweekday[0].weekday + 1; + // let weeknumE = + // ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6 + // ? 0 + // : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1; + + // if (day.date.getDay() == weeknumS && weeknumS != weeknumE) { + // return "rounded-e-lg"; + // } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) { + // return "rounded-s-lg"; + // } else if ( + // day.date.getDay() != weeknumS && + // day.date.getDay() != weeknumE + // ) { + // return "rounded-sm"; + // } else { + // return "rounded-lg"; + // } + + return "rounded-sm" + } }; const dayNextMonth = computed({ diff --git a/src/front/src/components/calendar_of_events/UI_calendar/timeSelect.vue b/src/front/src/components/calendar_of_events/UI_calendar/timeSelect.vue index 301d211ad..c2307ac64 100644 --- a/src/front/src/components/calendar_of_events/UI_calendar/timeSelect.vue +++ b/src/front/src/components/calendar_of_events/UI_calendar/timeSelect.vue @@ -38,8 +38,8 @@ hide-header border no-time - :max="order[0] == 2 ? new Date(limitation) : false" - :min="order[0] == 2 ? false : minData()" + :max="order[0] == 2 ? new Date(limitation) : endMax()" + :min="order[0] == 2 ? startMin() : minData()" /> @@ -99,6 +99,10 @@ export default { type: Boolean, default: false, }, + rule: { + type: Number, + default: -1, + }, }, setup(props, { emit }) { @@ -127,7 +131,6 @@ export default { }, set(newValue) { - creatwdDate(modelDate.value, newValue); }, }); @@ -167,6 +170,28 @@ export default { return new Date(min); }; + const startMin = () => { + if (props.rule == 2) { + return new Date( + new Date(props.limitation).setDate( + new Date(props.limitation).getDate() - 7 + ) + ); + } + return false; + }; + + const endMax = () => { + if (props.rule == 2) { + return new Date( + new Date(props.limitation).setDate( + new Date(props.limitation).getDate() + 6 + ) + ); + } + return false; + }; + return { propsDateEvent, menudate, @@ -175,6 +200,8 @@ export default { formatComa, timeEvent, minData, + startMin, + endMax, }; }, }; diff --git a/src/front/src/components/calendar_of_events/event-create.vue b/src/front/src/components/calendar_of_events/event-create.vue index 6696cc1a7..4911898d5 100644 --- a/src/front/src/components/calendar_of_events/event-create.vue +++ b/src/front/src/components/calendar_of_events/event-create.vue @@ -14,9 +14,9 @@ - Название + Название - + - @@ -218,31 +226,19 @@ export default { type: Object, default: () => {}, }, - }, setup(props, { emit }) { - - - const createDialog = ref(null) + const createDialog = ref(null); const propsEvent = computed({ - get: () => - { + get: () => { + return props.eventCalendar; + }, - return props.eventCalendar - } - - , set: (value) => emit("update:eventCalendar", value), }); - - - - - - const repeatRules = [ { type: "Не повторять", rule: {}, id: 1 }, { type: "Каждый день", rule: { freq: 3 }, id: 2 }, @@ -298,6 +294,21 @@ export default { byweekday: getWeekNumbersBetweenDates(), }); } + if (value.freq == 1) { + newRulse = new RRule({ + ...value, + bymonthday: getMonthBetweenDates(), + dtstart: new Date(propsEvent.value.event.date_start), + }); + } + if (value.freq == 0) { + newRulse = new RRule({ + ...value, + bymonthday: getYearBetweenDates(), + dtstart: new Date(propsEvent.value.event.date_start), + bymonth: getNumberMonth(), + }); + } // byweekday: getWeekNumbersBetweenDates(), Object.keys(value).length == 0 ? (propsEvent.value.event.period = null) @@ -314,17 +325,13 @@ export default { RRule.SA, ]; - - const feedalert = useAlertStore().alert; const req = (val) => { - return !!val || "Поле обязательно"; }; const rules = { - name: [(val) => req(val)], }; @@ -397,19 +404,16 @@ export default { cl_name: propsEvent.value.mycalendars[ind].cl_name, cl_color: propsEvent.value.mycalendars[ind].cl_color, id: propsEvent.value.mycalendars[ind].id, - }); } else { selected.push({ cl_name: propsEvent.value.mycalendars[0].cl_name, cl_color: propsEvent.value.mycalendars[0].cl_color, id: propsEvent.value.mycalendars[0].id, - }); } if (propsEvent.value.event.calendar == null) propsEvent.value.event.calendar = propsEvent.value.mycalendars[0].id; - return selected; }, @@ -432,8 +436,6 @@ export default { } }; - - const returnIdParticant = (idPart) => { idPart.staff.forEach((e) => { if ( @@ -483,7 +485,6 @@ export default { const menudate = ref(false); const postData = (validate) => { - if (validate) { let postEvent = new FormData(); postEvent.append( @@ -542,6 +543,54 @@ export default { return rulesWeek; }; + const getMonthBetweenDates = () => { + const start = new Date(propsEvent.value.event.date_start); + const end = new Date(propsEvent.value.event.date_end); + let s = start.getDate(); + let e = end.getDate(); + + const dateNumbers = []; + for (let x = s; x <= e; x++) { + dateNumbers.push(x); + } + console.log(dateNumbers.length, "дни в месяце"); + return dateNumbers; + }; + + const getYearBetweenDates = () => { + const start = new Date(propsEvent.value.event.date_start); + const end = new Date(propsEvent.value.event.date_end); + let dates = getDatesBetweenDates(start, end); + let date = []; + dates.forEach((e) => date.push(new Date(e).getDate())); + return date; + }; + + const getNumberMonth = () => { + const start = new Date(propsEvent.value.event.date_start); + const end = new Date(propsEvent.value.event.date_end); + let sm = start.getMonth(); + let em = end.getMonth(); + let month = []; + month.push(sm + 1); + + if (!month.includes(em + 1)) month.push(em + 1); + console.log(month, "month"); + return month; + }; + + const getDatesBetweenDates = (startDate, endDate) => { + let dates = []; + let currentDate = new Date(startDate); + + while (currentDate <= endDate) { + dates.push(new Date(currentDate)); + currentDate.setDate(currentDate.getDate() + 1); + } + + return dates; + }; + const what = (w) => { console.log(w, "?????????????????????????????????"); }; @@ -563,19 +612,6 @@ export default { return diffInDays; }, }); - // const date1 = new Date(start); - // const date2 = new Date(end); - - // // One day in milliseconds - // const oneDay = 1000 * 60 * 60 * 24; - - // // Calculating the time difference between two dates - // const diffInTime = date2.getTime() - date1.getTime(); - - // // Calculating the no. of days between two dates - // const diffInDays = Math.round(diffInTime / oneDay); - - // return diffInDays; return { menudate, @@ -597,7 +633,8 @@ export default { periodDisplayRule, what, - createDialog + createDialog, + getMonthBetweenDates, }; }, };