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

View File

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

View File

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