WIP Переделала создание клиента

This commit is contained in:
Daria Golova
2023-02-22 14:01:55 +03:00
parent 2f2c331189
commit 0f9d271575
2 changed files with 23 additions and 28 deletions

View File

@@ -270,7 +270,7 @@ export default {
closeModal() { closeModal() {
!this.showModal ? this.closeForm() : null; !this.showModal ? this.closeForm() : null;
}, },
createIdentityDocument(id) { async createIdentityDocument(id) {
let doc = null; let doc = null;
let filteredData = Object.keys( let filteredData = Object.keys(
this.filterDataEmptyProperty(this.infoClient.identity_document.pass) this.filterDataEmptyProperty(this.infoClient.identity_document.pass)
@@ -291,21 +291,17 @@ export default {
"Паспортные данные не будут записаны в профиль клиента" "Паспортные данные не будут записаны в профиль клиента"
); );
} else } else
fetchWrapper doc = await fetchWrapper.post("general/identity_document/create/", {
.post("general/identity_document/create/", { series_number: this.infoClient.identity_document.pass.series_number,
series_number: issued_by_org: this.infoClient.identity_document.pass.issued_by_org,
this.infoClient.identity_document.pass.series_number, issued_by_date: moment(
issued_by_org: this.infoClient.identity_document.pass.issued_by_date
this.infoClient.identity_document.pass.issued_by_org, ).format("YYYY-MM-DD"),
issued_by_date: moment( issued_by_org_code:
this.infoClient.identity_document.pass.issued_by_date this.infoClient.identity_document.pass.issued_by_org_code,
).format("YYYY-MM-DD"), person: id,
issued_by_org_code: kind: "Паспорт",
this.infoClient.identity_document.pass.issued_by_org_code, });
person: id,
kind: "Паспорт",
})
.then((res) => (doc = res));
return Promise.resolve(doc); return Promise.resolve(doc);
} }
}, },
@@ -335,17 +331,17 @@ export default {
...this.filterDataEmptyProperty(this.infoClient.email), ...this.filterDataEmptyProperty(this.infoClient.email),
person: id, person: id,
}); });
this.infoClient.basic.contacts.forEach((el) => { for (const network of this.infoClient.basic.contacts) {
if (el.username) if (network.username) {
fetchWrapper contacts.push(
.post("general/contact/create/", { await fetchWrapper.post("general/contact/create/", {
kind: el.kind.id, kind: network.kind.id,
username: el.username, username: network.username,
person: id, person: id,
}) })
.then((res) => contacts.push(res)); );
}); }
console.log(Promise.allSettled([phone, email, contacts])); }
return Promise.allSettled([phone, email, contacts]); return Promise.allSettled([phone, email, contacts]);
}, },
postNewClient() { postNewClient() {
@@ -370,8 +366,7 @@ export default {
this.createIdentityDocument(result.id), this.createIdentityDocument(result.id),
this.createAddress(result.id), this.createAddress(result.id),
this.createContacts(result.id), this.createContacts(result.id),
]).then((res) => { ]).then(() => {
console.log(res);
this.writeCreatedClientId(result.id); this.writeCreatedClientId(result.id);
this.setUpdatedClients(); this.setUpdatedClients();
this.addSuccessNotification(); this.addSuccessNotification();

View File

@@ -10,7 +10,7 @@
:dense="dense", :dense="dense",
:type="type", :type="type",
:filled="filled", :filled="filled",
:bg-color="!filled && 'white'", :bg-color="filled ? '' : 'white'",
:disable="disabled", :disable="disabled",
:rules="rule", :rules="rule",
:mask="mask", :mask="mask",