Добавить прикрепленный файл, и пустое значение на случай отстутсвия сопроводительного письма. Данные записываются, обновляются, форма чистится
This commit is contained in:
iriska-gri committed 2024-05-15 16:52:13 +03:00
1 parent 5013b14ed9
commit fdedd6c637
5 files changed
+85 -78

No files matched your search

+2
View File
@@ -53,6 +53,8 @@ class ResponseVacancy(models.Model):
fio = models.CharField(max_length=300, verbose_name='ФИО') fio = models.CharField(max_length=300, verbose_name='ФИО')
cdate = models.DateTimeField(auto_now_add=True, verbose_name='Дата создания') cdate = models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')
text = models.TextField(null=True, verbose_name='Сообщение') text = models.TextField(null=True, verbose_name='Сообщение')
email = models.CharField(null=True,max_length=300, verbose_name='Почта')
tel = models.CharField(null=True,max_length=300, verbose_name='Номер телефона')
file = models.FileField(null=True, upload_to='response/%Y/%m/%d', verbose_name='Файл резюме') file = models.FileField(null=True, upload_to='response/%Y/%m/%d', verbose_name='Файл резюме')
vacancy = models.ForeignKey(Vacancies, on_delete=models.PROTECT, related_name='get_vacancies', verbose_name='Вакансия') vacancy = models.ForeignKey(Vacancies, on_delete=models.PROTECT, related_name='get_vacancies', verbose_name='Вакансия')
+7 -1
View File
@@ -47,5 +47,11 @@ class GetVacancies(ListAPIView):
class PostResponseVacancies(ListAPIView): class PostResponseVacancies(ListAPIView):
def post(self, request): def post(self, request):
print(request.data['resp'],'poooooooooooooost----------------------------------------------') ResponseVacancy.objects.update_or_create(vacancy_id=request.data['id'],
defaults={'fio':request.data['resp']['name'],
'text':request.data['resp']['message'],
'email':request.data['resp']['email'],
'tel':request.data['resp']['phone'],
})
return Response('ki') return Response('ki')
@@ -1,5 +1,5 @@
<template> <template>
<v-row no-gutters class="h-100 gap" v-if="vacancy.length > 0" > <v-row no-gutters class="h-100 gap" v-if="vacancy.length > 0">
<v-col lg="4" class="flex-column d-flex"> <v-col lg="4" class="flex-column d-flex">
<v-card class="h-100 pa-1 d-flex flex-column rounded-0"> <v-card class="h-100 pa-1 d-flex flex-column rounded-0">
<v-card-title <v-card-title
@@ -56,7 +56,11 @@
> >
Описание Описание
</v-card-title> </v-card-title>
<v-row no-gutters class="h-0 gap overflow-auto" id="goto-container-example"> <v-row
no-gutters
class="h-0 gap overflow-auto"
id="goto-container-example"
>
<v-col> <v-col>
<v-card <v-card
class="rounded-0 h-100" class="rounded-0 h-100"
@@ -66,30 +70,27 @@
<span class="text-h4 text-wrap"> <span class="text-h4 text-wrap">
{{ vacancyDescription.name }} {{ vacancyDescription.name }}
</span> </span>
</v-card-title> </v-card-title>
<v-card-title class="pt-0"> <v-card-title class="pt-0">
<span class="text-h5"> <span class="text-h5">
{{ vacancyDescription.department.name }} {{ vacancyDescription.department.name }}
</span> </span>
</v-card-title> </v-card-title>
<v-card-title> <v-card-title>
<v-btn <v-btn
type="submit" type="submit"
class="text-subtitle-1 font-weight-light" class="text-subtitle-1 font-weight-light"
color="btn_text" color="btn_text"
elevation=1 elevation="1"
@click="goTo('#response', { container: '#goto-container-example' })" @click="
> goTo('#response', { container: '#goto-container-example' })
Откликнуться "
</v-btn> >
Откликнуться
</v-btn>
</v-card-title> </v-card-title>
<v-card-title class="pt-6"> <v-card-title class="pt-6">
<span class="text-h6"> <span class="text-h6">
Направление деятельности подразделения Направление деятельности подразделения
</span> </span>
@@ -106,7 +107,7 @@
</li> </li>
</ul> </ul>
</v-card-text> </v-card-text>
<v-card-title > <v-card-title>
<span class="text-h6"> <span class="text-h6">
Функционал и должностные обязанности Функционал и должностные обязанности
</span> </span>
@@ -121,9 +122,7 @@
<div class="py-1" v-html="vacancyDescription.functional"></div> <div class="py-1" v-html="vacancyDescription.functional"></div>
</v-card-text> </v-card-text>
<v-divider /> <v-divider />
<response-vacancies id="response"/> <response-vacancies id="response" :idVacations=vacancySelect />
</v-card> </v-card>
<v-card <v-card
@@ -166,7 +165,7 @@
<script> <script>
import { ref } from "vue"; import { ref } from "vue";
import { useGoTo } from 'vuetify' import { useGoTo } from "vuetify";
import { clearAxios } from "@/utils/axios-api"; import { clearAxios } from "@/utils/axios-api";
import { baseURL } from "@/utils/axios-api"; import { baseURL } from "@/utils/axios-api";
import ResponseVacancies from "@/components/about_inspection/open_vacancies/ResponseVacancies.vue"; import ResponseVacancies from "@/components/about_inspection/open_vacancies/ResponseVacancies.vue";
@@ -174,7 +173,7 @@ import ResponseVacancies from "@/components/about_inspection/open_vacancies/Resp
export default { export default {
components: { ResponseVacancies }, components: { ResponseVacancies },
setup() { setup() {
const goTo = useGoTo() const goTo = useGoTo();
let vacancyDescription = ref({ name: "", department: { name: "" } }); let vacancyDescription = ref({ name: "", department: { name: "" } });
let vacancySelect = ref(-1); let vacancySelect = ref(-1);
@@ -184,7 +183,7 @@ export default {
clearAxios.get(`api/about_inspection/getvacancy/`).then((data) => { clearAxios.get(`api/about_inspection/getvacancy/`).then((data) => {
vacancy.value = data.data; vacancy.value = data.data;
vacancyDescription.value = vacancy.value[0]; vacancyDescription.value = vacancy.value[0];
// console.log(, 'data') vacancySelect.value = vacancy.value[0].id
}); });
}; };
@@ -213,7 +212,7 @@ export default {
vacancyDescription, vacancyDescription,
getIndVacation, getIndVacation,
vacancySelect, vacancySelect,
goTo goTo,
}; };
}, },
}; };
@@ -1,16 +0,0 @@
<template>
<v-card>
{{}}
</v-card>
</template>
<script>
export default {
}
</script>
<style>
</style>
@@ -35,12 +35,8 @@
no-resize no-resize
rows="4" rows="4"
label="Сопроводительное письмо" label="Сопроводительное письмо"
></v-textarea>
<v-file-input
label="Резюме"
hide-details
/> />
<v-file-input label="Резюме" hide-details />
<v-btn block type="submit" class="mt-4 text-none" color="btn_text"> <v-btn block type="submit" class="mt-4 text-none" color="btn_text">
Отправить Отправить
</v-btn> </v-btn>
@@ -51,43 +47,63 @@
</div> </div>
</template> </template>
<script setup> <script>
import { ref } from "vue"; import { ref } from "vue";
import { useField, useForm } from "vee-validate"; import { useField, useForm } from "vee-validate";
import * as yup from "yup"; import * as yup from "yup";
import { clearAxios } from "@/utils/axios-api"; import { clearAxios } from "@/utils/axios-api";
const { handleSubmit } = useForm({ export default {
validationSchema: yup.object({ props: {
email: yup idVacations: {
.string() type: Number,
.email("Введите корректный email") default: -1
.required("Поле обязательно для заполнения"), }
name: yup },
.string() setup(props) {
.matches(/^[а-яА-ЯЁё]+$/, "Имя должно содержать только русские буквы") const { handleSubmit, handleReset } = useForm({
.required("Поле обязательно для заполнения"), validationSchema: yup.object({
phone: yup email: yup
.string() .string()
.matches( .email("Введите корректный email")
/^[[\d-]*\d[\d-]*$/, .required("Поле обязательно для заполнения"),
"Номер телефона должен содержать только цифры" name: yup
) .string()
.required("Поле обязательно для заполнения"), .matches(/^[а-яА-ЯЁё]+$/, "Имя должно содержать только русские буквы")
message: yup.string(), .required("Поле обязательно для заполнения"),
}), phone: yup
}); .string()
const name = useField("name"); .matches(
const phone = useField("phone"); /^[[\d-]*\d[\d-]*$/,
const email = useField("email"); "Номер телефона должен содержать только цифры"
const message = useField("message"); )
.required("Поле обязательно для заполнения"),
const submit = handleSubmit((values) => { message: yup.string(),
clearAxios }),
.post(`api/about_inspection/postresponsevacancy/`, { resp: values })
.then((data) => {
console.log("datas");
}); });
alert(JSON.stringify(values, null, 2));
}); const name = useField("name");
const phone = useField("phone");
const email = useField("email");
const message = useField("message");
const submit = handleSubmit((values) => {
clearAxios
.post(`api/about_inspection/postresponsevacancy/`, { resp: values, id: props.idVacations })
.then((data) => {
});
handleReset()
alert(JSON.stringify(values, null, 2));
});
return {
name,
phone,
email,
message,
submit,
};
},
};
</script> </script>