P-47 file and time completed

This commit is contained in:
iriska-gri committed 2024-07-11 15:12:39 +03:00
1 parent a4661443db
commit 5b600c8091
6 files changed
+332 -266

No files matched your search

@@ -0,0 +1,154 @@
<template>
<v-col>
<v-file-input
label="Файлы"
chips
multiple
v-model="eventFiles"
density="compact"
variant="outlined"
@click.stop=""
>
<template v-slot:selection="{ fileNames }">
<template v-for="(fileName, index) in fileNames" :key="fileName">
<v-chip
v-if="index < 4"
class="me-2"
color="teal-darken-3"
size="small"
label
>
{{ fileName }}
</v-chip>
<span
v-else-if="index === 4"
class="text-overline text-grey-darken-3 mx-2"
>
+{{ files.length - 4 }} файла(ов)
</span>
</template>
</template>
</v-file-input>
</v-col>
</template>
<script>
import { computed, ref } from "vue";
import { get_name } from "@/utils/universal_functions";
export default {
props: {
files: {
type: Object,
default: () => {},
},
},
setup(props, { emit }) {
const propsFiles = computed({
get: () => props.files,
set: (value) => emit("update:files", value),
});
const arrFiles = ref([]);
const eventFiles = computed({
get() {
propsFiles.value.forEach((e) =>
{
arrFiles.value.push(
dataURLtoFile(
"data:text/plain;base64,aGVsbG8gd29ybGQ=",
get_name(decodeURI(e.file))
)
)}
);
return arrFiles.value;
},
set(newValue) {
let newFile = []
arrFiles.value = [];
if (newValue.length == 0) {
arrFiles.value = [];
propsFiles.value = [];
} else {
newValue.forEach((e) => {
arrFiles.value.push(e)
newFile.push(e)
});
}
emit("postFiles", newFile);
console.log(newValue, arrFiles.value, "newValue");
},
});
//
function dataURLtoFile(dataurl, filename) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, { type: mime });
}
const proverka = () => {
console.log('h');
}
// const eventFiles = computed({
// get() {
// if (propsFiles.value.length > 0) {
// propsFiles.value.forEach((e) =>
// files.value.push(
// dataURLtoFile(
// "data:text/plain;base64,aGVsbG8gd29ybGQ=",
// get_name(decodeURI(e.file))
// )
// )
// );
// // let file = dataURLtoFile(
// // "data:text/plain;base64,aGVsbG8gd29ybGQ=",
// // get_name(
// // decodeURI(propsFiles.value.event.files[0].file)
// // )
// // );
// // files.value.push(file);
// }
// return files.value;
// },
// set(newValue) {
// // console.log(newValue,'file')
// newValue.forEach((e) => {
// if (!files.value.some((l) => l.name == e.name.split(" ").join("_"))) {
// files.value.push(e);
// }
// });
// if (newValue.length == 0) {
// files.value = [];
// propsFiles.value = [];
// }
// },
// });
return {
eventFiles,
arrFiles,
proverka
};
},
};
</script>
<style></style>
@@ -1,79 +1,84 @@
<template>
<v-col lg="3" :class="`order-${order[0]}`">
<v-menu
v-model="menudate"
:close-on-content-click="false"
:nudge-right="40"
transition="scale-transition"
offset-y
>
<template v-slot:activator="{ props }">
<v-textarea
v-model="modelDate"
:value="formatComa(modelDate)"
density="compact"
no-resize
row-height="25"
rows="1"
variant="outlined"
v-bind="props"
readonly
>
<template v-slot:prepend-inner>
<v-icon
v-bind="props"
icon="mdi-calendar-today"
color="cyan-darken-3"
size="x-small"
/>
</template>
</v-textarea>
</template>
<v-col lg=3 :class="`order-${order[0]}`" >
<v-menu
v-model="menudate"
:close-on-content-click="false"
:nudge-right="40"
transition="scale-transition"
offset-y
>
<template v-slot:activator="{ props }">
<v-textarea
v-model="myDate"
:value="formatComa(myDate)"
density="compact"
no-resize
row-height="25"
rows="1"
variant="outlined"
v-bind="props"
readonly
>
<template v-slot:prepend-inner>
<v-icon
v-bind="props"
icon="mdi-calendar-today"
color="cyan-darken-3"
size="x-small"
/>
</template>
</v-textarea>
</template>
<v-locale-provider locale="ru">
<v-date-picker
v-model="myDate"
show-adjacent-months
hide-header
border
no-time
:max="new Date(max_date)"
:min="new Date(min_date).setDate(new Date(min_date).getDate()-1)"
></v-date-picker>
</v-locale-provider>
</v-menu>
</v-col>
<v-col class="flex-grow-0 " :class="`order-${order[1]}`">
<v-textarea
density="compact"
no-resize
row-height="25"
width="75"
rows="1"
readonly
variant="outlined"
<v-locale-provider locale="ru">
<v-date-picker
v-model="modelDate"
show-adjacent-months
hide-header
border
no-time
:max="order[0] == 2 ? new Date(propsDateEvent.date_end) : false"
:min="
order[0] == 2
? false
: new Date(
new Date(propsDateEvent.date_start).setDate(
new Date(propsDateEvent.date_start).getDate() - 1
)
)
"
></v-date-picker>
</v-locale-provider>
</v-menu>
</v-col>
<v-col class="flex-grow-0" :class="`order-${order[1]}`">
<v-textarea
density="compact"
no-resize
row-height="25"
width="75"
rows="1"
readonly
variant="outlined"
v-model="timeEvent"
:active="menutime"
:focus="menutime"
>
</v-textarea>
<v-menu
v-model="menutime"
:close-on-content-click="false"
activator="parent"
transition="scale-transition"
>
<v-time-picker
v-if="menutime"
v-model="timeEvent"
:active="menutime"
:focus="menutime"
>
</v-textarea>
<v-menu
v-model="menutime"
:close-on-content-click="false"
activator="parent"
transition="scale-transition"
>
<v-time-picker
v-if="menutime"
v-model="timeEvent"
full-width
format="24hr"
></v-time-picker>
</v-menu>
</v-col>
full-width
format="24hr"
></v-time-picker>
</v-menu>
</v-col>
</template>
<script>
@@ -81,74 +86,76 @@ import { formatComa, formatDash } from "@/utils/universal_functions";
import { ref, computed } from "vue";
export default {
props: {
date: {
type: String,
default: "2024-07-01",
},
max_date: {
type: String,
default: '2555-07-01'
},
min_date: {
type: String,
default: "1970-01-01"
dateEvent: {
type: Object,
default: () => {},
},
order: {
type: Array,
default: [0, 0]
}
type: Array,
default: [0, 0],
},
},
setup(props, { emit }) {
const menudate = ref(false);
const menutime = ref(false);
const myDate = computed({
const propsDateEvent = computed({
get: () => props.dateEvent,
set: (value) => emit("update:dateEvent", value),
});
const modelDate = computed({
get() {
return props.date;
let date =
props.order[0] == 2
? new Date(propsDateEvent.value.date_start)
: new Date(propsDateEvent.value.date_end);
return date;
},
set(newValue) {
// console.log( , 'newValue')
emit(
"update:date",
new Date(formatDash(newValue) + "T" + timeEvent.value)
);
if (props.order[0] == 2)
propsDateEvent.value.date_start = new Date(
formatDash(newValue) + "T" + timeEvent.value
);
if (props.order[0] == 4)
propsDateEvent.value.date_end = new Date(
formatDash(newValue) + "T" + timeEvent.value
);
},
});
const timeEvent = computed({
get() {
return `${new Date(props.date).getHours()}:${String(
new Date(props.date).getMinutes()
let time =
props.order[0] == 2
? propsDateEvent.value.date_start
: propsDateEvent.value.date_end;
return `${new Date(time).getHours()}:${String(
new Date(time).getMinutes()
).padStart(2, "0")}`;
},
set(newValue) {
emit(
"update:date",
new Date(formatDash(myDate.value) + "T" + newValue)
);
// console.log(formatDash(myDate.value))
// emit("update:date", newValue);
// let timeParts = newValue.split(":");
// let h = new Date(props.date).setHours(
// parseInt(timeParts[0], 10),
// parseInt(timeParts[1], 10)
// );
// emit("update:date", new Date(h));
// console.log(newValue, new Date(h), '22222222222222222')
if (props.order[0] == 2)
propsDateEvent.value.date_start = new Date(
formatDash(modelDate.value) + "T" + newValue
);
if (props.order[0] == 4)
propsDateEvent.value.date_end = new Date(
formatDash(modelDate.value) + "T" + newValue
);
},
});
return {
propsDateEvent,
modelDate,
menudate,
menutime,
formatComa,
timeEvent,
myDate,
};
},
};
@@ -16,7 +16,11 @@
return-object
>
<template v-slot:selection="{ item }">
<v-chip>
<v-chip
class="me-2"
color="teal-darken-3"
size="small"
label>
<span> {{ item.title }}</span>
<v-icon
v-if="item.value != accountStore.user.is_idEmployee"
@@ -142,24 +146,17 @@ export default {
const selectedStaff = computed({
get() {
let selected = [];
props.staff.forEach((e) => {
console.log(e, 'eeeeeeeeeeeee')
if (e.employees.length != 1 && e.employees.every((n) => n[props.okey] == true)) {
console.log(e.employees.length, 'if')
e[props.okey] = true;
selected.push(e);
}
else if (e.employees.length == 1 ) {
if (
e.employees.length != 1 &&
e.employees.every((n) => n[props.okey] == true)
) {
e[props.okey] = true;
selected.push(e);
} else if (e.employees.length == 1) {
e[props.okey] = true;
selected.push(...e.employees.filter((n) => n[props.okey] == true));
}
else {
console.log(e, 'else eeeeeeeeeeeee')
} else {
e[props.okey] = false;
selected.push(...e.employees.filter((n) => n[props.okey] == true));
}
@@ -168,7 +165,6 @@ export default {
},
set(item) {
// Если нажимать на пользователя с disable, то срабатывает
// set и отправляет данные которые не нужны, но выдает только в виде массива.
// Остальные данные передаются объектом, кроме выбора ВСЕХ ПОЛЬЗОВАТЕЛЕЙ, для него написан отдельный клик на обработку
@@ -11,7 +11,7 @@
<v-col class="d-flex flex-column">
<v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
<my-helper :pretext= "propsCalendar " />
Название
</v-col>
<v-col>
@@ -121,7 +121,6 @@ export default {
let ind = propsCalendar.value.participant.find(
(l) => l.participant_calendar == e.id
);
console.log(indx, ind, 'inxind')
if (idPart.okey == "editor") {
ind.editor = e.editor;
} else {
@@ -88,24 +88,23 @@
</v-col>
<v-col class="d-flex flex-column">
<v-row no-gutters class="gap">
<!-- <time-select
:date="propsEvent.event.date_start"
:max_date="propsEvent.event.date_end"
@update:date="propsEvent.event.date_start = $event"
<time-select
:dateEvent="propsEvent.event"
@update:dateEvent="propsEvent.event = $event"
:order="[2, 1]"
/> -->
<!-- -->
<!-- -->
/>
<v-col class="order-3 flex-grow-0">
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
</v-col>
<!-- <time-select
:date="propsEvent.event.date_end"
<!-- @update:dateEvent="propsEvent.event.date_start = $event" -->
<time-select
:dateEvent="propsEvent.event"
:order="[4, 5]"
:min_date="propsEvent.event.date_start"
@update:date="propsEvent.event.date_end = $event"
/> -->
@update:dateEvent="propsEvent.event = $event"
/>
</v-row>
<v-row no-gutters>
<v-col>
@@ -123,38 +122,13 @@
</v-col>
<v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Файлы </v-col>
<v-col>
<v-file-input
label="Файлы"
chips
multiple
v-model="eventFiles"
variant="outlined"
>
</v-file-input>
<!-- <v-file-input
label="Файлы"
chips
multiple
v-model="eventFiles"
>
<template v-slot:selection="{ fileNames }">
<v-chip v-for="x in fileNames" :key=x>
<span> {{ x }}</span>
<v-icon
icon="mdi-close-circle"
size="x-small"
class="ml-3"
@click="proverka()"
/>
</v-chip>
</template>
</v-file-input> -->
</v-col></v-row
>
<uploading-file
:files="propsEvent.event.files"
@update:files="propsEvent.event.files = $event"
@postFiles="postFiles"
/>
</v-row>
<v-row no-gutters class="align-center">
<v-col>
<v-textarea
@@ -172,15 +146,17 @@
</template>
<script>
import { computed, ref, watch } from "vue";
import { computed, ref } from "vue";
import { axiosApiInstance } from "@/utils/axios-api";
import DialogCreate from "@/components/calendar_of_events/UI_calendar/dialogCreate.vue";
import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue";
import { formatComa, get_name } from "@/utils/universal_functions";
import { formatComa } from "@/utils/universal_functions";
import TimeSelect from "@/components/calendar_of_events/UI_calendar/timeSelect.vue";
import { useAccountStore } from "@/store/AccountStore";
import UploadingFile from "@/components/UI/defaultportal/uploading-file.vue";
export default {
components: { calendarCreateSelect, DialogCreate, TimeSelect },
components: { calendarCreateSelect, DialogCreate, TimeSelect, UploadingFile },
props: {
eventCalendar: {
@@ -195,8 +171,6 @@ export default {
set: (value) => emit("update:eventCalendar", value),
});
const staff = ref([]);
axiosApiInstance
@@ -211,21 +185,18 @@ export default {
const newStaff = computed({
get() {
let ns = [];
console.log(propsEvent.value.event.participant, '------------propsEvent.value.event.participant')
let indCal = propsEvent.value.mycalendars.findIndex(
(e) => e.id == calendar.value[0].id
);
staff.value.forEach((e) => {
let emp = { ...e };
emp.employees = e.employees.filter((n) => {
if (
n.id == accountStore.user.is_idEmployee ||
propsEvent.value.event.participant.some((e) => n.id == e)
) {
n.selected = true;
}
@@ -250,63 +221,14 @@ export default {
// });
// }
});
console.log(ns, " ns---------------");
return ns;
},
});
function dataURLtoFile(dataurl, filename) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, { type: mime });
}
const files = ref([]);
const eventFiles = computed({
get() {
if (propsEvent.value.event.files.length > 0) {
propsEvent.value.event.files.forEach((e) =>
files.value.push(
dataURLtoFile(
"data:text/plain;base64,aGVsbG8gd29ybGQ=",
get_name(decodeURI(e.file))
)
)
);
// let file = dataURLtoFile(
// "data:text/plain;base64,aGVsbG8gd29ybGQ=",
// get_name(
// decodeURI(propsEvent.value.event.files[0].file)
// )
// );
// files.value.push(file);
}
return files.value;
},
set(newValue) {
// console.log(newValue,'file')
newValue.forEach((e) => {
if (!files.value.some((l) => l.name == e.name.split(" ").join("_"))) {
files.value.push(e);
}
});
if (newValue.length == 0) {
files.value = [];
propsEvent.value.event.files = [];
}
},
});
const postFiles = (f) => {
files.value = f;
console.log(f, "postFiles");
};
const calendar = computed({
get() {
@@ -364,29 +286,25 @@ export default {
const part = new Set();
const returnIdParticant = (idPart) => {
idPart.staff.forEach((e)=> {
if(e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
propsEvent.value.event.participant.push(e.id)
}
else {
idPart.staff.forEach((e) => {
if (
e.selected == true &&
!propsEvent.value.event.participant.includes(e.id)
) {
propsEvent.value.event.participant.push(e.id);
} else {
let ind = propsEvent.value.event.participant.findIndex(
(l) => l == e.id
)
(l) => l == e.id
);
if (ind != -1) {
propsEvent.value.event.participant.splice(ind, 1);
}
if (ind != -1) {
propsEvent.value.event.participant.splice(ind, 1);
}
}
})
});
};
const cbSelect = (item, arr) => {
item.forEach((e) => {
if (!("employees" in e)) {
if (!propsEvent.value.event.participant.includes(e.id)) {
@@ -430,10 +348,6 @@ export default {
});
};
const proverka = () => {
console.log("Проверка");
};
return {
menudate,
titleCard,
@@ -444,10 +358,8 @@ export default {
staff,
newStaff,
returnIdParticant,
eventFiles,
postFiles,
postData,
files,
proverka,
};
},
};
@@ -38,11 +38,9 @@ export default {
const selectdate = ref(new Date())
const hol = ['2024-05-09', '2024-05-11']
const addWeekend = () => {
console.log(week);
}
addWeekend()
onMounted(()=>{
cal.value.$el.querySelectorAll(".v-date-picker-month__day").forEach((e)=>{