[WIP] Фикс апдейта данных клиента

This commit is contained in:
megavrilinvv
2022-12-09 14:11:08 +03:00
parent 343ded6c07
commit a451ef055a
3 changed files with 69 additions and 50 deletions

View File

@@ -1,17 +1,19 @@
<template lang="pug">
.flex.box-border.container.items-center.cursor-pointer.justify-center.relative(
@click="changeSelect"
@click="changeSelect",
v-click-outside="closeSelect",
:class="{border: styleBorder}"
)
.flex.select.cursor-pointer.w-full.text-xl.items-center.networks(:class="optionData, 'px-2.5'")
.absolute.options.top-11.left-0(
v-show="isSelectOpen"
:id="id")
v-show="isSelectOpen",
:id="id"
)
.flex.option.justify-center.py-1.text-xl(
v-for="data in listData"
@click="(e) => chooseOption(e)"
:key="data.network"
:id="data.network"
v-for="data in listData",
@click="(e) => chooseOption(e)",
:key="data.network",
:id="data.network",
:class="data.icon"
)
.select-form-separator.cursor-pointer.mr-6px(v-if="separator")
@@ -45,6 +47,9 @@ export default {
changeSelect() {
this.isSelectOpen = !this.isSelectOpen;
},
closeSelect() {
this.isSelectOpen = false;
},
},
};
</script>

View File

@@ -282,7 +282,9 @@ export default {
)
updateContacts.push(this.dataClient.email);
});
createContacts.forEach((el) => this.postCreateContact(el));
createContacts.forEach((el) => {
if (!el.id) this.postCreateContact(el);
});
deleteContacts.forEach((el) => this.postDeleteContact(el));
updateContacts.forEach((el) => this.postUpdateContact(el));
},
@@ -296,11 +298,13 @@ export default {
.then(() => this.fetchDataClients());
},
postUpdateContact(contact) {
fetchWrapper.post(`general/contact/${contact.id}/update/`, {
fetchWrapper
.post(`general/contact/${contact.id}/update/`, {
kind: contact.kind,
username: contact.username,
person_id: this.client.id,
});
})
.then(() => this.fetchDataClients());
},
postDeleteContact(contact) {
fetchWrapper.del(`general/contact/${contact.id}/delete/`);
@@ -549,7 +553,15 @@ export default {
});
},
},
created() {
watch: {
rowOverlay() {
if (this.rowOverlay) this.startTimer();
},
client: {
deep: true,
immediate: true,
handler(newValue) {
if (newValue) {
this.dataClient = {
id: this.client.id,
fullName: `${this.client.last_name || ""} ${
@@ -558,21 +570,26 @@ export default {
age: this.client.birth_date || "",
priority: this.prioritySettings.settings.find(
(el) =>
el.priority === this.client.priority || this.client.priority === el.id
el.priority === this.client.priority ||
this.client.priority === el.id
).text,
phone: {
id: this.client.contacts.find((el) => el.kind === "PHONE")?.id || "",
id:
this.client.contacts.find((el) => el.kind === "PHONE")?.id ||
"",
kind: "PHONE",
username:
this.client.contacts.find((el) => el.kind === "PHONE")?.username ||
"",
this.client.contacts.find((el) => el.kind === "PHONE")
?.username || "",
},
email: {
id: this.client.contacts.find((el) => el.kind === "EMAIL")?.id || "",
id:
this.client.contacts.find((el) => el.kind === "EMAIL")?.id ||
"",
kind: "EMAIL",
username:
this.client.contacts.find((el) => el.kind === "EMAIL")?.username ||
"",
this.client.contacts.find((el) => el.kind === "EMAIL")
?.username || "",
},
contacts: [...this.client.contacts],
avatar: this.client.first_name
@@ -581,13 +598,10 @@ export default {
color: this.client.color,
photo: this.client.photo,
};
},
watch: {
rowOverlay() {
if (this.rowOverlay) this.startTimer();
}
},
},
},
beforeUnmount() {
if (this.timer) {
this.deleteClient();

View File

@@ -73,7 +73,7 @@ export const column = [
icon: "icon-tg",
},
{
network: "GOOGLE",
network: "GMAIL",
icon: "icon-google",
},
{