WIP Паспортные данные отображаются при изменении

This commit is contained in:
Daria Golova
2022-12-07 18:11:30 +03:00
parent 3ee9f9e4f9
commit e59a7f6f43
5 changed files with 161 additions and 62 deletions

View File

@@ -1,11 +1,17 @@
<template lang="pug"> <template lang="pug">
.base-select(@click="open = !open", :class="{'open': open && !disable, 'border-none': borderNone}") .base-select(@click="open = !open", :class="{'open': open, 'border-none': borderNone}")
.placeholder.text-base(:class="{'value-color': value || placeholderOpacity}") {{ value || placeholder }} .placeholder(
:class="{'value-color': value || placeholderOpacity, ...textClass}"
) {{ value || placeholder }}
.flex.items-center .flex.items-center
.select-form-separator.cursor-pointer.mr-4(v-if="separator") .select-form-separator.cursor-pointer.mr-4(v-if="separator")
span.icon-down-arrow.open-icon(:class="{'open': open && !disable }") span.icon-down-arrow.open-icon(:class="{'open': open && !disable }")
base-menu(v-if="open") base-menu(v-if="open")
.items-container(@click="open = false", v-click-outside="leaveSelect") .items-container(
@click="open = false",
v-click-outside="leaveSelect",
:class="textClass"
)
.item(v-for="item in items", :key="item.id" @click="clickItem(item.label)") {{ item.label }} .item(v-for="item in items", :key="item.id" @click="clickItem(item.label)") {{ item.label }}
</template> </template>
@@ -25,6 +31,7 @@ export default {
separator: Boolean, separator: Boolean,
placeholderOpacity: Boolean, placeholderOpacity: Boolean,
disable: Boolean, disable: Boolean,
textStyle: String,
}, },
emits: ["update:modelValue"], emits: ["update:modelValue"],
data() { data() {
@@ -41,6 +48,15 @@ export default {
this.$emit("update:modelValue", value); this.$emit("update:modelValue", value);
}, },
}, },
textClass() {
return this.textStyle
? {
[this.textStyle]: true,
}
: {
"text-base": true,
};
},
}, },
methods: { methods: {
clickItem(id) { clickItem(id) {

View File

@@ -62,7 +62,7 @@
span.title-section.font-semibold.text-xs( span.title-section.font-semibold.text-xs(
v-if="settings[section].options") {{settings[section].options[key]}} v-if="settings[section].options") {{settings[section].options[key]}}
span.title-section.font-semibold.text-xs(v-if="item.header") {{item.header}} span.title-section.font-semibold.text-xs(v-if="item.header") {{item.header}}
client-detail-input.text-sm.text-sm.w-max-fit( client-detail-input.text-sm.w-max-fit(
v-if="section!=='docs' && isChange && settings[section].options[key] !== 'Дата выдачи'", v-if="section!=='docs' && isChange && settings[section].options[key] !== 'Дата выдачи'",
:style="{fontWeight:key === 'numba'&&600, maxHeight: settings[section].options[key] !== 'Выдан' ? '40px' : ''}", :style="{fontWeight:key === 'numba'&&600, maxHeight: settings[section].options[key] !== 'Выдан' ? '40px' : ''}",
v-model:value="sectionInfo[key]", v-model:value="sectionInfo[key]",
@@ -70,7 +70,7 @@
:placeholder="settings[section].placeholder[key]" :placeholder="settings[section].placeholder[key]"
:sharp="settings[section].sharps[key] && section === 'pass' ? settings[section].sharps[key] : ''" :sharp="settings[section].sharps[key] && section === 'pass' ? settings[section].sharps[key] : ''"
) )
base-input-date.input( base-input-date.input.text-sm(
v-else-if="isChange && section !== 'docs'", v-else-if="isChange && section !== 'docs'",
v-model:value="sectionInfo.issued_by_date" v-model:value="sectionInfo.issued_by_date"
) )
@@ -79,7 +79,7 @@
@click="() => copyValue(item)" @click="() => copyValue(item)"
) )
.flex(v-if="settings[section].options && !isChange") .flex(v-if="settings[section].options && !isChange")
span.text-sm.w-fit(:style="{fontWeight:key === 'numba'&&600}") {{item}} span.text-sm.w-fit(:style="{fontWeight:key === 'numba'&&600}") {{item === 'issued_by_date' ? formattedDate : item}}
.copy.icon-copy.cursor-pointer.pl-4( .copy.icon-copy.cursor-pointer.pl-4(
v-if="key === 'numba'", v-if="key === 'numba'",
@click="() => copyValue(item)" @click="() => copyValue(item)"
@@ -125,6 +125,7 @@ import { detail } from "@/pages/clients/utils/tableConfig";
import pdfIcon from "@/assets/icons/pdf.svg"; import pdfIcon from "@/assets/icons/pdf.svg";
import wordIcon from "@/assets/icons/word.svg"; import wordIcon from "@/assets/icons/word.svg";
import exelIcon from "@/assets/icons/exel.svg"; import exelIcon from "@/assets/icons/exel.svg";
import * as moment from "moment";
export default { export default {
name: "ClientDetailInfoSection", name: "ClientDetailInfoSection",
components: { components: {
@@ -188,6 +189,11 @@ export default {
? "var(--light-grey-bg-color)" ? "var(--light-grey-bg-color)"
: "var(--default-white)"; : "var(--default-white)";
}, },
formattedDate() {
return this.sectionInfo["issued_by_date"]
? this.sectionInfo.issued_by_date.split("-").reverse().join(".")
: "";
},
}, },
methods: { methods: {
openAddDoc() { openAddDoc() {
@@ -220,13 +226,39 @@ export default {
this.showModal = false; this.showModal = false;
this.saveDocs(); this.saveDocs();
}, },
checkDataPresence(data) {
let postData = JSON.parse(JSON.stringify(data));
let keys = Object.keys(postData);
keys.forEach((key) => {
if (!postData[key]) {
delete postData[key];
}
});
return postData;
},
changeDoc() { changeDoc() {
this.isChange = false; this.isChange = false;
if (this.section === "pass") { if (this.section === "pass") {
this.docId ? this.updateDocument() : this.createDocument(); if (!this.docId) {
let changedData = Object.keys(
this.checkDataPresence(this.sectionInfo)
);
if (
changedData.length !== Object.keys(this.sectionInfo).length ||
moment(this.sectionInfo.issued_by_date).isAfter(
moment().format("YYYY-MM-DD")
)
) {
this.isData = false;
}
this.createDocument();
} else this.updateDocument();
} }
if (this.section === "addresses") { if (this.section === "addresses") {
this.addressId ? this.updateAddress() : this.createAddress(); if (!this.addressId) {
if (this.sectionInfo.join_adress === "") this.isAddress = false;
this.createAddress();
} else this.updateAddress();
} }
}, },
copyValue(text) { copyValue(text) {
@@ -267,15 +299,18 @@ export default {
}, },
watch: { watch: {
lackData: { lackData: {
deep: true,
immediate: true, immediate: true,
handler(newValue) { handler(newValue) {
this.isData = newValue; if (this.isData !== newValue) {
this.isData = newValue;
}
}, },
}, },
lackAddress: { lackAddress: {
immediate: true, immediate: true,
handler(newValue) { handler(newValue) {
this.isAddress = newValue; if (this.isAddress !== newValue) this.isAddress = newValue;
}, },
}, },
lackAttachments: { lackAttachments: {
@@ -359,4 +394,5 @@ export default {
.input .input
border: 1.5px solid var(--border-light-grey-color) border: 1.5px solid var(--border-light-grey-color)
height: 40px
</style> </style>

View File

@@ -4,6 +4,7 @@
.text-info.text-xxs.font-semibold Город .text-info.text-xxs.font-semibold Город
base-select.cursor-grab( base-select.cursor-grab(
disable, disable,
textStyle="text-sm",
placeholder="Введите город", placeholder="Введите город",
v-model="dopeAddress.city", v-model="dopeAddress.city",
:style="{backgroundColor: 'var(--bg-disable-grey-color)'}" :style="{backgroundColor: 'var(--bg-disable-grey-color)'}"

View File

@@ -20,6 +20,7 @@
:client="client", :client="client",
:deleted-client-id="deletedRowId", :deleted-client-id="deletedRowId",
:update-data-client="updateDataClient", :update-data-client="updateDataClient",
:fetch-data-clients="fetchDataClients",
@delete-client="deleteClientHandler", @delete-client="deleteClientHandler",
@recover-client="clearDeletedRowId", @recover-client="clearDeletedRowId",
) )

View File

@@ -86,22 +86,22 @@
) )
client-detail-info-wrapper.detail( client-detail-info-wrapper.detail(
v-if="isOpenDetailInfo", v-if="isOpenDetailInfo",
:data-address="dataAddress" :data-address="dataAddress",
:data-detail="dataDetail" :data-detail="dataDetail",
:data-attachments="dataAttachments" :data-attachments="dataAttachments",
:data-document="dataIdentityDocument" :data-document="dataIdentityDocument",
:save-new-doc="saveNewDoc" :save-new-doc="saveNewDoc",
:delete-doc="deleteDoc" :delete-doc="deleteDoc",
:update-document="postUpdateIdentityDocument" :update-document="postUpdateIdentityDocument",
:update-address="postUpdateAddress" :update-address="postUpdateAddress",
:lack-data="lackData" :lack-data="lackData",
:lack-address="lackAddress" :lack-address="lackAddress",
:dope-address="dopeAddress" :dope-address="dopeAddress",
:lack-attachments="lackAttachments" :lack-attachments="lackAttachments",
:create-address="postCreateAddress" :create-address="postCreateAddress",
:create-document="postCreateIdentityDocument" :create-document="postCreateIdentityDocument",
:address-id="addressId" :address-id="addressId",
:doc-id="docId" :doc-id="docId",
) )
</template> </template>
@@ -178,6 +178,7 @@ export default {
deletedClientId: String, deletedClientId: String,
updateDataClient: Function, updateDataClient: Function,
url: String, url: String,
fetchDataClients: Function,
}, },
computed: { computed: {
rowOverlay() { rowOverlay() {
@@ -223,6 +224,7 @@ export default {
data.birth_date = this.dataClient.age; data.birth_date = this.dataClient.age;
else if (!this.dataClient.age) { else if (!this.dataClient.age) {
this.addErrorNotification( this.addErrorNotification(
"Некорректная дата рождения",
"Пожалуйста, введите дату рождения корректно" "Пожалуйста, введите дату рождения корректно"
); );
this.dataClient.age = this.client.birth_date || ""; this.dataClient.age = this.client.birth_date || "";
@@ -233,12 +235,17 @@ export default {
data.birth_date && data.birth_date &&
moment(data.birth_date).isAfter(moment().format("YYYY-MM-DD")) moment(data.birth_date).isAfter(moment().format("YYYY-MM-DD"))
) { ) {
this.addErrorNotification("Дата рождения позже текущего дня"); this.addErrorNotification(
"Некорректная дата рождения",
"Дата рождения позже текущего дня"
);
this.dataClient.age = this.client.birth_date || ""; this.dataClient.age = this.client.birth_date || "";
} else if (!Object.keys(data).length == 0) } else if (!Object.keys(data).length == 0)
fetchWrapper.post(`general/person/${this.client.id}/update/`, { fetchWrapper
...data, .post(`general/person/${this.client.id}/update/`, {
}); ...data,
})
.then(() => this.fetchDataClients());
}, },
postContactsClient() { postContactsClient() {
let contacts = [...this.dataClient.contacts]; let contacts = [...this.dataClient.contacts];
@@ -334,26 +341,14 @@ export default {
}, },
async deleteClient() { async deleteClient() {
await fetchWrapper.del(`general/person/${this.client.id}/delete/`); await fetchWrapper.del(`general/person/${this.client.id}/delete/`);
this.addSuccessNotification(); this.addSuccessNotification("Клиент Успешно удален", "");
this.handleUnFocusPopup(); this.handleUnFocusPopup();
}, },
addSuccessNotification() { addSuccessNotification(title, message) {
addNotification( addNotification(new Date().getTime(), title, message, "success", 5000);
new Date().getTime(),
"Клиент Успешно удален",
"",
"success",
5000
);
}, },
addErrorNotification(message) { addErrorNotification(title, message) {
addNotification( addNotification(title, title, message, "error", 5000);
"Некорректная дата рождения",
"Некорректная дата рождения",
message,
"error",
5000
);
}, },
fetchClientDetail(id) { fetchClientDetail(id) {
fetchWrapper fetchWrapper
@@ -388,9 +383,7 @@ export default {
issued_by_org_code: data.issued_by_org_code issued_by_org_code: data.issued_by_org_code
? data?.issued_by_org_code ? data?.issued_by_org_code
: "", : "",
issued_by_date: data.issued_by_date issued_by_date: data.issued_by_date ? data?.issued_by_date : "",
? data?.issued_by_date.split("-").reverse().join(".")
: "",
}; };
this.lackData = true; this.lackData = true;
} else { } else {
@@ -410,12 +403,28 @@ export default {
series_number: this.dataIdentityDocument.numba, series_number: this.dataIdentityDocument.numba,
issued_by_org: this.dataIdentityDocument.issued_by_org, issued_by_org: this.dataIdentityDocument.issued_by_org,
issued_by_org_code: this.dataIdentityDocument.issued_by_org_code, issued_by_org_code: this.dataIdentityDocument.issued_by_org_code,
issued_by_date: this.dataIdentityDocument.issued_by_date issued_by_date: this.dataIdentityDocument.issued_by_date,
.split(".")
.reverse()
.join("-"),
}) })
.then(() => this.fetchClientDetail(this.id)); .then((response) => {
this.fetchClientDetail(this.id);
if (response.type) {
if (response.errors[0].code === "blank")
this.addErrorNotification(
"Ошибка создания ДУЛ",
"Часть паспортных данных не заполнена"
);
if (response.errors[0].code === "Ошибка создания ДУЛ")
this.addErrorNotification(
response.errors[0].code,
response.errors[0].detail
);
if (response?.errors[0].code === "invalid")
this.addErrorNotification(
"Ошибка создания ДУЛ",
"Дата выдачи паспорта не заполнена"
);
} else this.addSuccessNotification("Изменения успешно сохранены", "");
});
}, },
saveAddress(data) { saveAddress(data) {
this.addressId = data?.id; this.addressId = data?.id;
@@ -456,7 +465,15 @@ export default {
.post(`general/address/${this.addressId}/update/`, { .post(`general/address/${this.addressId}/update/`, {
full_address: this.mergeFullAddress() || this.dataAddress.join_adress, full_address: this.mergeFullAddress() || this.dataAddress.join_adress,
}) })
.then(() => this.fetchClientDetail(this.id)); .then((response) => {
this.fetchClientDetail(this.id);
if (response.type && response.errors[0].code === "blank")
this.addErrorNotification(
"Ошибка именения адреса",
"Полный адрес не заполнен"
);
else this.addSuccessNotification("Изменения успешно сохранены", "");
});
this.clearAddress(); this.clearAddress();
}, },
openPopup(e) { openPopup(e) {
@@ -494,7 +511,15 @@ export default {
person_id: this.id, person_id: this.id,
full_address: this.mergeFullAddress() || this.dataAddress.join_adress, full_address: this.mergeFullAddress() || this.dataAddress.join_adress,
}) })
.then(() => this.fetchClientDetail(this.id)); .then((response) => {
this.fetchClientDetail(this.id);
if (response.type && response.errors[0].code === "blank")
this.addErrorNotification(
"Ошибка создания адреса",
"Полный адрес не заполнен"
);
else this.addSuccessNotification("Полный адрес успешно создан", "");
});
}, },
postCreateIdentityDocument() { postCreateIdentityDocument() {
fetchWrapper fetchWrapper
@@ -504,12 +529,32 @@ export default {
series_number: this.dataIdentityDocument.numba, series_number: this.dataIdentityDocument.numba,
issued_by_org: this.dataIdentityDocument.issued_by_org, issued_by_org: this.dataIdentityDocument.issued_by_org,
issued_by_org_code: this.dataIdentityDocument.issued_by_org_code, issued_by_org_code: this.dataIdentityDocument.issued_by_org_code,
issued_by_date: this.dataIdentityDocument.issued_by_date issued_by_date: this.dataIdentityDocument.issued_by_date,
.split(".")
.reverse()
.join("-"),
}) })
.then(() => this.fetchClientDetail(this.id)); .then((response) => {
this.fetchClientDetail(this.id);
if (response.type) {
if (response.errors[0].code === "blank")
this.addErrorNotification(
"Ошибка создания ДУЛ",
"Часть паспортных данных не заполнена"
);
if (response.errors[0].code === "Ошибка создания ДУЛ")
this.addErrorNotification(
response.errors[0].code,
response.errors[0].detail
);
if (response.errors[0].code === "invalid")
this.addErrorNotification(
"Ошибка создания ДУЛ",
"Дата выдачи паспорта не заполнена"
);
} else
this.addSuccessNotification(
"Паспортные данные успешно созданы",
""
);
});
}, },
}, },
watch: { watch: {