Merge pull request #182 from dderbentsov/UC-162
[WIP] Фикс апдейта данных клиента и просроченного токена
This commit is contained in:
@@ -104,16 +104,10 @@ export default {
|
||||
saveEmployeesData(res) {
|
||||
this.employeesData = res.results;
|
||||
},
|
||||
logout() {
|
||||
localStorage.removeItem("tokenAccess");
|
||||
this.$router.push("/login");
|
||||
},
|
||||
fetchEmployeesData() {
|
||||
fetchWrapper.get("general/employee/").then((res) => {
|
||||
if (res.type === "client_error") {
|
||||
this.logout();
|
||||
} else this.saveEmployeesData(res);
|
||||
});
|
||||
fetchWrapper
|
||||
.get("general/employee/")
|
||||
.then((res) => this.saveEmployeesData(res));
|
||||
},
|
||||
fetchEventsData() {
|
||||
fetchWrapper
|
||||
|
||||
@@ -118,10 +118,6 @@ export default {
|
||||
this.fetchDataClients();
|
||||
}
|
||||
},
|
||||
logout() {
|
||||
localStorage.removeItem("tokenAccess");
|
||||
this.$router.push("/login");
|
||||
},
|
||||
async fetchDataClients() {
|
||||
let response = {};
|
||||
if (this.textSearch) {
|
||||
@@ -130,32 +126,24 @@ export default {
|
||||
this.limit
|
||||
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
||||
);
|
||||
if (response.type === "client_error") {
|
||||
this.logout();
|
||||
} else {
|
||||
this.saveDataClients(response);
|
||||
this.saveFilteredClientsCount(response);
|
||||
this.paginationInfo = {
|
||||
currentPage: this.currentTablePage,
|
||||
length: this.calculatePageCount(this.filteredClientsCount),
|
||||
};
|
||||
}
|
||||
this.saveDataClients(response);
|
||||
this.saveFilteredClientsCount(response);
|
||||
this.paginationInfo = {
|
||||
currentPage: this.currentTablePage,
|
||||
length: this.calculatePageCount(this.filteredClientsCount),
|
||||
};
|
||||
} else {
|
||||
response = await fetchWrapper.get(
|
||||
`general/person/?limit=${this.limit}&offset=${
|
||||
(this.currentTablePage - 1) * this.limit
|
||||
}`
|
||||
);
|
||||
if (response.type === "client_error") {
|
||||
this.logout();
|
||||
} else {
|
||||
this.saveDataClients(response);
|
||||
this.saveClientsCount(response);
|
||||
this.paginationInfo = {
|
||||
currentPage: this.currentTablePage,
|
||||
length: this.calculatePageCount(this.clientsCount),
|
||||
};
|
||||
}
|
||||
this.saveDataClients(response);
|
||||
this.saveClientsCount(response);
|
||||
this.paginationInfo = {
|
||||
currentPage: this.currentTablePage,
|
||||
length: this.calculatePageCount(this.clientsCount),
|
||||
};
|
||||
}
|
||||
},
|
||||
calculatePageCount(count) {
|
||||
|
||||
@@ -212,29 +212,31 @@ export default {
|
||||
(el) => el.text === this.dataClient.priority
|
||||
);
|
||||
let data = {};
|
||||
if (
|
||||
this.dataClient.age !== this.client.birth_date &&
|
||||
this.dataClient.age
|
||||
) {
|
||||
let clientName = `${this.client.last_name || ""} ${
|
||||
this.client.first_name || ""
|
||||
} ${this.client.patronymic || ""}`;
|
||||
|
||||
if (!this.dataClient.fullName) this.dataClient.fullName = clientName;
|
||||
else if (this.dataClient.fullName !== clientName)
|
||||
data.full_name = this.dataClient.fullName;
|
||||
if (this.dataClient.age !== this.client.birth_date && this.dataClient.age)
|
||||
data.birth_date = this.dataClient.age;
|
||||
else if (!this.dataClient.age) {
|
||||
this.addErrorNotification(
|
||||
"Пожалуйста, введите дату рождения корректно"
|
||||
);
|
||||
this.dataClient.age = this.client.birth_date || "";
|
||||
}
|
||||
if (
|
||||
foundElement.id !== this.client.priority &&
|
||||
foundElement.text !== "-"
|
||||
) {
|
||||
data.priority = foundElement.priority;
|
||||
} else if (foundElement.text === "-") {
|
||||
data.priority = 4;
|
||||
}
|
||||
if (foundElement.id !== this.client.priority)
|
||||
data.priority = foundElement.id;
|
||||
if (
|
||||
data.birth_date &&
|
||||
moment(data.birth_date).isAfter(moment().format("YYYY-MM-DD"))
|
||||
) {
|
||||
this.addErrorNotification();
|
||||
this.dataClient.age = this.client.birth_date;
|
||||
} else
|
||||
this.addErrorNotification("Дата рождения позже текущего дня");
|
||||
this.dataClient.age = this.client.birth_date || "";
|
||||
} else if (!Object.keys(data).length == 0)
|
||||
fetchWrapper.post(`general/person/${this.client.id}/update/`, {
|
||||
full_name: this.dataClient.fullName,
|
||||
...data,
|
||||
});
|
||||
},
|
||||
@@ -264,16 +266,24 @@ export default {
|
||||
this.client.contacts.forEach((el) => {
|
||||
if (
|
||||
el.kind === "PHONE" &&
|
||||
this.dataClient.phone.username.length === 18 &&
|
||||
el.username !== this.dataClient.phone.username
|
||||
) {
|
||||
updateContacts.push(this.dataClient.phone);
|
||||
}
|
||||
} else
|
||||
this.dataClient.phone.username =
|
||||
this.client.contacts.find((el) => el.kind === "PHONE")?.username ||
|
||||
"";
|
||||
if (
|
||||
el.kind === "EMAIL" &&
|
||||
this.dataClient.email.username &&
|
||||
el.username !== this.dataClient.email.username
|
||||
) {
|
||||
updateContacts.push(this.dataClient.email);
|
||||
}
|
||||
} else
|
||||
this.dataClient.email.username =
|
||||
this.client.contacts.find((el) => el.kind === "EMAIL")?.username ||
|
||||
"";
|
||||
});
|
||||
createContacts.forEach((el) => this.postCreateContact(el));
|
||||
// deleteContacts.forEach((el) => this.postDeleteContact(el));
|
||||
@@ -336,11 +346,11 @@ export default {
|
||||
5000
|
||||
);
|
||||
},
|
||||
addErrorNotification() {
|
||||
addErrorNotification(message) {
|
||||
addNotification(
|
||||
"Некорректная дата рождения",
|
||||
"Некорректная дата рождения",
|
||||
"Дата рождения позже текущего дня",
|
||||
message,
|
||||
"error",
|
||||
5000
|
||||
);
|
||||
|
||||
@@ -87,7 +87,7 @@ export default {
|
||||
|
||||
<style lang="sass" scoped>
|
||||
.wrapper-info
|
||||
min-height: 443px
|
||||
min-height: 336px
|
||||
max-height: 443px
|
||||
overflow-y: auto
|
||||
color: var(--font-grey-color)
|
||||
|
||||
@@ -39,18 +39,22 @@
|
||||
.flex.flex-col(class="gap-y-1.5")
|
||||
span.text-sm Номер СНИЛС
|
||||
base-input.input-info(
|
||||
disabled,
|
||||
v-mask="'###-###-### ##'",
|
||||
v-model:value="identityDocument.snils.numba",
|
||||
placeholder="000–000–000 00",
|
||||
:width-input="277"
|
||||
:width-input="277",
|
||||
:style="{backgroundColor: 'var(--bg-disable-grey-color)'}"
|
||||
)
|
||||
.flex.flex-col(class="gap-y-1.5")
|
||||
span.text-sm Номер ИНН
|
||||
base-input.input-info(
|
||||
disabled,
|
||||
v-mask="'############'",
|
||||
v-model:value="identityDocument.inn.numba",
|
||||
placeholder="000000000000",
|
||||
:width-input="277"
|
||||
:width-input="277",
|
||||
:style="{backgroundColor: 'var(--bg-disable-grey-color)'}"
|
||||
)
|
||||
.px-4
|
||||
base-button(@click="saveClient" :size="40")
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
@click.stop,
|
||||
type="text",
|
||||
v-model:value="value.fullName",
|
||||
:width-input="300"
|
||||
:width-input="300",
|
||||
placeholder="Фамилия Имя Отчество"
|
||||
)
|
||||
</template>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
.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)"
|
||||
@click.stop="(e) => deleteNetwork(e)"
|
||||
)
|
||||
.flex.relative.pb-2(class="pl-[46px]")
|
||||
base-button(
|
||||
|
||||
Reference in New Issue
Block a user