From 3f7a24caaf24f006a904051284204c2a4bde02e2 Mon Sep 17 00:00:00 2001 From: Daria Golova Date: Tue, 8 Nov 2022 17:18:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0=20=D1=81=20=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D1=82=D1=8B=D0=BC=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=8F?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/base/BaseClientFormCreate.vue | 41 ++++++++++++------- .../components/FormCreateBasicInfo.vue | 3 -- 2 files changed, 27 insertions(+), 17 deletions(-) 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 Ссылки на соцсети