Исправила создание клиента с пустыми полями

This commit is contained in:
Daria Golova
2022-11-08 17:18:31 +03:00
parent 5505b4ed04
commit 3f7a24caaf
2 changed files with 27 additions and 17 deletions

View File

@@ -181,15 +181,16 @@ export default {
}); });
}, },
postNewClient() { postNewClient() {
fetchWrapper let sentData = {
.post("general/person/create/", {
full_name: this.infoClient.basic.full_name, full_name: this.infoClient.basic.full_name,
birth_date: this.infoClient.basic.birth_date, };
priority: this.prioritySettings.settings.find( if (this.infoClient.basic.birth_date)
sentData.birth_date = this.infoClient.basic.birth_date;
let foundElement = this.prioritySettings.settings.find(
(el) => el.text === this.infoClient.basic.priority (el) => el.text === this.infoClient.basic.priority
).priority, );
}) if (foundElement) sentData.priority = foundElement.priority;
.then((result) => { fetchWrapper.post("general/person/create/", sentData).then((result) => {
this.createIdentityDocument(result.id); this.createIdentityDocument(result.id);
this.createAddress(result.id); this.createAddress(result.id);
}); });
@@ -221,8 +222,10 @@ export default {
this.infoClient.basic.contacts[index].icon = icon; this.infoClient.basic.contacts[index].icon = icon;
}, },
saveClient() { saveClient() {
if (this.checkFormFullness()) {
this.postNewClient(); this.postNewClient();
this.closeForm(); this.closeForm();
}
}, },
saveDocFile(e) { saveDocFile(e) {
this.infoClient.doc = e.target.files; this.infoClient.doc = e.target.files;
@@ -261,6 +264,16 @@ export default {
} }
}); });
}, },
checkFormFullness() {
if (!this.infoClient.basic.full_name) {
alert("Не заполнено ФИО клиента");
return false;
}
return true;
},
output() {
console.log(this.checkFormFullness());
},
}, },
}; };
</script> </script>

View File

@@ -6,15 +6,12 @@
base-select(:items="priorityList", placeholder="Приоритет клиента", v-model="basicInfo.priority") base-select(:items="priorityList", placeholder="Приоритет клиента", v-model="basicInfo.priority")
.flex.flex-col(class="gap-y-1.5") .flex.flex-col(class="gap-y-1.5")
span.text-sm Дата рождения span.text-sm Дата рождения
span.obligatory *
base-input.input-info(v-model:value="basicInfo.birth_date" type="date" placeholder="00.00.0000" :width-input="277") base-input.input-info(v-model:value="basicInfo.birth_date" type="date" placeholder="00.00.0000" :width-input="277")
.flex.flex-col(class="gap-y-1.5") .flex.flex-col(class="gap-y-1.5")
span.text-sm Номер телефона span.text-sm Номер телефона
span.obligatory *
base-input.input-info(v-model:value="phone.username" placeholder="+7 (915) 6449223" :width-input="277") base-input.input-info(v-model:value="phone.username" placeholder="+7 (915) 6449223" :width-input="277")
.flex.flex-col(class="gap-y-1.5") .flex.flex-col(class="gap-y-1.5")
span.text-sm Email span.text-sm Email
span.obligatory *
base-input.input-info(v-model:value="email.username" placeholder="user@yandex.ru" :width-input="277") base-input.input-info(v-model:value="email.username" placeholder="user@yandex.ru" :width-input="277")
.flex.flex-col.col-start-1.col-end-3.w-100(class="gap-y-1.5") .flex.flex-col.col-start-1.col-end-3.w-100(class="gap-y-1.5")
span.text-sm Ссылки на соцсети span.text-sm Ссылки на соцсети