P-51 Переделать годовой период

This commit is contained in:
iriska-gri committed 2024-07-23 16:57:28 +03:00
1 parent baaeca9220
commit 773a087236
3 files changed
+141 -47

No files matched your search

@@ -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({
@@ -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()"
/>
</v-locale-provider>
</v-menu>
@@ -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,
};
},
};
@@ -14,9 +14,9 @@
<!-- <my-helper :pretext="propsEvent.event" /> -->
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
Название
Название
</v-col>
<v-col>
<v-textarea
density="compact"
@@ -92,8 +92,12 @@
</v-col>
<v-col class="d-flex flex-column">
<v-row no-gutters class="gap">
<time-select
:rule="
returnPeriod != repeatRules[0].type
? returnPeriod.rule.freq
: -1
"
:chek="propsEvent.event.allday"
:order="[2, 1]"
:dateEvent="String(propsEvent.event.date_start)"
@@ -104,6 +108,11 @@
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
</v-col>
<time-select
:rule="
returnPeriod != repeatRules[0].type
? returnPeriod.rule.freq
: -1
"
:chek="propsEvent.event.allday"
:order="[4, 5]"
:dateEvent="String(propsEvent.event.date_end)"
@@ -113,7 +122,6 @@
</v-row>
<v-row no-gutters>
<period-events
:dateEventStart="propsEvent.event"
@update:dateEventStart="propsEvent.event = $event"
/>
@@ -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,
};
},
};