diff --git a/src/components/base/BaseClientFormCreate.vue b/src/components/base/BaseClientFormCreate.vue index 2e5af3c..4ceec60 100644 --- a/src/components/base/BaseClientFormCreate.vue +++ b/src/components/base/BaseClientFormCreate.vue @@ -181,18 +181,19 @@ export default { }); }, postNewClient() { - fetchWrapper - .post("general/person/create/", { - full_name: this.infoClient.basic.full_name, - birth_date: this.infoClient.basic.birth_date, - priority: this.prioritySettings.settings.find( - (el) => el.text === this.infoClient.basic.priority - ).priority, - }) - .then((result) => { - this.createIdentityDocument(result.id); - this.createAddress(result.id); - }); + let sentData = { + full_name: this.infoClient.basic.full_name, + }; + 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 + ); + if (foundElement) sentData.priority = foundElement.priority; + fetchWrapper.post("general/person/create/", sentData).then((result) => { + this.createIdentityDocument(result.id); + this.createAddress(result.id); + }); }, filterDataEmptyProperty(data) { let postData = data; @@ -221,8 +222,10 @@ export default { this.infoClient.basic.contacts[index].icon = icon; }, saveClient() { - this.postNewClient(); - this.closeForm(); + if (this.checkFormFullness()) { + this.postNewClient(); + this.closeForm(); + } }, saveDocFile(e) { 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()); + }, }, }; diff --git a/src/pages/clients/components/FormCreateBasicInfo.vue b/src/pages/clients/components/FormCreateBasicInfo.vue index 2f7e719..2ce7594 100644 --- a/src/pages/clients/components/FormCreateBasicInfo.vue +++ b/src/pages/clients/components/FormCreateBasicInfo.vue @@ -6,15 +6,12 @@ base-select(:items="priorityList", placeholder="Приоритет клиента", v-model="basicInfo.priority") .flex.flex-col(class="gap-y-1.5") span.text-sm Дата рождения - span.obligatory * 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") span.text-sm Номер телефона - span.obligatory * base-input.input-info(v-model:value="phone.username" placeholder="+7 (915) 644–92–23" :width-input="277") .flex.flex-col(class="gap-y-1.5") span.text-sm Email - span.obligatory * 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") span.text-sm Ссылки на соцсети