итегрировал таблицу с сервером
This commit is contained in:
@@ -12,7 +12,10 @@ export default {
|
|||||||
name: "TableAddingNetwork",
|
name: "TableAddingNetwork",
|
||||||
components: { BaseInput, BaseSelect },
|
components: { BaseInput, BaseSelect },
|
||||||
props: {
|
props: {
|
||||||
saveNetworkId: Function,
|
saveNetworkId: {
|
||||||
|
type: Function,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
selectedOption: String,
|
selectedOption: String,
|
||||||
value: Object,
|
value: Object,
|
||||||
listAddingNetworks: Array,
|
listAddingNetworks: Array,
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
.w-full.h-fit.pt-4.flex.gap-x-4(class="px-[52px] pb-[30px]")
|
.w-full.h-fit.pt-4.flex.gap-x-4(class="px-[52px] pb-[30px]")
|
||||||
client-detail-info-section(v-model:section-info="dataDocument" section="pass")
|
client-detail-info-section(v-model:section-info="dataDocument" section="pass")
|
||||||
.flex.flex-col.gap-y-2
|
.flex.flex-col.gap-y-2
|
||||||
client-detail-info-section(:section-info="dataDetail.birthday" section="birthday")
|
client-detail-info-section(:section-info="dataAddress" section="addresses")
|
||||||
client-detail-info-section(:section-info="dataDetail.addresses" section="addresses")
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -13,6 +12,7 @@ export default {
|
|||||||
components: { ClientDetailInfoSection },
|
components: { ClientDetailInfoSection },
|
||||||
props: {
|
props: {
|
||||||
dataDetail: Object,
|
dataDetail: Object,
|
||||||
|
dataAddress: Object,
|
||||||
saveNewDoc: Function,
|
saveNewDoc: Function,
|
||||||
deleteDoc: Function,
|
deleteDoc: Function,
|
||||||
dataDocument: Object,
|
dataDocument: Object,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export default {
|
|||||||
identity_document: {
|
identity_document: {
|
||||||
pass: {
|
pass: {
|
||||||
kind: "Паспорт",
|
kind: "Паспорт",
|
||||||
numba: "",
|
series_number: "",
|
||||||
issued_by_org: "",
|
issued_by_org: "",
|
||||||
issued_by_date: "",
|
issued_by_date: "",
|
||||||
issued_by_org_code: "",
|
issued_by_org_code: "",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
:is-check="marked.includes(client.id)"
|
:is-check="marked.includes(client.id)"
|
||||||
:check="selectedCheck"
|
:check="selectedCheck"
|
||||||
:client="client"
|
:client="client"
|
||||||
|
:fetch-data-clients="fetchDataClients"
|
||||||
)
|
)
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -44,13 +45,14 @@ export default {
|
|||||||
},
|
},
|
||||||
closeFormCreateClient() {
|
closeFormCreateClient() {
|
||||||
this.isOpenFormCreate = false;
|
this.isOpenFormCreate = false;
|
||||||
|
this.fetchDataClients();
|
||||||
},
|
},
|
||||||
saveDataClients(data) {
|
saveDataClients(data) {
|
||||||
this.dataClients = data.results;
|
this.dataClients = data.results;
|
||||||
},
|
},
|
||||||
fetchDataClients() {
|
fetchDataClients() {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
fetch("api/clients").then((res) => res.json()).then((data) => this.saveDataClients(data))
|
fetch("http://45.84.227.122:8080/general/person/").then((res) => res.json()).then((data) => this.saveDataClients(data))
|
||||||
},
|
},
|
||||||
selectedCheck(e) {
|
selectedCheck(e) {
|
||||||
if (e.target.id === "checkbox") {
|
if (e.target.id === "checkbox") {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
base-button-ok(v-if="isOpenChange" :size="20" :icon-size="10" :dark-style="true" @click="closeChangeData")
|
base-button-ok(v-if="isOpenChange" :size="20" :icon-size="10" :dark-style="true" @click="closeChangeData")
|
||||||
.relative.dots-button.icon-dots.cursor-pointer.leading-6.text-center(v-show="!isOpenChange" :tabindex="1" @click="(e) => openPopup(e)" @blur="handleUnFocusPopup")
|
.relative.dots-button.icon-dots.cursor-pointer.leading-6.text-center(v-show="!isOpenChange" :tabindex="1" @click="(e) => openPopup(e)" @blur="handleUnFocusPopup")
|
||||||
clients-action-popup(v-if="isOpenPopup" :open-change-data="openChangeData")
|
clients-action-popup(v-if="isOpenPopup" :open-change-data="openChangeData")
|
||||||
client-detail-info-wrapper(v-if="isOpenDetailInfo" :data-detail="dataDetail" :data-document="dataIdentityDocument" :save-new-doc="saveNewDoc" :delete-doc="deleteDoc")
|
client-detail-info-wrapper(v-if="isOpenDetailInfo" :data-address="dataAddress" :data-detail="dataDetail" :data-document="dataIdentityDocument" :save-new-doc="saveNewDoc" :delete-doc="deleteDoc")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -49,6 +49,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dataIdentityDocument: {},
|
dataIdentityDocument: {},
|
||||||
|
dataAddress: {},
|
||||||
dataDetail: {},
|
dataDetail: {},
|
||||||
isOpenDetailInfo: false,
|
isOpenDetailInfo: false,
|
||||||
isOpenPopup: false,
|
isOpenPopup: false,
|
||||||
@@ -62,25 +63,127 @@ export default {
|
|||||||
check: Function,
|
check: Function,
|
||||||
isCheck: Boolean,
|
isCheck: Boolean,
|
||||||
client: Object,
|
client: Object,
|
||||||
|
fetchDataClients: Function,
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.dataClient = {
|
this.dataClient = {
|
||||||
fullName: `${this.client.last_name} ${this.client.first_name} ${this.client.patronymic}`,
|
id: this.client.id,
|
||||||
age: this.client.birth_date,
|
fullName: `${this.client.last_name || ""} ${
|
||||||
|
this.client.first_name || ""
|
||||||
|
} ${this.client.patronymic || ""}`,
|
||||||
|
age: this.client.birth_date || "",
|
||||||
priority: this.client.priority,
|
priority: this.client.priority,
|
||||||
phone: this.client.contacts.find((el) => el.kind === "PHONE") || {
|
phone: {
|
||||||
kind: "EMAIL",
|
id: this.client.contacts.find((el) => el.kind === "PHONE")?.id || "",
|
||||||
username: "",
|
kind: "PHONE",
|
||||||
|
username:
|
||||||
|
this.client.contacts.find((el) => el.kind === "PHONE")?.username ||
|
||||||
|
"",
|
||||||
},
|
},
|
||||||
email: this.client.contacts.find((el) => el.kind === "EMAIL") || {
|
email: {
|
||||||
|
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 ||
|
||||||
|
"",
|
||||||
},
|
},
|
||||||
contacts: [...this.client.contacts],
|
contacts: [...this.client.contacts],
|
||||||
avatar: `${this.client.last_name[0]}${this.client.first_name[0]}`,
|
avatar: `${this.client.last_name[0]}${this.client.first_name[0]}`,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
postUpdateClient() {
|
||||||
|
fetch(
|
||||||
|
`http://45.84.227.122:8080/general/person/${this.client.id}/update/`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "*/*",
|
||||||
|
"Content-Type": "application/json;charset=utf-8",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
full_name: this.dataClient.fullName,
|
||||||
|
birth_date: this.dataClient.age,
|
||||||
|
priority: this.dataClient.priority,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
postContactsClient() {
|
||||||
|
let contacts = [...this.dataClient.contacts];
|
||||||
|
if (
|
||||||
|
this.dataClient.email.username &&
|
||||||
|
!contacts.find((el) => el.kind === "EMAIL")
|
||||||
|
) {
|
||||||
|
contacts.push(this.dataClient.email);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.dataClient.phone.username &&
|
||||||
|
!contacts.find((el) => el.kind === "PHONE")
|
||||||
|
) {
|
||||||
|
contacts.push(this.dataClient.phone);
|
||||||
|
}
|
||||||
|
let mapCreateContacts = this.client.contacts.map((el) => el.kind);
|
||||||
|
// let mapDeleteContacts = contacts.map((el) => el.kind);
|
||||||
|
let createContacts = contacts.filter(
|
||||||
|
(el) => !mapCreateContacts.includes(el.kind)
|
||||||
|
);
|
||||||
|
// let deleteContacts = this.client.contacts.filter(
|
||||||
|
// (el) => !mapDeleteContacts.includes(el.kind)
|
||||||
|
// );
|
||||||
|
let updateContacts = [];
|
||||||
|
this.client.contacts.forEach((el) => {
|
||||||
|
if (
|
||||||
|
el.kind === "PHONE" &&
|
||||||
|
el.username !== this.dataClient.phone.username
|
||||||
|
) {
|
||||||
|
updateContacts.push(this.dataClient.phone);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
el.kind === "EMAIL" &&
|
||||||
|
el.username !== this.dataClient.email.username
|
||||||
|
) {
|
||||||
|
updateContacts.push(this.dataClient.email);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
createContacts.forEach((el) => this.postCreateContact(el));
|
||||||
|
// deleteContacts.forEach((el) => this.postDeleteContact(el));
|
||||||
|
updateContacts.forEach((el) => this.postUpdateContact(el));
|
||||||
|
},
|
||||||
|
|
||||||
|
postCreateContact(contact) {
|
||||||
|
fetch("http://45.84.227.122:8080/general/contact/create/", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "*/*",
|
||||||
|
"Content-Type": "application/json;charset=utf-8",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
kind: contact.kind,
|
||||||
|
username: contact.username,
|
||||||
|
person_id: this.client.id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
postUpdateContact(contact) {
|
||||||
|
fetch(`http://45.84.227.122:8080/general/contact/${contact.id}/update/`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "*/*",
|
||||||
|
"Content-Type": "application/json;charset=utf-8",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
kind: contact.kind,
|
||||||
|
username: contact.username,
|
||||||
|
person_id: this.client.id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
postDeleteContact(contact) {
|
||||||
|
fetch(`http://45.84.227.122:8080/general/contact/${contact.id}/delete/`, {
|
||||||
|
method: "DELETE",
|
||||||
|
});
|
||||||
|
},
|
||||||
addNetwork(network) {
|
addNetwork(network) {
|
||||||
this.dataClient.contacts.push(network);
|
this.dataClient.contacts.push(network);
|
||||||
},
|
},
|
||||||
@@ -96,27 +199,34 @@ export default {
|
|||||||
},
|
},
|
||||||
closeChangeData() {
|
closeChangeData() {
|
||||||
this.isOpenChange = false;
|
this.isOpenChange = false;
|
||||||
|
this.postUpdateClient();
|
||||||
|
this.postContactsClient();
|
||||||
},
|
},
|
||||||
openChangeData() {
|
openChangeData() {
|
||||||
this.isOpenChange = true;
|
this.isOpenChange = true;
|
||||||
},
|
},
|
||||||
fetchClientDetail(id) {
|
fetchClientDetail(id) {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
fetch(`/api/detail/${id}`).then((res) => res.json()).then((data) => this.saveClientDetail(data))
|
fetch(`http://45.84.227.122:8080/general/person/${id}/detail`).then((res) => res.json()).then((data) => this.saveClientDetail(data))
|
||||||
},
|
|
||||||
fetchClientIdentityDocument(id) {
|
|
||||||
// eslint-disable-next-line
|
|
||||||
fetch(`/api/detail/identity_document/${id}`).then((res) => res.json()).then((data) => this.saveIdentityDocument(data))
|
|
||||||
},
|
},
|
||||||
saveClientDetail(data) {
|
saveClientDetail(data) {
|
||||||
this.dataDetail = data;
|
this.saveIdentityDocument(
|
||||||
|
data.identity_documents.find((el) => el.kind === "Паспорт")
|
||||||
|
);
|
||||||
|
this.saveAddress(data.address[0]);
|
||||||
|
console.log(this.dataIdentityDocument);
|
||||||
},
|
},
|
||||||
saveIdentityDocument(data) {
|
saveIdentityDocument(data) {
|
||||||
this.dataIdentityDocument = {
|
this.dataIdentityDocument = {
|
||||||
numba: data.numba,
|
numba: data?.numba || "-",
|
||||||
issued_by_org: data.issued_by_org,
|
issued_by_org: data?.issued_by_org || "-",
|
||||||
issued_by_org_code: data.issued_by_org_code,
|
issued_by_org_code: data?.issued_by_org_code || "-",
|
||||||
issued_by_date: data.issued_by_date,
|
issued_by_date: data?.issued_by_date || "-",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
saveAddress(data) {
|
||||||
|
this.dataAddress = {
|
||||||
|
join_address: data?.join_address || "-",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
openPopup(e) {
|
openPopup(e) {
|
||||||
@@ -125,8 +235,7 @@ export default {
|
|||||||
},
|
},
|
||||||
openDetailInfo(e) {
|
openDetailInfo(e) {
|
||||||
this.isOpenDetailInfo = !this.isOpenDetailInfo;
|
this.isOpenDetailInfo = !this.isOpenDetailInfo;
|
||||||
this.isOpenDetailInfo && this.fetchClientDetail(e.currentTarget.id),
|
this.isOpenDetailInfo && this.fetchClientDetail(e.currentTarget.id);
|
||||||
this.fetchClientIdentityDocument(e.currentTarget.id);
|
|
||||||
},
|
},
|
||||||
handleUnFocusPopup() {
|
handleUnFocusPopup() {
|
||||||
this.isOpenPopup = false;
|
this.isOpenPopup = false;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
.grid.grid-cols-2.gap-x-4.gap-y-6
|
.grid.grid-cols-2.gap-x-4.gap-y-6
|
||||||
.flex.flex-col(class="gap-y-1.5")
|
.flex.flex-col(class="gap-y-1.5")
|
||||||
span.text-sm Серия и номер
|
span.text-sm Серия и номер
|
||||||
base-input.input-info(v-model:value="identityDocument.pass.numba" placeholder="0000 000000" :width-input="277")
|
base-input.input-info(v-model:value="identityDocument.pass.series_number" placeholder="0000 000000" :width-input="277")
|
||||||
.flex.flex-col(class="gap-y-1.5")
|
.flex.flex-col(class="gap-y-1.5")
|
||||||
span.text-sm Кем и когда выдан
|
span.text-sm Кем и когда выдан
|
||||||
base-input.input-info(v-model:value="identityDocument.pass.issued_by_org" placeholder="Точно как в паспорте" :width-input="277")
|
base-input.input-info(v-model:value="identityDocument.pass.issued_by_org" placeholder="Точно как в паспорте" :width-input="277")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.flex.box-border.px-4.items-center.w-full.text-sm(:style="{ minWidth : width + 'px' }")
|
.flex.box-border.px-4.items-center.w-full.text-sm(:style="{ minWidth : width + 'px' }")
|
||||||
span(v-if="!isOpenChange") {{new Date().getFullYear() - new Date(value.age).getFullYear()}}
|
span(v-if="!isOpenChange") {{value.age ? new Date().getFullYear() - new Date(value.age).getFullYear() : ""}}
|
||||||
base-input(v-if="isOpenChange" type="date" v-model:value="value.age" :width-input="124")
|
base-input(v-if="isOpenChange" type="date" v-model:value="value.age" :width-input="124")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.network-cell.flex.box-border.px-4.items-center.w-full(:style="{ minWidth : width + 'px' }")
|
.network-cell.flex.box-border.px-4.items-center.w-full(:style="{ minWidth : width + 'px' }")
|
||||||
.flex.gap-x-1
|
.flex.gap-x-1
|
||||||
.text-xl.icon.relative(v-for="network in getNetworks" :class="settings.settings.find((el) => el.network === network.kind).icon")
|
.text-xl.icon.relative(v-for="network in getNetworks" :class="settings.settings.find((el) => el.network === network.kind)?.icon || ''")
|
||||||
.absolute.icon-cancel-mini.delete.flex.w-4.h-4.justify-center.items-center.bottom-4.left-2(v-if="isOpenChange" :id="network.kind" @click="(e) => deleteNetwork(e)")
|
.absolute.icon-cancel-mini.delete.flex.w-4.h-4.justify-center.items-center.bottom-4.left-2(v-if="isOpenChange" :id="network.kind" @click="(e) => deleteNetwork(e)")
|
||||||
.flex.relative
|
.flex.relative.pb-2
|
||||||
base-button-plus.ml-3(v-if="isOpenChange && settings.settings.length !== getNetworks.length" :with-border="true" @click="openPopupAdding")
|
base-button-plus.ml-3(v-if="isOpenChange && settings.settings.length !== getNetworks.length" :with-border="true" @click="openPopupAdding")
|
||||||
base-popup.right-3.top-6(v-if="isOpenPopupAdding" :width="485")
|
base-popup.right-3.top-6(v-if="isOpenPopupAdding" :width="485")
|
||||||
base-adding-network(:value="network" :selected-option="getSelectedIcon" :list-adding-networks="getAddingNetworks" :choose-network="chooseNetwork")
|
base-adding-network(:value="network" :selected-option="getSelectedIcon" :list-adding-networks="getAddingNetworks" :choose-network="chooseNetwork")
|
||||||
@@ -25,7 +25,14 @@ export default {
|
|||||||
BaseCreateButton,
|
BaseCreateButton,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
networks: Array,
|
networks: {
|
||||||
|
default: [
|
||||||
|
{
|
||||||
|
kind: "TELEGRAM",
|
||||||
|
username: "",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
width: Number,
|
width: Number,
|
||||||
isOpenChange: Boolean,
|
isOpenChange: Boolean,
|
||||||
deleteNetwork: Function,
|
deleteNetwork: Function,
|
||||||
@@ -42,6 +49,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
getNetworks() {
|
||||||
|
return this.networks.filter(
|
||||||
|
(el) => el.kind !== "EMAIL" && el.kind !== "PHONE"
|
||||||
|
);
|
||||||
|
},
|
||||||
getSelectedIcon() {
|
getSelectedIcon() {
|
||||||
return this.settings.settings.find(
|
return this.settings.settings.find(
|
||||||
(el) => el.network === this.network.kind
|
(el) => el.network === this.network.kind
|
||||||
@@ -51,11 +63,6 @@ export default {
|
|||||||
let kinds = this.networks.map((el) => el.kind);
|
let kinds = this.networks.map((el) => el.kind);
|
||||||
return this.settings.settings.filter((el) => !kinds.includes(el.network));
|
return this.settings.settings.filter((el) => !kinds.includes(el.network));
|
||||||
},
|
},
|
||||||
getNetworks() {
|
|
||||||
return this.networks.filter(
|
|
||||||
(el) => el.kind !== "EMAIL" && el.kind !== "PHONE"
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
chooseNetwork(e) {
|
chooseNetwork(e) {
|
||||||
@@ -64,6 +71,10 @@ export default {
|
|||||||
saveNetwork() {
|
saveNetwork() {
|
||||||
this.addNetwork(this.network);
|
this.addNetwork(this.network);
|
||||||
this.isOpenPopupAdding = false;
|
this.isOpenPopupAdding = false;
|
||||||
|
this.network = {
|
||||||
|
kind: "TELEGRAM",
|
||||||
|
username: "",
|
||||||
|
};
|
||||||
},
|
},
|
||||||
openPopupAdding() {
|
openPopupAdding() {
|
||||||
this.isOpenPopupAdding = true;
|
this.isOpenPopupAdding = true;
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ export const column = [
|
|||||||
network: "DISCORD",
|
network: "DISCORD",
|
||||||
icon: "icon-discord",
|
icon: "icon-discord",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
network: "VIBER",
|
||||||
|
icon: "icon-mail",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
network: "WHATS_APP",
|
||||||
|
icon: "icon-mail",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
iconHead: false,
|
iconHead: false,
|
||||||
width: 152,
|
width: 152,
|
||||||
@@ -125,8 +133,7 @@ export const detail = {
|
|||||||
addresses: {
|
addresses: {
|
||||||
title: "Адреса",
|
title: "Адреса",
|
||||||
options: {
|
options: {
|
||||||
registrationPlace: "Адрес постоянной регистрации",
|
join_address: "Полный адрес",
|
||||||
actualPlace: "Адрес фактического проживания",
|
|
||||||
},
|
},
|
||||||
width: 292,
|
width: 292,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user