P-42 Не забыть исправить проверку валидации

This commit is contained in:
iriska-gri committed 2024-06-26 14:41:52 +03:00
1 parent 8d8ad9390e
commit 90994e83de
12 files changed
+231 -321

No files matched your search

@@ -7,7 +7,6 @@
<v-form @submit.prevent="submit">
<v-row no-gutters class="justify-center">
<v-col lg="8">
<v-text-field
v-model="form.fio"
:counter="10"
@@ -51,10 +50,9 @@
<script>
import { ref } from "vue";
import { useAlertStore } from '@/store/useAlertStore'
import { useAlertStore } from "@/store/useAlertStore";
import { clearAxios } from "@/utils/axios-api";
export default {
props: {
idVacations: {
@@ -64,12 +62,11 @@ export default {
},
setup(props) {
const form = ref({ fio: "", email: "", tel: "", text: "" });
const feedalert = useAlertStore().alert
const feedalert = useAlertStore().alert;
const req = (val) => {
return !!val || "Поле обязательно"
}
return !!val || "Поле обязательно";
};
const rules = {
fio: [
@@ -93,11 +90,11 @@ export default {
"data",
JSON.stringify({ ...form.value, vacancy_id: props.idVacations })
);
if (file.value !==null) {
if (file.value !== null) {
postFile.append("file", file.value[0]);
}
// Отправляет сообщение об отправлении при отсутсвии валидации!!!!!!!!!!!!!!!!!!!!!!!!!
clearAxios
.post(`api/about_inspection/postresponsevacancy/`, postFile)
.then((data) => {
@@ -105,7 +102,6 @@ export default {
feedalert.text = data.data;
feedalert.color = "teal-lighten-4";
feedalert.ico = "mdi-email-outline";
});
};
@@ -72,7 +72,7 @@
</v-row>
</v-card>
</v-col>
<v-col class="bg-green">
<v-col>
<v-btn @click="drawer_right = !drawer_right">
{{ drawer_right }}
</v-btn>
@@ -1,152 +0,0 @@
<template>
<v-select
v-model="selectedStaff"
:items="staff"
label="Выберите из списка или найдите по ФИО"
item-title="department"
item-value="department"
multiple
hide-details
variant="outlined"
density="compact"
class="max-height-select"
return-object
>
<template v-slot:selection="{ item, index }">
<!-- <v-chip v-if="(index < 1) && allStaff">
<span>Выбраны все сотрудники</span>
</v-chip> -->
<v-chip>
<span> {{ item.value }}</span>
</v-chip>
<!-- <span
v-if="index === 2"
class="text-grey text-caption align-self-center"
>
(+{{ selectedFruits.length - 2 }} others)
</span> -->
</template>
<template v-slot:prepend-item>
<v-list-item @click="toggle" class="text-body-2">
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
<template v-slot:prepend>
<v-checkbox-btn
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
:indeterminate="onePlusStaff && !allStaff"
:model-value="allStaff"
></v-checkbox-btn>
</template>
</v-list-item>
<v-divider class="mt-2"></v-divider>
</template>
<template v-slot:item="{ props, item }">
<v-list-group v-bind="props" :value="item.raw.department">
<template v-slot:activator="{ props }">
<v-list-item
v-bind="props"
@click.stop=""
density="compact"
class="text-body-2"
>
</v-list-item>
</template>
<v-list-item
v-for="(x, i) in item.raw.staff"
:key="i"
:value="x.fio"
@click.stop="selectFIO(x, item.raw.id)"
density="compact"
>
<span class="text-body-2"> {{ x.fio }} </span>
</v-list-item>
</v-list-group>
<!-- <v-list-item v-bind="props" :title="item.raw.department">
<template v-slot:prepend>
<v-checkbox-btn
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
:indeterminate="onePlusStaff && !allStaff"
:model-value="allStaff"
></v-checkbox-btn>
</template>
</v-list-item> -->
</template>
</v-select>
</template>
<script>
import { ref, onMounted, computed } from "vue";
export default {
setup() {
const staff = ref([
{
department: "ОКТП",
id: 1,
staff: [{ fio: "ГИС", id: 1 }, { fio: "СВВ", id: 2 }, { fio: "ФА", id: 3 }, { fio: "АА", id: 4 }],
},
{ department: "ОВТП", id: 2, staff: [{ fio: "ЩВ", id: 1 }, { fio: "ДК", id: 2 }] },
]);
const selectedStaff = ref([]);
const allStaff = computed(
() => selectedStaff.value.length === staff.value.length
);
const onePlusStaff = computed(() => selectedStaff.value.length > 0);
function toggle() {
if (allStaff.value) {
selectedStaff.value = [];
} else {
selectedStaff.value = staff.value.slice();
}
}
function selectFIO(user, dep) {
let ob = staff.value.find(el => el.id == dep)
ob['chek'] = false
let indx = selectedStaff.value.findIndex((i) => i.id == dep)
if (indx ==-1) {
selectedStaff.value.push(ob)
}
console.log(ob, 'ki')
}
return {
staff,
selectedStaff,
allStaff,
onePlusStaff,
selectFIO,
toggle,
};
},
};
</script>
<style>
.max-height-select .v-field__input {
max-height: 60px; /* Установите желаемую максимальную высоту */
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
overflow-x: hidden;
margin: 5px;
}
</style>
@@ -100,6 +100,10 @@ export default {
type: Array,
default: () => [],
},
editor: {
type: Boolean,
default: false,
},
},
setup(props, { emit }) {
@@ -132,6 +136,7 @@ export default {
});
const selectedStaff = computed(() => {
let selected = [];
let idEmployees = [];
@@ -139,7 +144,7 @@ export default {
e.employees
.filter((n) => n.selected == true)
.map((res) => {
idEmployees.push({ participant_calendar: res.id });
idEmployees.push({ participant_calendar: res.id, editor: props.editor?1:props.participant.editor });
});
if (e.employees.every((n) => n.selected == true)) {
e.selected = true;
@@ -149,8 +154,10 @@ export default {
selected.push(...e.employees.filter((n) => n.selected == true));
}
});
emit("returnIdParticant", idEmployees);
// console.log(selected, accountStore.user.is_idEmployee, props.editor, selected.some(e=> e.id== accountStore.user.is_idEmployee), '222222222222222222222222222222222222')
return selected;
});
@@ -1,10 +1,9 @@
<template>
<v-dialog v-model="dialog_create_calendar" min-width="636" max-width="800">
<v-card min-height="436" class="pa-3">
{{ calendar }}
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
{{
calendar.hasOwnProperty("id")
propsCalendar.hasOwnProperty("id")
? "Редактирование календаря"
: "Новый календарь"
}}
@@ -15,110 +14,128 @@
@click="dialog_create_calendar = false"
></v-icon>
</v-card-title>
<v-card-text class="d-flex py-0 px-3">
<v-row no-gutters class="flex-column">
<v-col class="d-flex flex-column">
<v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey" lg="2">
Название
</v-col>
<v-col>
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="1"
variant="outlined"
hide-details
v-model="calendar.cl_name"
></v-textarea></v-col
></v-row>
<v-row no-gutters class="align-center pt-3">
<v-col class="text-body-2 text-text_grey" lg="2"> Цвет </v-col>
<v-col v-for="(x, key) in color" :key="key">
<v-avatar
class="cursor-pointer"
@click="colorPik(x, key)"
size="x-small"
:color="x"
:variant="
calendar.cl_color === null
? 'flat'
: calendar.cl_color === x
? 'flat'
: 'tonal'
"
/> </v-col
></v-row>
<v-form @submit.prevent="postCalendar">
<v-card-text class="d-flex py-0 px-3">
<v-row no-gutters class="flex-column">
<v-col class="d-flex flex-column">
<v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey" lg="2">
Название
</v-col>
<v-col>
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="1"
variant="outlined"
v-model="propsCalendar.cl_name"
:rules="rules.cl_name"
></v-textarea></v-col
></v-row>
<v-row no-gutters class="align-center pt-3">
<v-col class="text-body-2 text-text_grey" lg="2"> Цвет </v-col>
<v-col v-for="(x, key) in color" :key="key">
<v-avatar
class="cursor-pointer"
@click="colorPik(x, key)"
size="x-small"
:color="x"
:variant="
propsCalendar.cl_color === null
? 'flat'
: propsCalendar.cl_color === x
? 'flat'
: 'tonal'
"
/> </v-col
></v-row>
<v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey" lg="2">
Участники
</v-col>
<v-col>
<calendar-create-select
:participant="propsCalendar.participant"
@returnIdParticant="returnIdParticant"
/> </v-col
></v-row>
</v-col>
<v-col class="d-flex flex-grow-0">
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="4"
variant="outlined"
shaped
no-resize
:rules="rules.cl_descr"
v-model="propsCalendar.cl_descr"
></v-textarea>
</v-col>
<v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey" lg="2">
Участники
Редакторы
</v-col>
<v-col>
<calendar-create-select
:participant="calendar.participant"
:editor="true"
:participant="
propsCalendar.participant.filter((e) => e.editor == 1)
"
@returnIdParticant="returnIdParticant"
/> </v-col
></v-row>
</v-col>
<v-col class="d-flex flex-grow-0">
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="4"
variant="outlined"
hide-details
shaped
no-resize
v-model="calendar.cl_descr"
></v-textarea>
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-btn
class="text-subtitle-1"
elevation="0"
width="150"
@click="dialog_create_calendar = false"
>Отменить</v-btn
>
<v-btn
class="text-subtitle-1 font-weight-regular"
color="btn_text"
variant="flat"
elevation="0"
width="150"
@click="postCalendar"
>
{{ calendar.hasOwnProperty("id") ? "Редактировать" : "Создать" }}
</v-btn>
</v-card-actions>
<!-- <v-row no-gutters class="gap flex-column">
v-col*
</v-row> -->
<!-- <v-row>
<v-col>
<v-textarea
v-model="newcalendar.cl_name"
placeholder="Название календаря"
no-resize
rows="1"
hide-details
density="compact"
/>
</v-col>
</v-row>
{{newcalendar}} -->
</v-col>
<v-col lg="1" class="text-center">
<v-tooltip location="top">
<template v-slot:activator="{ props }">
<v-icon v-bind="props" icon="mdi-help-circle-outline" />
</template>
<div class="custom-tooltip">
Участники с доступом редактирования смогут изменять поля
календаря, а также редактировать и удалять события
</div>
</v-tooltip>
</v-col>
</v-row>
</v-row>
</v-card-text>
<v-card-actions class="justify-end">
<v-btn
icon="mdi-delete"
variant="tonal"
rounded
size="36px"
:disabled="!propsCalendar.hasOwnProperty('id')"
@click="delCalendar(propsCalendar.id)"
/>
<v-btn
class="text-subtitle-1"
elevation="0"
width="150"
@click="dialog_create_calendar = false"
color="btn_gray"
variant="flat"
>Отменить</v-btn
>
<v-btn
class="text-subtitle-1 font-weight-regular"
color="btn_text"
variant="flat"
elevation="0"
width="150"
type="postCalendar"
>
{{
propsCalendar.hasOwnProperty("id") ? "Редактировать" : "Создать"
}}
</v-btn>
</v-card-actions>
</v-form>
</v-card>
</v-dialog>
</template>
@@ -128,6 +145,7 @@ import { computed, ref } from "vue";
import { axiosApiInstance } from "@/utils/axios-api";
import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue";
import { useAlertStore } from "@/store/useAlertStore";
import { useAccountStore } from "@/store/AccountStore";
export default {
components: { calendarCreateSelect },
@@ -140,31 +158,17 @@ export default {
calendar: {
type: Object,
default: {
cl_name: "",
participant: [{ editor: true, participant_calendar: 0 }],
cl_color: "",
cl_descr: "",
},
default: {},
},
},
setup(props, { emit }) {
const postParticant = {};
const accountStore = useAccountStore();
// Возможно можно сделать запись короче
const returnIdParticant = (idPart) => {
console.log(props.calendar, "props.calendar");
let g = {
participant: [{participant_calendar: 107 }],
cl_name: "проба2",
cl_color: "lime",
cl_descr: "описание",
};
postParticant.value = g
// postParticant.value = { ...props.calendar, participant: idPart };
postParticant.value = { ...props.calendar, participant: idPart };
};
const dialog_create_calendar = computed({
@@ -172,20 +176,45 @@ export default {
set: (value) => emit("update:opendialog", value),
});
const feedalert = useAlertStore().alert;
const propsCalendar = computed({
get: () => props.calendar,
set: (value) => emit("update:calendar", value),
});
const feedalert = useAlertStore().alert;
const rules = {
cl_name: [(val) => req(val)],
cl_descr: [(val) => req(val)],
};
const postCalendar = () => {
console.log(postParticant.value, 'postParticant.valuepostParticant.value')
axiosApiInstance
.post(`api/calendar_of_events/my_calendars/`, postParticant.value)
.then((result) => {
feedalert.alert = true;
feedalert.text = result.data.mess;
feedalert.ico = "mdi-check";
feedalert.color = "green-darken-4";
emit("getCalendar");
});
dialog_create_calendar.value = false;
if (
postParticant.value.participant.some(
(e) => e.participant_calendar == accountStore.user.is_idEmployee
)
) {
axiosApiInstance
.post(`api/calendar_of_events/my_calendars/`, postParticant.value)
.then((result) => {
feedalert.alert = true;
feedalert.text = result.data.mess;
feedalert.ico = "mdi-check";
feedalert.color = "green-darken-4";
emit("getCalendar");
if (result.data.mess != "Ошибка валидации полей") {
dialog_create_calendar.value = false;
}
});
} else {
feedalert.alert = true;
feedalert.text = "Вы не можете удалить себя из редакторов";
feedalert.color = "red-darken-2";
feedalert.ico = "mdi-alert-outline";
}
};
const color = [
@@ -207,13 +236,33 @@ export default {
];
const colorPik = (col) => {
if (props.calendar.cl_color === col) {
props.calendar.cl_color = null;
if (propsCalendar.value.cl_color === col) {
propsCalendar.value.cl_color = null;
} else {
props.calendar.cl_color = col;
propsCalendar.value.cl_color = col;
}
};
const delCalendar = (idcal) => {
console.log(idcal, "idcal");
axiosApiInstance
.delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`)
.then((result) => {
feedalert.alert = true;
feedalert.text = result.data.mess;
feedalert.ico = "mdi-check";
feedalert.color = "orange-accent-1";
emit("getCalendar");
});
dialog_create_calendar.value = false;
};
const req = (val) => {
return !!val || "Поле обязательно";
};
return {
dialog_create_calendar,
@@ -221,9 +270,16 @@ export default {
color,
colorPik,
returnIdParticant,
propsCalendar,
delCalendar,
rules,
};
},
};
</script>
<style></style>
<style>
.custom-tooltip {
max-width: 350px; /* Установка максимальной ширины для подсказки */
}
</style>
@@ -74,10 +74,12 @@
</template>
</v-expansion-panel-text>
</v-expansion-panel>
<calendar-create
@update:opendialog="showDialog = $event"
:opendialog="showDialog"
:calendar="calendar"
@update:calendar="calendar = $event"
@getCalendar="$emit('getCalendar')"
/>
</v-expansion-panels>
@@ -110,10 +112,17 @@ export default {
const trans = ref(false);
const hover = ref(0);
const editCreatedCalendar = (cal) => {
calendar.value = cal;
if (cal === undefined) {
calendar.value = {
cl_name: "",
participant: [{ editor: true, participant_calendar: accountStore.user.is_idEmployee }],
cl_color: "red",
cl_descr: "",
};
} else {
calendar.value = cal;
}
showDialog.value = true;
};
@@ -136,7 +145,6 @@ export default {
openGroup,
trans,
hover,
};
},
};
@@ -117,7 +117,6 @@ export default {
axiosApiInstance
.get("api/calendar_of_events/calendarEvents/")
.then((data) => {
console.log(data.data,'-vvv');
data.data.forEach((e) => {
e.start = formaDashTime(e.start);
e.end = e.start;
@@ -22,16 +22,6 @@ export default {
set: (value) => emit("update:opendialog", value),
});
// const confirmation = () => {
// axiosApiInstance
// .get(`api/calendar_of_events/createEvents/`)
// .then((data) => {
// console.log(data.data, "datadatadatawwwwwwwwwwww");
// });
// };
// confirmation()
return {
dialog_create_event,
};
@@ -4,7 +4,7 @@
v-model="feedalert.alert"
:color="feedalert.color"
:icon="feedalert.ico"
variant="outlined"
>
<v-icon :icon="feedalert.ico" />
<span class="pl-2 text-body-2">
+4 -2
View File
@@ -45,7 +45,8 @@ export default createVuetify({
grey_white: '#FFFFFF', // Цвет для карточек
insert_table: '#FAFAFA',
btn_text: '#00897B', // фигма, текст кнопки с иконкой
select_list: '#E0EAE8'
select_list: '#E0EAE8',
btn_gray: '#E0E0E0'
},
},
dark: {
@@ -72,7 +73,8 @@ export default createVuetify({
grey_white: '#212121',
insert_table: '#323030',
btn_text: '#00897B',
select_list: '#E0EAE8'
select_list: '#E0EAE8',
btn_gray: '#E0E0E0'
},
},
options: {