add validation to create event form
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
teleport(:to="appContainer")
|
teleport(:to="appContainer")
|
||||||
.absolute.top-0.p-2.right-0.overflow-hidden.z-50(class="w-1/4 xl:w-1/3 sm:w-1/2")
|
.absolute.top-0.p-2.right-0.overflow-hidden.wrapper(class="w-1/4 xl:w-1/3 sm:w-1/2")
|
||||||
.pt-32(v-if="displayPadding")
|
.pt-32(v-if="displayPadding")
|
||||||
.flex.gap-2.flex-col.relative
|
.flex.gap-2.flex-col.relative
|
||||||
transition-group(name="list", @before-leave="displayPadding = true", @after-leave="displayPadding = false")
|
transition-group(name="list", @before-leave="displayPadding = true", @after-leave="displayPadding = false")
|
||||||
@@ -41,6 +41,9 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.wrapper {
|
||||||
|
z-index: 10000;
|
||||||
|
}
|
||||||
.list-enter-active,
|
.list-enter-active,
|
||||||
.list-leave-active {
|
.list-leave-active {
|
||||||
transition: all 0.5s ease;
|
transition: all 0.5s ease;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { reactive } from "vue";
|
|||||||
|
|
||||||
export const notifications = reactive({});
|
export const notifications = reactive({});
|
||||||
|
|
||||||
export const addNotification = (id, title, message, type, lifeTime = 0) => {
|
export const addNotification = (id, title, message, type, lifeTime = 3000) => {
|
||||||
notifications[id] = {
|
notifications[id] = {
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
:debounce="debounce",
|
:debounce="debounce",
|
||||||
:shadow-text="shadowText",
|
:shadow-text="shadowText",
|
||||||
:autofocus="autofocus",
|
:autofocus="autofocus",
|
||||||
hide-bottom-space
|
hide-bottom-space,
|
||||||
:error="error",
|
:error="error",
|
||||||
@focus="e => $emit('focus', e)"
|
@focus="e => $emit('focus', e)"
|
||||||
)
|
)
|
||||||
@@ -86,6 +86,7 @@ export default {
|
|||||||
circle: Boolean,
|
circle: Boolean,
|
||||||
height: String,
|
height: String,
|
||||||
error: Boolean,
|
error: Boolean,
|
||||||
|
hint: String,
|
||||||
},
|
},
|
||||||
emits: ["update:modelValue", "focus"],
|
emits: ["update:modelValue", "focus"],
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
header-record-form(
|
header-record-form(
|
||||||
:current-status="currentStatus",
|
:current-status="currentStatus",
|
||||||
:statuses="patientData.statuses",
|
:statuses="patientData.statuses",
|
||||||
:choice-status="choiceStatus"
|
:choice-status="choiceStatus",
|
||||||
v-model="time"
|
v-model="time",
|
||||||
)
|
)
|
||||||
base-input-with-search(v-model="patient", @create-person="createPerson")
|
base-input-with-search(v-model="patient", @create-person="createPerson")
|
||||||
.flex.flex-col.flex-auto.l.gap-y-8
|
.flex.flex-col.flex-auto.l.gap-y-8
|
||||||
@@ -47,6 +47,8 @@ import { fetchWrapper } from "@/shared/fetchWrapper";
|
|||||||
import { mapActions } from "vuex";
|
import { mapActions } from "vuex";
|
||||||
import PatientCreationForm from "@/components/PatientCreationForm.vue";
|
import PatientCreationForm from "@/components/PatientCreationForm.vue";
|
||||||
import BaseModal from "@/components/base/BaseModal.vue";
|
import BaseModal from "@/components/base/BaseModal.vue";
|
||||||
|
import { addNotification } from "@/components/Notifications/notificationContext";
|
||||||
|
import { errors } from "@/shared/errors";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CreateEventForm",
|
name: "CreateEventForm",
|
||||||
@@ -70,6 +72,7 @@ export default {
|
|||||||
patientData: patientData,
|
patientData: patientData,
|
||||||
currentStatus: patientData.statuses.find((e) => e.name === "Не принят"),
|
currentStatus: patientData.statuses.find((e) => e.name === "Не принят"),
|
||||||
showCreateModal: false,
|
showCreateModal: false,
|
||||||
|
errors: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -106,6 +109,10 @@ export default {
|
|||||||
await this.getEvents();
|
await this.getEvents();
|
||||||
this.closeForm();
|
this.closeForm();
|
||||||
}
|
}
|
||||||
|
if (event?.code) {
|
||||||
|
this.errors = event?.fields;
|
||||||
|
addNotification(new Date(), "Ошибка", errors[event?.type], "error");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
.flex.gap-x-3.items-center
|
.flex.gap-x-3.items-center
|
||||||
.text.font-semibold Время:
|
.text.font-semibold Время:
|
||||||
.flex.gap-x-1
|
.flex.gap-x-1
|
||||||
base-input.input.no-border(size="XS", mask="##:## - ##:##", v-model="times" )
|
base-input.input.no-border(size="XS", mask="##:## - ##:##", v-model="times", :error="!!errors?.['start'] || !!errors?.['end']")
|
||||||
.flex.h-14.gap-x-3.items-center.text-smm
|
.flex.h-14.gap-x-3.items-center.text-smm
|
||||||
.text.font-semibold Медкарта:
|
.text.font-semibold Медкарта:
|
||||||
.flex.gap-x-1
|
.flex.gap-x-1
|
||||||
@@ -86,7 +86,12 @@ export default {
|
|||||||
MedcardModal,
|
MedcardModal,
|
||||||
},
|
},
|
||||||
mixins: [v_model],
|
mixins: [v_model],
|
||||||
props: { currentStatus: Object, statuses: Array, choiceStatus: Function },
|
props: {
|
||||||
|
currentStatus: Object,
|
||||||
|
statuses: Array,
|
||||||
|
choiceStatus: Function,
|
||||||
|
errors: Object,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
noname,
|
noname,
|
||||||
|
|||||||
4
src/shared/errors.js
Normal file
4
src/shared/errors.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const errors = {
|
||||||
|
internal_error: "Внутренняя ошибка",
|
||||||
|
validation_error: "Ошибка валидации",
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user