P-47 Шаблон диалогового окна

This commit is contained in:
iriska-gri committed 2024-07-01 11:19:56 +03:00
1 parent 90994e83de
commit 6a5d5d642c
5 files changed
+370 -159

No files matched your search

@@ -1,120 +0,0 @@
<template>
<div>
<v-card-text class="text-center">
<span class="text-h4">Откликнуться на вакансию</span>
</v-card-text>
<v-card-text class="d-flex flex-column pt-0">
<form @submit.prevent="submit">
<v-row no-gutters class="justify-center">
<v-col lg="8">
<v-text-field
v-model="name.value.value"
:counter="10"
:error-messages="name.errorMessage.value"
label="Фамилия, имя, отчество"
/>
<v-row no-gutters class="gap">
<v-col>
<v-text-field
v-model="email.value.value"
:error-messages="email.errorMessage.value"
label="E-mail или почта Lotus"
/>
</v-col>
<v-col>
<v-text-field
v-model="phone.value.value"
:counter="7"
:error-messages="phone.errorMessage.value"
label="Телефон"
/>
</v-col>
</v-row>
<v-textarea
v-model="message.value.value"
no-resize
rows="4"
label="Сопроводительное письмо"
/>
<v-file-input label="Резюме" hide-details v-model="responseFiles" />
<v-btn block type="submit" class="mt-4 text-none" color="btn_text">
Отправить
</v-btn>
</v-col>
</v-row>
</form>
</v-card-text>
</div>
</template>
<script>
import { ref } from "vue";
import { useField, useForm } from "vee-validate";
import * as yup from "yup";
import { clearAxios } from "@/utils/axios-api";
export default {
props: {
idVacations: {
type: Number,
default: -1
}
},
setup(props) {
const responseFiles = ref('')
const { handleSubmit, handleReset } = useForm({
validationSchema: yup.object({
email: yup
.string()
.email("Введите корректный email")
.required("Поле обязательно для заполнения"),
name: yup
.string()
.matches(/^[а-яА-ЯЁё]+$/, "Имя должно содержать только русские буквы")
.required("Поле обязательно для заполнения"),
phone: yup
.string()
.matches(
/^[[\d-]*\d[\d-]*$/,
"Номер телефона должен содержать только цифры"
)
.required("Поле обязательно для заполнения"),
message: yup.string(),
}),
});
const name = useField("name");
const phone = useField("phone");
const email = useField("email");
const message = useField("message");
const submit = handleSubmit((values) => {
const postFile = new FormData()
postFile.append("file", responseFiles.value);
postFile.append("resp", JSON.stringify(values));
postFile.append("id", JSON.stringify(props.idVacations));
clearAxios
.post(`api/about_inspection/postresponsevacancy/`, postFile)
.then((data) => {
});
handleReset()
alert(JSON.stringify(values, null, 2));
});
return {
name,
phone,
email,
message,
submit,
responseFiles
};
},
};
</script>
@@ -4,7 +4,7 @@
<span class="text-h4">Откликнуться на вакансию</span> <span class="text-h4">Откликнуться на вакансию</span>
</v-card-text> </v-card-text>
<v-card-text class="d-flex flex-column pt-0"> <v-card-text class="d-flex flex-column pt-0">
<v-form @submit.prevent="submit"> <v-form ref="form_vacancies" @submit.prevent="submit">
<v-row no-gutters class="justify-center"> <v-row no-gutters class="justify-center">
<v-col lg="8"> <v-col lg="8">
<v-text-field <v-text-field
@@ -83,8 +83,12 @@ export default {
}; };
const file = ref(null); const file = ref(null);
const form_vacancies = ref(null)
const submit = () => { const submit = () => {
if(form_vacancies.value.isValid) {
const postFile = new FormData(); const postFile = new FormData();
postFile.append( postFile.append(
"data", "data",
@@ -103,6 +107,7 @@ export default {
feedalert.color = "teal-lighten-4"; feedalert.color = "teal-lighten-4";
feedalert.ico = "mdi-email-outline"; feedalert.ico = "mdi-email-outline";
}); });
}
}; };
return { return {
@@ -0,0 +1,212 @@
<template>
<v-card min-height="436" class="pa-3 ">
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
{{ title }}
<v-icon
icon="mdi-close cursor-pointer"
size="small"
color="grey"
@click="$emit('closeDialog')"
/>
</v-card-title>
<v-form ref="form_valid" @submit.prevent="transformation">
<v-card-text class="d-flex px-3">
<slot name="card_text"></slot>
</v-card-text>
<v-card-actions class="justify-end">
<v-btn
icon="mdi-delete"
variant="tonal"
rounded
size="36px"
:disabled="!newOrOld"
@click="$emit('delObject')"
/>
<v-btn
class="text-subtitle-1"
elevation="0"
width="150"
@click="$emit('closeDialog')"
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="transformation"
>
{{
newOrOld? "Создать" : "Редактировать"
}}
</v-btn>
</v-card-actions>
</v-form>
<!--
<v-form ref="form_calendar" @submit.prevent="postCalendar">
<v-card-text class="d-flex 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 pb-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 pb-3">
<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
:editor="true"
:participant="
propsCalendar.participant.filter((e) => e.editor == 1)
"
@returnIdParticant="returnIdParticant"
/>
</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>
</template>
<script>
import { ref } from "vue";
export default {
props: {
title: {
type: String,
default: "",
},
newOrOld: {
type: Boolean,
default: false,
}
},
setup(props, {emit}) {
const form_valid = ref(null);
const transformation = () => {
emit("postData", form_valid.value)
}
return {
form_valid,
transformation
}
},
};
</script>
<style></style>
@@ -1,6 +1,6 @@
<template> <template>
<v-dialog v-model="dialog_create_calendar" min-width="636" max-width="800"> <v-dialog v-model="dialog_create_calendar" min-width="636" max-width="800">
<v-card min-height="436" class="pa-3"> <!-- <v-card min-height="436" class="pa-3">
<v-card-title class="pr-0 pl-2 d-flex justify-space-between"> <v-card-title class="pr-0 pl-2 d-flex justify-space-between">
{{ {{
propsCalendar.hasOwnProperty("id") propsCalendar.hasOwnProperty("id")
@@ -14,8 +14,8 @@
@click="dialog_create_calendar = false" @click="dialog_create_calendar = false"
></v-icon> ></v-icon>
</v-card-title> </v-card-title>
<v-form @submit.prevent="postCalendar"> <v-form ref="form_calendar" @submit.prevent="postCalendar">
<v-card-text class="d-flex py-0 px-3"> <v-card-text class="d-flex px-3">
<v-row no-gutters class="flex-column"> <v-row no-gutters class="flex-column">
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<v-row no-gutters class="align-center"> <v-row no-gutters class="align-center">
@@ -33,7 +33,7 @@
:rules="rules.cl_name" :rules="rules.cl_name"
></v-textarea></v-col ></v-textarea></v-col
></v-row> ></v-row>
<v-row no-gutters class="align-center pt-3"> <v-row no-gutters class="align-center pb-3">
<v-col class="text-body-2 text-text_grey" lg="2"> Цвет </v-col> <v-col class="text-body-2 text-text_grey" lg="2"> Цвет </v-col>
<v-col v-for="(x, key) in color" :key="key"> <v-col v-for="(x, key) in color" :key="key">
<v-avatar <v-avatar
@@ -51,7 +51,7 @@
/> </v-col /> </v-col
></v-row> ></v-row>
<v-row no-gutters class="align-center"> <v-row no-gutters class="align-center pb-3">
<v-col class="text-body-2 text-text_grey" lg="2"> <v-col class="text-body-2 text-text_grey" lg="2">
Участники Участники
</v-col> </v-col>
@@ -136,19 +136,113 @@
</v-btn> </v-btn>
</v-card-actions> </v-card-actions>
</v-form> </v-form>
</v-card> </v-card> -->
<dialog-create
:title="titleCard"
:newOrOld="newCalendar"
@closeDialog="dialog_create_calendar = false"
@delObject="delCalendar(propsCalendar.id)"
@postData="postCalendar"
>
<template v-slot:card_text>
<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 pb-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 pb-3">
<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
:editor="true"
:participant="
propsCalendar.participant.filter((e) => e.editor == 1)
"
@returnIdParticant="returnIdParticant"
/>
</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>
</template>
</dialog-create>
</v-dialog> </v-dialog>
</template> </template>
<script> <script>
import { computed, ref } from "vue"; import { computed, ref, watch } from "vue";
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from "@/utils/axios-api";
import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue"; import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue";
import { useAlertStore } from "@/store/useAlertStore"; import { useAlertStore } from "@/store/useAlertStore";
import { useAccountStore } from "@/store/AccountStore"; import { useAccountStore } from "@/store/AccountStore";
import DialogCreate from "./UI_calendar/dialogCreate.vue";
export default { export default {
components: { calendarCreateSelect }, components: { calendarCreateSelect, DialogCreate },
props: { props: {
opendialog: { opendialog: {
@@ -164,6 +258,7 @@ export default {
setup(props, { emit }) { setup(props, { emit }) {
const postParticant = {}; const postParticant = {};
const form_calendar = ref(null);
const accountStore = useAccountStore(); const accountStore = useAccountStore();
// Возможно можно сделать запись короче // Возможно можно сделать запись короче
@@ -186,34 +281,52 @@ export default {
cl_name: [(val) => req(val)], cl_name: [(val) => req(val)],
cl_descr: [(val) => req(val)], cl_descr: [(val) => req(val)],
}; };
const postCalendar = () => {
const titleCard = ref("");
if ( const newCalendar = ref(false);
postParticant.value.participant.some(
(e) => e.participant_calendar == accountStore.user.is_idEmployee const calendarOrEvents = () => {
) if (propsCalendar.value.hasOwnProperty("id")) {
) { titleCard.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");
if (result.data.mess != "Ошибка валидации полей") {
dialog_create_calendar.value = false;
}
});
} else { } else {
feedalert.alert = true; titleCard.value = "Новый календарь";
feedalert.text = "Вы не можете удалить себя из редакторов"; newCalendar.value = true;
feedalert.color = "red-darken-2"; }
feedalert.ico = "mdi-alert-outline"; };
watch(
() => dialog_create_calendar,
(newValue, oldValue) => {
if (newValue) {
calendarOrEvents();
}
},
{ deep: true }
);
const postCalendar = (val) => {
if (val.isValid) {
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");
dialog_create_calendar.value = false;
});
} else {
feedalert.alert = true;
feedalert.text = "Вы не можете удалить себя из редакторов";
feedalert.color = "red-darken-2";
feedalert.ico = "mdi-alert-outline";
}
} }
}; };
@@ -244,7 +357,6 @@ export default {
}; };
const delCalendar = (idcal) => { const delCalendar = (idcal) => {
console.log(idcal, "idcal");
axiosApiInstance axiosApiInstance
.delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`) .delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`)
.then((result) => { .then((result) => {
@@ -261,8 +373,6 @@ export default {
return !!val || "Поле обязательно"; return !!val || "Поле обязательно";
}; };
return { return {
dialog_create_calendar, dialog_create_calendar,
@@ -273,6 +383,9 @@ export default {
propsCalendar, propsCalendar,
delCalendar, delCalendar,
rules, rules,
form_calendar,
titleCard,
newCalendar,
}; };
}, },
}; };
@@ -76,6 +76,7 @@
</v-expansion-panel> </v-expansion-panel>
<calendar-create <calendar-create
@update:opendialog="showDialog = $event" @update:opendialog="showDialog = $event"
:opendialog="showDialog" :opendialog="showDialog"
:calendar="calendar" :calendar="calendar"